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

**URL:** <https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883>\
**Category:** Ansible Project\
**Created:** [May 7, 2020, 10:17pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883 "2020-05-07T22:17:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [May 7, 2020, 10:17pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/1 "2020-05-07T22:17:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 7, 2020, 10:28pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/2 "2020-05-07T22:28:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 8, 2020, 2:46pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/3 "2020-05-08T14:46:43Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [May 8, 2020, 3:42pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/4 "2020-05-08T15:42:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [May 8, 2020, 3:45pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/5 "2020-05-08T15:45:36Z")

</div>

Brian if I remove ignore\_unreachable=true. The playbook halts to continue the playbook.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 8, 2020, 6:15pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/6 "2020-05-08T18:15:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [May 8, 2020, 9:09pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/7 "2020-05-08T21:09:39Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 9, 2020, 3:49am UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/8 "2020-05-09T03:49:31Z")

</div>

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](https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#inventory-script-example-aws-ec2)

---

<div class="post-metadata">

**Author:** ![Work\_Email](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@Work\_Email](https://forum.ansible.com/u/Work_Email)\
**Post date:** [May 11, 2020, 7:53pm UTC](https://forum.ansible.com/t/if-unreachable-stop-giving-failed-out-and-move-to-next-host/32883/9 "2020-05-11T19:53:41Z")

</div>

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](https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#inventory-script-example-aws-ec2)
