aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2021-03-25 21:39:06 +0100
committerbinary <me@rgoncalves.se>2021-03-25 21:39:06 +0100
commit3ace280acec54508dcd1ab9964fa57a47fb752f5 (patch)
treeba905644bbd331f61b2219de8af32b3af51e281c
parent376743ac96ee505fa967af675034fb796835b2e9 (diff)
downloadinfrastructure-3ace280acec54508dcd1ab9964fa57a47fb752f5.tar.gz
Fix alpine quirks automatically
-rw-r--r--roles/factorio/meta/main.yml10
-rw-r--r--roles/factorio/tasks/main.yml24
-rw-r--r--roles/factorio/templates/server-settings.json.j2 (renamed from roles/factorio/files/server-settings.json)8
-rw-r--r--roles/factorio/vars/main.yml10
4 files changed, 39 insertions, 13 deletions
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/files/server-settings.json b/roles/factorio/templates/server-settings.json.j2
index 71d8a9e..b64b2d6 100644
--- a/roles/factorio/files/server-settings.json
+++ b/roles/factorio/templates/server-settings.json.j2
@@ -1,13 +1,13 @@
{
- "name": "<rgoncalves.se> coal factory D:",
- "description": "We need more coal",
+ "name": "{{ global.domain_name }} - {{ factorio__name }}",
+ "description": "{{ factorio__description }}",
"tags": ["game", "tags"],
- "max_players": 8,
+ "max_players": {{ factorio__max_players }},
"visibility":
{
- "public": false,
+ "public": {{ factorio__public }},
"lan": true
},
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"
remember that computers suck.