minecraft/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 16 May 2020 12:50:02 -0500
changeset 28 d289eab1ea52
parent 27 8fddefdd948b
permissions -rw-r--r--
Made transmission idempotent.

---

- name: add minecract user
  become: yes
  user: name="{{minecraft_user}}" home="{{minecraft_dir}}"

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

- name: download minecraft
  become: yes
  get_url:
    url: "{{minecraft_url}}"
    dest: "{{minecraft_dir}}/server.jar"
    mode: "0755"
  notify: restart minecraft

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

# minecraft server writes a timtestamp to the config every time it starts so this always generates a change.
- name: configure minecraft
  become: yes
  template:
    src: "server.properties.j2"
    dest: "{{minecraft_dir}}/server.properties"
    owner: "{{minecraft_user}}"
    group: "{{minecraft_user}}"
  changed_when: false

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

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