papermc/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Tue, 09 Jun 2020 14:39:54 -0500
changeset 38 b4e705f4cda4
parent 33 ad75fc2d2853
child 42 edb53dfadfb5
permissions -rw-r--r--
Suppress warning.
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
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
     3
- name: add papermc user
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
     5
  user: name="{{papermc_user}}" home="{{papermc_dir}}"
19
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
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    11
- name: download papermc
19
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:
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    14
    url: "{{papermc_url}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    15
    dest: "{{papermc_dir}}/server.jar"
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    16
    mode: "0755"
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    17
  notify: restart papermc
19
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}}"
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    23
    dest: "{{papermc_dir}}/{{item}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    24
    owner: "{{papermc_user}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    25
    group: "{{papermc_user}}"
20
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"
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    29
  notify: restart papermc
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    31
- name: set motd
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    32
  become: yes
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    33
  lineinfile:
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    34
    path: "{{papermc_dir}}/server.properties"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    35
    regexp: "^motd="
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    36
    line: "motd={{papermc_motd}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    37
  notify: restart papermc
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    38
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    39
- name: create world file directory
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
  become: yes
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    41
  file:
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    42
    path: "{{papermc_world_dir}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    43
    state: "directory"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    44
    owner: "{{papermc_user}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    45
    group: "{{papermc_user}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    46
    mode: "0755"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    47
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    48
- name: set world files
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    49
  become: yes
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    50
  lineinfile:
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    51
    path: "{{papermc_dir}}/bukkit.yml"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    52
    regexp: "^  world-container:"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    53
    line: "  world-container: {{papermc_world_dir}}"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    54
    insertbefore: "^  permissions-file:"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    55
  notify: restart papermc
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    56
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    57
- name: install systemd service
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    58
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    59
  template:
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    60
    src: "papermc.service.j2"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    61
    dest: "/lib/systemd/system/papermc.service"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    62
  notify: restart papermc
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    63
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    64
- name: ensure service is started
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    65
  become: yes
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    66
  systemd: name="papermc.service" enabled="yes" state="started"