If unreachable - stop giving Failed out and move to next host

Hi,
Is it possible for the host that if it’s unreachable - stop giving Failed output and move to the next task. As of now, it just shows the output fails.

Out of interest - what is the reason they are unreachable?

if you want to stop that ... dont use ignore_unreachable=true, the
'default' behaviour is to remove the host from play and not try
executing subsequent tasks (that of course fail again).

They are either off or unreachable over VPN. This is from production.

Brian if I remove ignore_unreachable=true. The playbook halts to continue the playbook.

You could use the ec2.py dynamic inventory to at least target the instances that are powered on. It’s more elegant than ignoring errors etc

Hi Dick,
I just to make sure on your suggestion that I have over 100 hosts that brought up and down dynamically. My goal is that the tasks should stop reporting HUGE errors in the output and we save them to be reviewed by external companies. Is it possible ?

This is exactly what the dynamic inventory is meant for. Basically if queries the aws api to fetch a list of the instances that are up, and provides that as the inventory.

https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#inventory-script-example-aws-ec2

Hi Dick,
The script from the article reports a 404 error for Ec2 external inventory script. Do you have it handy ?

https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#inventory-script-example-aws-ec2