From 3ace280acec54508dcd1ab9964fa57a47fb752f5 Mon Sep 17 00:00:00 2001 From: binary Date: Thu, 25 Mar 2021 21:39:06 +0100 Subject: Fix alpine quirks automatically --- roles/factorio/files/server-settings.json | 41 ------------------------ roles/factorio/meta/main.yml | 10 ++++++ roles/factorio/tasks/main.yml | 24 ++++++++++---- roles/factorio/templates/server-settings.json.j2 | 41 ++++++++++++++++++++++++ roles/factorio/vars/main.yml | 10 ++++-- 5 files changed, 76 insertions(+), 50 deletions(-) delete mode 100644 roles/factorio/files/server-settings.json create mode 100644 roles/factorio/meta/main.yml create mode 100644 roles/factorio/templates/server-settings.json.j2 (limited to 'roles/factorio') diff --git a/roles/factorio/files/server-settings.json b/roles/factorio/files/server-settings.json deleted file mode 100644 index 71d8a9e..0000000 --- a/roles/factorio/files/server-settings.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": " coal factory D:", - "description": "We need more coal", - "tags": ["game", "tags"], - - "max_players": 8, - - "visibility": - { - "public": false, - "lan": true - }, - - "username": "", - "password": "", - "token": "", - - "game_password": "", - "require_user_verification": true, - - "max_upload_in_kilobytes_per_second": 0, - "max_upload_slots": 5, - - "minimum_latency_in_ticks": 0, - "ignore_player_limit_for_returning_players": false, - - "allow_commands": "admins-only", - "autosave_interval": 10, - "autosave_slots": 5, - - "afk_autokick_interval": 10, - "auto_pause": true, - - "only_admins_can_pause_the_game": true, - "non_blocking_saving": false, - - "minimum_segment_size": 25, - "minimum_segment_size_peer_count": 20, - "maximum_segment_size": 100, - "maximum_segment_size_peer_count": 10 -} diff --git a/roles/factorio/meta/main.yml b/roles/factorio/meta/main.yml new file mode 100644 index 0000000..56a37d5 --- /dev/null +++ b/roles/factorio/meta/main.yml @@ -0,0 +1,10 @@ + +# factorio ~~ roles/factorio/meta/main.yml + +--- + +dependencies: + + - role: alpine_glibc + tags: "dependency" + when: ansible_distribution == "Alpine" diff --git a/roles/factorio/tasks/main.yml b/roles/factorio/tasks/main.yml index 3c23569..548d7de 100644 --- a/roles/factorio/tasks/main.yml +++ b/roles/factorio/tasks/main.yml @@ -25,25 +25,33 @@ - name: download latest factorio server get_url: - url: https://factorio.com/get-download/latest/headless/linux64 + url: "{{ factorio_url }}" dest: "{{ factorio_dir }}/factorio.tar.gz" owner: "{{ factorio_user }}" group: "{{ factorio_group }}" mode: 0600 register: archive +- name: ensure GNU tar is present for busybox + package: + name: tar + state: present + when: ansible_distribution == "Alpine" + - name: untar factorio server unarchive: src: "{{ factorio_dir }}/factorio.tar.gz" dest: "{{ factorio_dir }}" + owner: "{{ factorio_user }}" + group: "{{ factorio_group }}" + remote_src: true extra_opts: - --strip-components=1 - remote_src: true when: archive.changed -- name: deploy server settings - copy: - src: server-settings.json +- name: generate server setting + template: + src: server-settings.json.j2 dest: "{{ factorio_dir }}/data/server-settings.json" owner: "{{ factorio_user }}" group: "{{ factorio_group }}" @@ -54,16 +62,18 @@ register: world - name: create default world - shell: ./bin/x64/factorio --create "{{ factorio_world }}" + shell: "{{ factorio_dir }}/bin/x64/factorio --create {{ factorio_world }}" args: chdir: "{{ factorio_dir }}" + become: true + become_user: "{{ factorio_user }}" when: world.stat.islnk is not defined - name: enable and start rc script include_role: name=rc vars: rc_cmd: "{{ factorio_dir }}/bin/x64/factorio" - rc_args: --server-settings server-settings.json --start-server "{{ factorio_world }}" + rc_args: "--server-settings data/server-settings.json --start-server {{ factorio_world }}" rc_user: "{{ factorio_user }}:{{ factorio_group }}" rc_dir: "{{ factorio_dir }}" rc_name: factorio diff --git a/roles/factorio/templates/server-settings.json.j2 b/roles/factorio/templates/server-settings.json.j2 new file mode 100644 index 0000000..b64b2d6 --- /dev/null +++ b/roles/factorio/templates/server-settings.json.j2 @@ -0,0 +1,41 @@ +{ + "name": "{{ global.domain_name }} - {{ factorio__name }}", + "description": "{{ factorio__description }}", + "tags": ["game", "tags"], + + "max_players": {{ factorio__max_players }}, + + "visibility": + { + "public": {{ factorio__public }}, + "lan": true + }, + + "username": "", + "password": "", + "token": "", + + "game_password": "", + "require_user_verification": true, + + "max_upload_in_kilobytes_per_second": 0, + "max_upload_slots": 5, + + "minimum_latency_in_ticks": 0, + "ignore_player_limit_for_returning_players": false, + + "allow_commands": "admins-only", + "autosave_interval": 10, + "autosave_slots": 5, + + "afk_autokick_interval": 10, + "auto_pause": true, + + "only_admins_can_pause_the_game": true, + "non_blocking_saving": false, + + "minimum_segment_size": 25, + "minimum_segment_size_peer_count": 20, + "maximum_segment_size": 100, + "maximum_segment_size_peer_count": 10 +} diff --git a/roles/factorio/vars/main.yml b/roles/factorio/vars/main.yml index 41b1e34..e08bdf6 100644 --- a/roles/factorio/vars/main.yml +++ b/roles/factorio/vars/main.yml @@ -3,7 +3,13 @@ --- -factorio_user: "factorio" -factorio_group: "factorio" +factorio_user: "_factorio" +factorio_group: "_factorio" factorio_dir: "/data/factorio" factorio_world: "saves/world.zip" +factorio_url: "https://factorio.com/get-download/latest/headless/linux64" + +factorio__name: "coal reactor!" +factorio__description: "we eat coal" +factorio__public: "false" +factorio__max_players: "8" -- cgit v1.2.3