From 4dd6380c0b571b0602e7715280c9864c56d4e7eb Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 26 Jan 2020 15:18:17 -0600 Subject: [PATCH] disable/enable minecraft instances --- roles/minecraft/tasks/main.yaml | 4 ++-- roles/restic/files/hooks/minecraft.sh | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/minecraft/tasks/main.yaml b/roles/minecraft/tasks/main.yaml index b6663b1..873150c 100644 --- a/roles/minecraft/tasks/main.yaml +++ b/roles/minecraft/tasks/main.yaml @@ -86,8 +86,8 @@ - name: manage minecraft service service: name: "minecraft@{{ item.name }}" - state: "{{ minecraft_service_state }}" - enabled: "{{ minecraft_service_enabled }}" + state: "{{ item.state | default(minecraft_service_state) }}" + enabled: "{{ item.enabled | default(minecraft_service_enabled) }}" loop: "{{ minecraft_worlds }}" #- name: configure ops diff --git a/roles/restic/files/hooks/minecraft.sh b/roles/restic/files/hooks/minecraft.sh index a7ff407..5657708 100644 --- a/roles/restic/files/hooks/minecraft.sh +++ b/roles/restic/files/hooks/minecraft.sh @@ -47,6 +47,11 @@ start_server() { local unit="${1:-$SERVICE}" local attempts="${2:-$WAIT}" + if ! systemctl -q is-enabled "$unit"; then + printf "%s is not enabled, skipping.\n" "$unit" + return 0 + fi + if systemctl -q is-active "$unit"; then printf "%s is already started\n" "$unit" return 0