From c8b5d97c027508a4707e7b9d5ddeafdac48ead9d Mon Sep 17 00:00:00 2001 From: Salt Date: Wed, 24 Jun 2020 09:33:43 -0500 Subject: [PATCH] Change control flow of Minecraft deployment --- roles/minecraft/tasks/main.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/roles/minecraft/tasks/main.yml b/roles/minecraft/tasks/main.yml index e24af50..98a8e33 100644 --- a/roles/minecraft/tasks/main.yml +++ b/roles/minecraft/tasks/main.yml @@ -42,22 +42,19 @@ file: path: "/var/minecraft/{{ mcname }}" state: directory - - name: Check for existing install - stat: - path: "/var/minecraft/{{ mcname }}/forge-{{ mcforge }}-universal.jar" - register: stat_mcroot_forgejar - name: Download zip get_url: dest: "/var/minecraft/{{ mcname }}/modpack.zip" url: "{{ mczip }}" register: get_mcpack - - name: Unpack archive + - name: Install modpack block: - name: Unpack zip unarchive: src: "/var/minecraft/{{ mcname }}/modpack.zip" remote_src: yes dest: "/var/minecraft/{{ mcname }}" + notify: "restart minecraft {{ mcname }}" - name: Check for MultiMC pack stat: path: "/var/minecraft/{{ mcname }}/.minecraft" @@ -69,6 +66,7 @@ - mv - "/var/minecraft/{{ mcname }}/.minecraft/*" - "." + notify: "restart minecraft {{ mcname }}" when: stat_mcroot_multimc.stat.exists - name: Remove MultiMC artifacts file: @@ -79,11 +77,19 @@ - "/var/minecraft/{{ mcname }}/instance.cfg" - "/var/minecraft/{{ mcname }}/mmc-pack.json" when: stat_mcroot_multimc.stat.exists + when: get_mcpack is changed + - name: Check for Forge + stat: + path: "/var/minecraft/{{ mcname }}/forge-{{ mcforge }}-universal.jar" + register: stat_mcroot_forgejar + - name: Install Forge + block: - name: Download Forge get_url: dest: "/var/minecraft/{{ mcname }}/installer.jar" # Accurate as of 2020-02-23 url: "https://files.minecraftforge.net/maven/net/minecraftforge/forge/{{ mcforge }}/forge-{{ mcforge }}-installer.jar" + register: get_forge - name: Install Forge # Note: This also installs a Minecraft server, thankfully command: @@ -100,7 +106,7 @@ path: "/var/minecraft/{{ mcname }}/server.jar" src: "/var/minecraft/{{ mcname }}/forge-{{ mcforge }}-universal.jar" state: link - when: not stat_mcroot_forgejar.stat.exists or get_mcpack is changed + when: not stat_mcroot_forgejar.stat.exists - name: Configure server block: - name: Template out server.properties