Hello again!
I have an playbook where i update something, but id like to add an failsave if any hosts which doesnt have the sw installed will be excluded, so if there are somehpow in the inventroy some uninvited hosts id like to avoid installing the sw to them too.
my test playbook just to test the excluding.
I have to buntu 22 hosts one with wazuh one not and both outputted thhe message which only should be executed from the host with awzuh:
---
- name: Manage Wazuh Services
hosts: all
become: yes
vars:
wazuh_packages:
- wazuh-indexer
- wazuh-manager
- wazuh-dashboard
tasks:
- name: Check if Wazuh packages are installed
package_facts:
- name: Ensure all Wazuh packages are installed
block:
- name: Check Wazuh Indexer installation
ansible.builtin.package:
name: "{{ item }}"
state: present
loop: "{{ wazuh_packages }}"
register: wazuh_install_check
failed_when: wazuh_install_check is not success
- name: Skip host if any Wazuh package is missing
meta: end_play
when: wazuh_install_check is failed
- name: Output success message for hosts with Wazuh installed
ansible.builtin.debug:
msg: "I have Wazuh installed"
I dont know if you can jkust say in the playbok the host gets kicked ouf rom the process, or do i have to set a var for not installed and add an exclude in all tasks?
Thank you!!