minecraft/tasks/main.yaml
changeset 19 31de177274a1
child 20 9cacee5eec83
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/minecraft/tasks/main.yaml	Tue May 12 21:24:25 2020 -0500
@@ -0,0 +1,42 @@
+---
+
+- 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
+  become: yes
+  copy:
+    src: "eula.txt"
+    dest: "{{minecraft_dir}}/eula.txt"
+
+- name: configure minecraft
+  become: yes
+  template:
+    src: "server.properties.j2"
+    dest: "{{minecraft_dir}}/server.properties"
+    owner: "{{minecraft_user}}"
+    group: "{{minecraft_user}}"
+  notify: restart minecraft
+
+- name: install systemd service
+  become: yes
+  template:
+    src: "minecraft.service.j2"
+    dest: "/lib/systemd/system/minecraft.service"
+
+- name: ensure service is started
+  become: yes
+  systemd: name="minecraft.service" enabled="yes" state="started"