aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-11-21 16:14:55 +0100
committerbinary <me@rgoncalves.se>2020-11-21 16:14:55 +0100
commit77eef6041db574d65c4dd6f5af1468db7b8fbb36 (patch)
tree4eb27757eb4bf94817b93dbee1f73cffcf3a0627
parent141a96d2ce17194acb14b48b5a00fc10f2972879 (diff)
downloadinfrastructure-77eef6041db574d65c4dd6f5af1468db7b8fbb36.tar.gz
Add factorio role.
-rw-r--r--host_vars/vm0.yml7
-rw-r--r--playbooks/vm0.rgoncalves.se.yml3
-rw-r--r--roles/factorio/files/server-settings.json41
-rw-r--r--roles/factorio/tasks/main.yml69
-rw-r--r--roles/factorio/vars/main.yml9
5 files changed, 128 insertions, 1 deletions
diff --git a/host_vars/vm0.yml b/host_vars/vm0.yml
index 781eeda..2b372a9 100644
--- a/host_vars/vm0.yml
+++ b/host_vars/vm0.yml
@@ -14,7 +14,14 @@ services:
- name: "minecraft"
proto: "tcp"
port: "25565"
+ public: true
- name: "minecraft"
proto: "udp"
port: "25565"
+ public: true
+
+ - name: "factorio"
+ proto: "udp"
+ port: "34197"
+ public: true
diff --git a/playbooks/vm0.rgoncalves.se.yml b/playbooks/vm0.rgoncalves.se.yml
index da1862d..5e9ca4a 100644
--- a/playbooks/vm0.rgoncalves.se.yml
+++ b/playbooks/vm0.rgoncalves.se.yml
@@ -8,6 +8,7 @@
- hosts: vm0
roles:
+ - { role: alpine_glibc }
- { role: minecraft }
- # - { role: factorio }
+ - { role: factorio }
# - { role: stationeers }
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"
remember that computers suck.