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.

---

- name: add papermc user
  become: yes
  user: name="{{papermc_user}}" home="{{papermc_dir}}"

- name: install jre
  become: yes
  apt: name="default-jre-headless"

- name: download papermc
  become: yes
  get_url:
    url: "{{papermc_url}}"
    dest: "{{papermc_dir}}/server.jar"
    mode: "0755"
  notify: restart papermc

- name: configure eula and ops
  become: yes
  copy:
    src: "{{item}}"
    dest: "{{papermc_dir}}/{{item}}"
    owner: "{{papermc_user}}"
    group: "{{papermc_user}}"
  loop:
    - "eula.txt"
    - "ops.json"
  notify: restart papermc

- name: create server.properties
  become: yes
  file:
    path: "{{papermc_dir}}/server.properties"
    state: "touch"
    owner: "{{papermc_user}}"
    group: "{{papermc_user}}"

- name: configure server.properties
  become: yes
  lineinfile:
    path: "{{papermc_dir}}/server.properties"
    regexp: "^{{item.key}}="
    line: "{{item.key}}={{item.value}}"
  notify: restart papermc
  loop:
    - {key: "motd", value: "{{papermc_motd}}"}
    - {key: "level-seed", value: "{{papermc_seed}}"}

- name: install systemd service
  become: yes
  template:
    src: "papermc.service.j2"
    dest: "/lib/systemd/system/papermc.service"
  notify: restart papermc

- name: ensure service is started
  become: yes
  systemd: name="papermc.service" enabled="yes" state="started"