I’ve been trying to loop on a fact for all hosts (‘distribution’) and encountered an error to the effect of ‘dict is undefined’ . It took a while to realize that ‘ansible_facts:’ exists but is unpopulated on unreachable hosts.
What would be the best way to loop through only reachable hosts that have successfully populated ansible_facts?
I've been trying to loop on a fact for all hosts ('distribution') and encountered an error to the effect of 'dict is
undefined' . It took a while to realize that 'ansible_facts:' exists but is unpopulated on unreachable hosts.
What would be the best way to loop through only reachable hosts that have successfully populated ansible_facts?
Thank you,
You could check whether the host is listed in the ansible_play_hosts variable which only contains "active"
hosts.