diff options
Diffstat (limited to 'roles')
-rw-r--r-- | roles/factorio/files/server-settings.json | 41 | ||||
-rw-r--r-- | roles/factorio/tasks/main.yml | 69 | ||||
-rw-r--r-- | roles/factorio/vars/main.yml | 9 |
3 files changed, 119 insertions, 0 deletions
diff --git a/roles/factorio/files/server-settings.json b/roles/factorio/files/server-settings.json new file mode 100644 index 0000000..71d8a9e --- /dev/null +++ b/roles/factorio/files/server-settings.json @@ -0,0 +1,41 @@ +{ + "name": "<rgoncalves.se> 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/tasks/main.yml b/roles/factorio/tasks/main.yml new file mode 100644 index 0000000..3c23569 --- /dev/null +++ b/roles/factorio/tasks/main.yml @@ -0,0 +1,69 @@ + +# factorio ~~ roles/factorio/tasks/main.yml +# factorio gameserver + +--- + +- name: create factorio group + group: + name: "{{ factorio_group }}" + state: present + +- name: create factorio user + user: + name: "{{ factorio_user }}" + group: "{{ factorio_group }}" + state: present + +- name: create factorio directory + file: + path: "{{ factorio_dir }}" + owner: "{{ factorio_user }}" + group: "{{ factorio_group }}" + state: directory + mode: 0700 + +- name: download latest factorio server + get_url: + url: https://factorio.com/get-download/latest/headless/linux64 + dest: "{{ factorio_dir }}/factorio.tar.gz" + owner: "{{ factorio_user }}" + group: "{{ factorio_group }}" + mode: 0600 + register: archive + +- name: untar factorio server + unarchive: + src: "{{ factorio_dir }}/factorio.tar.gz" + dest: "{{ factorio_dir }}" + extra_opts: + - --strip-components=1 + remote_src: true + when: archive.changed + +- name: deploy server settings + copy: + src: server-settings.json + dest: "{{ factorio_dir }}/data/server-settings.json" + owner: "{{ factorio_user }}" + group: "{{ factorio_group }}" + mode: 0600 + +- name: ensure default world does not exist + stat: path="{{ factorio_dir }}/{{ factorio_world }}" + register: world + +- name: create default world + shell: ./bin/x64/factorio --create "{{ factorio_world }}" + args: + chdir: "{{ factorio_dir }}" + 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_user: "{{ factorio_user }}:{{ factorio_group }}" + rc_dir: "{{ factorio_dir }}" + rc_name: factorio diff --git a/roles/factorio/vars/main.yml b/roles/factorio/vars/main.yml new file mode 100644 index 0000000..41b1e34 --- /dev/null +++ b/roles/factorio/vars/main.yml @@ -0,0 +1,9 @@ + +# factorio ~~ roles/factorio/vars/main.yml + +--- + +factorio_user: "factorio" +factorio_group: "factorio" +factorio_dir: "/data/factorio" +factorio_world: "saves/world.zip" |