|
1 --- |
|
2 |
|
3 - name: add minecraft user |
|
4 become: yes |
|
5 user: name="{{minecraft_user}}" home="{{minecraft_dir}}" |
|
6 |
|
7 - name: install adoptopenjdk |
|
8 include_tasks: adoptopenjdk.yaml |
|
9 |
|
10 - name: set minecraft fork |
|
11 set_fact: minecraft_url="{{minecraft_vanilla_url}}" |
|
12 when: minecraft_fork == "vanilla" |
|
13 |
|
14 - name: set minecraft fork |
|
15 set_fact: minecraft_url="{{minecraft_paper_url}}" |
|
16 when: minecraft_fork == "paper" |
|
17 |
|
18 - name: create minecraft dir |
|
19 become: yes |
|
20 file: |
|
21 path: "{{minecraft_dir}}" |
|
22 owner: "{{minecraft_user}}" |
|
23 group: "{{minecraft_user}}" |
|
24 mode: "0755" |
|
25 state: "directory" |
|
26 |
|
27 - name: download minecraft |
|
28 become: yes |
|
29 get_url: |
|
30 url: "{{minecraft_url}}" |
|
31 dest: "{{minecraft_dir}}/server.jar" |
|
32 mode: "0755" |
|
33 notify: restart minecraft |
|
34 |
|
35 - name: configure minecraft eula |
|
36 become: yes |
|
37 copy: |
|
38 src: "{{item}}" |
|
39 dest: "{{minecraft_dir}}/{{item}}" |
|
40 owner: "{{minecraft_user}}" |
|
41 group: "{{minecraft_user}}" |
|
42 loop: |
|
43 - "eula.txt" |
|
44 notify: restart minecraft |
|
45 |
|
46 - name: configure minecraft ops |
|
47 become: yes |
|
48 template: |
|
49 src: "ops.json.j2" |
|
50 dest: "{{minecraft_dir}}/ops.json" |
|
51 owner: "{{minecraft_user}}" |
|
52 group: "{{minecraft_user}}" |
|
53 notify: restart minecraft |
|
54 |
|
55 - name: install plugins |
|
56 include_tasks: dynmap.yaml |
|
57 when: minecraft_fork == "paper" |
|
58 |
|
59 - name: create server.properties |
|
60 become: yes |
|
61 file: |
|
62 path: "{{minecraft_dir}}/server.properties" |
|
63 state: "touch" |
|
64 access_time: "preserve" |
|
65 modification_time: "preserve" |
|
66 owner: "{{minecraft_user}}" |
|
67 group: "{{minecraft_user}}" |
|
68 |
|
69 - name: configure server.properties |
|
70 become: yes |
|
71 lineinfile: |
|
72 path: "{{minecraft_dir}}/server.properties" |
|
73 regexp: "^{{item.key}}=" |
|
74 line: "{{item.key}}={{item.value}}" |
|
75 notify: restart minecraft |
|
76 loop: |
|
77 - {key: "motd", value: "{{minecraft_motd}}"} |
|
78 - {key: "level-seed", value: "{{minecraft_seed}}"} |
|
79 - {key: "difficulty", value: "{{minecraft_difficulty}}"} |
|
80 |
|
81 - name: install systemd service |
|
82 become: yes |
|
83 template: |
|
84 src: "minecraft.service.j2" |
|
85 dest: "/lib/systemd/system/minecraft.service" |
|
86 notify: restart minecraft |
|
87 |
|
88 - name: ensure service is started |
|
89 become: yes |
|
90 systemd: name="minecraft.service" enabled="yes" state="started" |