papermc/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Wed, 01 Jul 2020 14:51:38 -0500
changeset 107 9057b9f9ced8
parent 59 b339d3c51504
child 111 1c1a911b26aa
permissions -rw-r--r--
MC separate world files dont work. Had to move main dir.
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
107
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    31
- name: create server.properties
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    32
  become: yes
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    33
  file:
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    34
    path: "{{papermc_dir}}/server.properties"
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    35
    state: "touch"
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    36
    owner: "{{papermc_user}}"
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    37
    group: "{{papermc_user}}"
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    38
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    39
- name: configure server.properties
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    40
  become: yes
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    41
  lineinfile:
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    42
    path: "{{papermc_dir}}/server.properties"
107
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    43
    regexp: "^{{item.key}}="
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    44
    line: "{{item.key}}={{item.value}}"
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    45
  notify: restart papermc
107
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    46
  loop:
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    47
    - {key: "motd", value: "{{papermc_motd}}"}
9057b9f9ced8 MC separate world files dont work. Had to move main dir.
Luke Hoersten <luke@hoersten.org>
parents: 59
diff changeset
    48
    - {key: "level-seed", value: "{{papermc_seed}}"}
19
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    49
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    50
- name: install systemd service
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    51
  become: yes
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    52
  template:
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    53
    src: "papermc.service.j2"
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    54
    dest: "/lib/systemd/system/papermc.service"
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: ensure service is started
31de177274a1 Added minecraft server role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    58
  become: yes
33
ad75fc2d2853 Added papermc role.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    59
  systemd: name="papermc.service" enabled="yes" state="started"