From 297f5373ca39e12c258ecadb9efd6020a79a39a0 Mon Sep 17 00:00:00 2001 From: Salt Date: Tue, 29 Dec 2020 08:23:06 -0600 Subject: [PATCH] Add boolean to disable a server --- README.md | 1 + defaults/main.yml | 1 + tasks/main.yml | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 58a87fd..d13753b 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Template out the role, ensuring it has root privileges. Set the following vars: ```yaml minecraft_name: Name of the subdirectory of the server minecraft_version: Version of Minecraft desired in semver (i.e. 1.7.10, 1.16.4, does not support Beta) +minecraft_enabled: Boolean to determine state of server (defaults to yes) ``` You must also set one of `minecraft_paper_install` *or* `minecraft_forge_install` depending on desired configuration. Vanilla servers are not supported; use Paper. diff --git a/defaults/main.yml b/defaults/main.yml index fdd4468..05c8439 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,7 @@ # vim:ft=ansible: minecraft_name: default minecraft_version: 1.16.3 +minecraft_enabled: yes # minecraft_forge_version: You tell me # Packages diff --git a/tasks/main.yml b/tasks/main.yml index 287f526..e48d3c1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -85,3 +85,7 @@ when: minecraft_forge_install and minecraft_forge_version is defined - name: enable service systemd: name=minecraft@{{ minecraft_name }}.service enabled=yes state=started + when: minecraft_enabled +- name: disable service + systemd: name=minecraft@{{ minecraft_name }}.service enabled=no state=stopped + when: not minecraft_enabled