--- - hosts: "{{ host_list }}" remote_user: root tasks: - name: SHUTDOWN | in 5 min when: inventory_hostname not in groups.production community.general.shutdown: 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"