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: file:
path: "/var/minecraft/{{ mcname }}" path: "/var/minecraft/{{ mcname }}"
state: directory state: directory
- name: Check for existing install
stat:
path: "/var/minecraft/{{ mcname }}/forge-{{ mcforge }}-universal.jar"
register: stat_mcroot_forgejar
- name: Download zip - name: Download zip
get_url: get_url:
dest: "/var/minecraft/{{ mcname }}/modpack.zip" dest: "/var/minecraft/{{ mcname }}/modpack.zip"
url: "{{ mczip }}" url: "{{ mczip }}"
register: get_mcpack register: get_mcpack
- name: Unpack archive - name: Install modpack
block: block:
- name: Unpack zip - name: Unpack zip
unarchive: unarchive:
src: "/var/minecraft/{{ mcname }}/modpack.zip" src: "/var/minecraft/{{ mcname }}/modpack.zip"
remote_src: yes remote_src: yes
dest: "/var/minecraft/{{ mcname }}" dest: "/var/minecraft/{{ mcname }}"
notify: "restart minecraft {{ mcname }}"
- name: Check for MultiMC pack - name: Check for MultiMC pack
stat: stat:
path: "/var/minecraft/{{ mcname }}/.minecraft" path: "/var/minecraft/{{ mcname }}/.minecraft"
@ -69,6 +66,7 @@
- mv - mv
- "/var/minecraft/{{ mcname }}/.minecraft/*" - "/var/minecraft/{{ mcname }}/.minecraft/*"
- "." - "."
notify: "restart minecraft {{ mcname }}"
when: stat_mcroot_multimc.stat.exists when: stat_mcroot_multimc.stat.exists
- name: Remove MultiMC artifacts - name: Remove MultiMC artifacts
file: file:
@ -79,11 +77,19 @@
- "/var/minecraft/{{ mcname }}/instance.cfg" - "/var/minecraft/{{ mcname }}/instance.cfg"
- "/var/minecraft/{{ mcname }}/mmc-pack.json" - "/var/minecraft/{{ mcname }}/mmc-pack.json"
when: stat_mcroot_multimc.stat.exists 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 - name: Download Forge
get_url: get_url:
dest: "/var/minecraft/{{ mcname }}/installer.jar" dest: "/var/minecraft/{{ mcname }}/installer.jar"
# Accurate as of 2020-02-23 # Accurate as of 2020-02-23
url: "https://files.minecraftforge.net/maven/net/minecraftforge/forge/{{ mcforge }}/forge-{{ mcforge }}-installer.jar" url: "https://files.minecraftforge.net/maven/net/minecraftforge/forge/{{ mcforge }}/forge-{{ mcforge }}-installer.jar"
register: get_forge
- name: Install Forge - name: Install Forge
# Note: This also installs a Minecraft server, thankfully # Note: This also installs a Minecraft server, thankfully
command: command:
@ -100,7 +106,7 @@
path: "/var/minecraft/{{ mcname }}/server.jar" path: "/var/minecraft/{{ mcname }}/server.jar"
src: "/var/minecraft/{{ mcname }}/forge-{{ mcforge }}-universal.jar" src: "/var/minecraft/{{ mcname }}/forge-{{ mcforge }}-universal.jar"
state: link state: link
when: not stat_mcroot_forgejar.stat.exists or get_mcpack is changed when: not stat_mcroot_forgejar.stat.exists
- name: Configure server - name: Configure server
block: block:
- name: Template out server.properties - name: Template out server.properties