aboutsummaryrefslogtreecommitdiffstats
path: root/roles/factorio/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/factorio/tasks')
-rw-r--r--roles/factorio/tasks/main.yml69
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
remember that computers suck.