blob: 3c23569ebe120e2bfa2146975818ac40fc16b83d (
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
|
# 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
|