-
Notifications
You must be signed in to change notification settings - Fork 18
/
provision-infra-minecraft.yml
84 lines (77 loc) · 2.13 KB
/
provision-infra-minecraft.yml
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
80
81
82
83
84
---
- name: MINECRAFT - INITIAL SETUP
hosts: minecraft.infra.netsoc.co
become: yes
roles:
- ansible-requirements
- utf8-locale
- docker
tags:
- init
- name: MINECRAFT - SETUP SERVER
hosts: minecraft.infra.netsoc.co
become: yes
tasks:
- name: Rember Manifest Map
set_fact:
manifest: "{{ lookup('file', '{{ playbook_dir }}/roles/minecraft/files/manifest.json') | from_json }}"
tags:
- server
- name: Ensure directories exist
file:
path: '/{{ item }}'
owner: root
group: root
mode: '0777'
state: directory
with_items:
- data
- 'data/mods'
- name: Ensure server icon
copy:
src: '{{ playbook_dir }}/roles/minecraft/files/server-icon.png'
dest: /data/server-icon.png
- name: Ensure server.properties
copy:
src: '{{ playbook_dir }}/roles/minecraft/files/server.properties'
dest: /data/server.properties
- name: Download Mods
get_url:
dest: '/data/mods'
url: "{{ lookup('url', 'https://addons-ecs.forgesvc.net/api/v2/addon/{{item.projectID}}/file/{{item.fileID}}/download-url') | replace(' ', '%20') }}"
force: no
loop: '{{ manifest.files }}'
- name: Remember Compose definition
set_fact:
minecraft_definition:
version: '3.8'
services:
minecraft:
container_name: minecraft
image: itzg/minecraft-server:java17
ports:
- '1194:25565/tcp'
- '19565:19565'
restart: always
volumes:
- '/data:/data'
environment:
EULA: 'TRUE'
TYPE: FORGE
MEMORY: 10G
VERSION: '{{ manifest.minecraft.version }}'
tags:
- server
- name: Setup compose
docker_compose:
project_name: minecraft
recreate: always
restarted: yes
pull: yes
remove_orphans: yes
state: present
definition: '{{ minecraft_definition }}'
tags:
- server
tags:
- minecraft