diff options
author | binary <me@rgoncalves.se> | 2020-11-21 16:14:55 +0100 |
---|---|---|
committer | binary <me@rgoncalves.se> | 2020-11-21 16:14:55 +0100 |
commit | 77eef6041db574d65c4dd6f5af1468db7b8fbb36 (patch) | |
tree | 4eb27757eb4bf94817b93dbee1f73cffcf3a0627 /roles/factorio/tasks | |
parent | 141a96d2ce17194acb14b48b5a00fc10f2972879 (diff) | |
download | infrastructure-77eef6041db574d65c4dd6f5af1468db7b8fbb36.tar.gz |
Add factorio role.
Diffstat (limited to 'roles/factorio/tasks')
-rw-r--r-- | roles/factorio/tasks/main.yml | 69 |
1 files changed, 69 insertions, 0 deletions
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 |