This helped. Thank you so much. Much appreciated. 

On Monday, July 18, 2022 at 11:54:25 PM UTC-7 [email protected] wrote:

> On Mon, 18 Jul 2022 22:39:49 -0700 (PDT)
> Vinita Shah <[email protected]> wrote:
>
> > I have a dynamic inventory of hosts. *How do I get a list of failed 
> > instances?*
>
> For example,
>
> _failed: "{{ ansible_play_hosts_all|
> difference(ansible_play_hosts) }}"
>
> See
>
> https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html#special-variables
>
> Let's test it. Given the inventory
>
> shell> cat hosts
> host1 ok=true
> host2 ok=false
> host3 ok=false
>
> The playbook
>
> - hosts: all
> gather_facts: false
> vars:
> _failed: "{{ ansible_play_hosts_all|
> difference(ansible_play_hosts) }}"
> tasks:
> - assert:
> that: ok|bool
> - debug:
> var: _failed
>
> gives
>
> _failed:
> - host2
> - host3
>
>
> -- 
> Vladimir Botka
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/576a219e-ee69-4b56-bb09-8aa72287715an%40googlegroups.com.

Reply via email to