On Sun, 26 Feb 2023 18:11:02 -0800 (PST) Kenady Inampudi <ken...@cis-in.com> wrote:
> {% for host in ansible_play_hosts_all %} > {% if 'Completed Successfully' not in hostvars[host]['mksys']['msg'] %} > > This condition generates nothing. Your code works as expected. For testing, put the variable into the inventory shell> cat hosts all: hosts: host1: mksys: msg: 'Completed Successfully' host2: mksys: msg: 'Completed Successfully' host3: mksys: msg: 'Completed Not Successfully' The playbook shell> cat pb.yml - hosts: all tasks: - debug: msg: | {% for host in ansible_play_hosts_all %} {% if 'Completed Successfully' not in hostvars[host]['mksys']['msg'] %} {{ host }} msg:{{hostvars[host]['mksys']['msg'] }} {% endif %} {% endfor %} run_once: true gives (abridged) msg: |- host3 msg:Completed Not Successfully -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20230227044225.1a0e72e9%40gmail.com.
pgpmAhiizcL2_.pgp
Description: OpenPGP digital signature