minecraft/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 16 May 2020 10:23:01 -0500
changeset 27 8fddefdd948b
parent 20 9cacee5eec83
permissions -rw-r--r--
More fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
---
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
- name: add minecract user
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     5
  user: name="{{minecraft_user}}" home="{{minecraft_dir}}"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
- name: install jre
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     9
  apt: name="default-jre-headless"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
- name: download minecraft
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    13
  get_url:
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
    url: "{{minecraft_url}}"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    15
    dest: "{{minecraft_dir}}/server.jar"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    16
    mode: "0755"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    17
  notify: restart minecraft
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    18
20
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    19
- name: configure eula and ops
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    20
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    21
  copy:
20
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    22
    src: "{{item}}"
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    23
    dest: "{{minecraft_dir}}/{{item}}"
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    24
    owner: "{{minecraft_user}}"
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    25
    group: "{{minecraft_user}}"
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    26
  loop:
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    27
    - "eula.txt"
9cacee5eec83 Added ops to minecraft role.
Luke Hoersten <luke@hoersten.org>
parents: 19
diff changeset
    28
    - "ops.json"
27
8fddefdd948b More fixes
Luke Hoersten <luke@hoersten.org>
parents: 20
diff changeset
    29
  notify: restart minecraft
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
27
8fddefdd948b More fixes
Luke Hoersten <luke@hoersten.org>
parents: 20
diff changeset
    31
# minecraft server writes a timtestamp to the config every time it starts so this always generates a change.
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    32
- name: configure minecraft
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    34
  template:
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    35
    src: "server.properties.j2"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
    dest: "{{minecraft_dir}}/server.properties"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    37
    owner: "{{minecraft_user}}"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    38
    group: "{{minecraft_user}}"
27
8fddefdd948b More fixes
Luke Hoersten <luke@hoersten.org>
parents: 20
diff changeset
    39
  changed_when: false
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    41
- name: install systemd service
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    42
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    43
  template:
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    44
    src: "minecraft.service.j2"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    45
    dest: "/lib/systemd/system/minecraft.service"
27
8fddefdd948b More fixes
Luke Hoersten <luke@hoersten.org>
parents: 20
diff changeset
    46
  notify: restart minecraft
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    47
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    48
- name: ensure service is started
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    49
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    50
  systemd: name="minecraft.service" enabled="yes" state="started"