Change control flow of Minecraft deployment

This commit is contained in:
Salt 2020-06-24 09:33:43 -05:00
parent d5d6bfcf2e
commit c8b5d97c02

View File

@ -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