minecraft/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Wed, 13 May 2020 09:24:18 -0500
changeset 20 9cacee5eec83
parent 19 31de177274a1
child 27 8fddefdd948b
permissions -rw-r--r--
Added ops to minecraft role.
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"
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    29
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
- name: configure minecraft
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    31
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    32
  template:
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
    src: "server.properties.j2"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    34
    dest: "{{minecraft_dir}}/server.properties"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    35
    owner: "{{minecraft_user}}"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
    group: "{{minecraft_user}}"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    37
  notify: restart minecraft
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    38
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    39
- name: install systemd service
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    41
  template:
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    42
    src: "minecraft.service.j2"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    43
    dest: "/lib/systemd/system/minecraft.service"
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    44
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    45
- name: ensure service is started
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    46
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    47
  systemd: name="minecraft.service" enabled="yes" state="started"