blob: 548d7def2ff29cdfb3e13db53a7ce316e5004e41 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# 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: "{{ 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
when: archive.changed
- name: generate server setting
template:
src: server-settings.json.j2
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: "{{ 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 data/server-settings.json --start-server {{ factorio_world }}"
rc_user: "{{ factorio_user }}:{{ factorio_group }}"
rc_dir: "{{ factorio_dir }}"
rc_name: factorio
|