aboutsummaryrefslogtreecommitdiffstats
path: root/roles/minecraft/tasks/main.yml
blob: d75ff0754bc8c11ce9399702ebe20f02bc4f1953 (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

# minecraft ~~ tasks/main.yml

---

- name: create minecraft group
  group:
    name: "{{ minecraft_group }}"
    state: present

- name: create minecraft user
  user:
    name: "{{ minecraft_user }}"
    group: "{{ minecraft_group }}"

- name: create minecraft directory
  file:
    path: "{{ minecraft_dir }}"
    owner: "{{ minecraft_user }}"
    group: "{{ minecraft_user }}"
    mode: 0700
    state: directory

- name: download minecraft server
  get_url:
    url: "{{ minecraft_url }}"
    dest: "{{ minecraft_dir }}/{{ minecraft_bin }}"
    owner: "{{ minecraft_user }}"

- name: enable eula
  lineinfile:
    path: "{{ minecraft_dir }}/eula.txt"
    regexp: "^eula=false"
    line: eula=true
    owner: "{{ minecraft_user }}"
    group: "{{ minecraft_group }}"
    mode: 0600
    create: true

- name: generate launch script
  template:
    src: launch.sh.j2
    dest: "{{ minecraft_dir }}/launch.sh"
    owner: "{{ minecraft_user }}"
    group: "{{ minecraft_group }}"
    mode: 0700

- name: create service minecraft server
  include_role: name=rc
  vars:
    rc_cmd: java
    rc_args: "-jar -Xms{{ minecraft_ram }} -Xmx{{ minecraft_ram }} -XX:+UseG1GC -jar server.jar nogui"
    rc_user: "{{ minecraft_user }}:{{ minecraft_group }}"
    rc_dir: "{{ minecraft_dir }}"
    rc_name: minecraft
remember that computers suck.