From fcb0b2baa4374681f6d9056dc618db1cb60246d8 Mon Sep 17 00:00:00 2001 From: Freezed <2160318-free_zed@users.noreply.gitlab.com> Date: Tue, 15 Mar 2022 10:03:17 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Forbid=20shutdown=20for=20produc?= =?UTF-8?q?tion=20host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- tasks/shutdown.yml | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b472758..35213f1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Suitable for server and workstation. | :--------------------------------------: | :--------------------------------------------------------------: | | [`become_user_cfg.yml`](tasks/become_user_cfg.yml) | Set `sudo` without password for `become_user` access | | [`host_info.yml`](tasks/host_info.yml) | Return message with distribution full name & version | -| [`shutdown.yml`](tasks/shutdown.yml) | Shutdown target in 10 min | +| [`shutdown.yml`](tasks/shutdown.yml) | Shutdown target in 5 min (not if host is in production group) | | [`system_cfg`](tasks/system_cfg/main.yml) | Configure `root` users , NTP & `{{ my_users }}` shell | | [`user_cfg`](tasks/user_cfg/main.yml) | Configure `{{ my_user }}` | | [`whoami.yml`](tasks/whoami.yml) | Return message with `ansible_user` & `become_user` (`sudo` method) | diff --git a/tasks/shutdown.yml b/tasks/shutdown.yml index 310be6c..f6de220 100644 --- a/tasks/shutdown.yml +++ b/tasks/shutdown.yml @@ -3,6 +3,12 @@ remote_user: root tasks: - - name: Shutdown the host in 10 min + - name: SHUTDOWN | in 5 min + when: inventory_hostname not in groups.production community.general.shutdown: - delay: 600 + delay: 300 + + - name: SHUTDOWN | not allowed + when: inventory_hostname in groups.production + ansible.builtin.debug: + msg: "«{{ ansible_hostname }}» belongs to production group: shutdown not allowed" -- GitLab