# Clear host errors not working as supposed - cannot retry task on unreachable host

**URL:** <https://forum.ansible.com/t/clear-host-errors-not-working-as-supposed-cannot-retry-task-on-unreachable-host/24916>\
**Category:** Ansible Project\
**Created:** [July 6, 2017, 7:54pm UTC](https://forum.ansible.com/t/clear-host-errors-not-working-as-supposed-cannot-retry-task-on-unreachable-host/24916 "2017-07-06T19:54:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Listing](https://avatars.discourse-cdn.com/v4/letter/l/3d9bf3/32.png) [@Listing](https://forum.ansible.com/u/Listing)\
**Post date:** [July 6, 2017, 7:54pm UTC](https://forum.ansible.com/t/clear-host-errors-not-working-as-supposed-cannot-retry-task-on-unreachable-host/24916/1 "2017-07-06T19:54:49Z")

</div>

HI al,

I am running a playbook on a set of hosts of which I expect them to be offline. I want to check every 10 seconds whether they are online or not and then output a message when all is running, or another message when all is not running after 10 retries for instance.

I am getting ‘host unreachable’ after which the unreachable host is being removed. I can continue to run other tasks on the hosts that were online (by using ‘meta: clear\_host\_errors’), but I can’t retry the task on the host that was not online.

Does anybody know how to keep trying (for instance 10 times) a task until all hosts have been successful? Is this possible?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 6, 2017, 8:18pm UTC](https://forum.ansible.com/t/clear-host-errors-not-working-as-supposed-cannot-retry-task-on-unreachable-host/24916/2 "2017-07-06T20:18:32Z")

</div>

Have you check out wait\_for?  
[https://docs.ansible.com/ansible/wait\_for\_module.html](https://docs.ansible.com/ansible/wait_for_module.html)

and with "any\_errors\_fatal: true" you can at least stop the play if one or more host doesn't come online.

---

<div class="post-metadata">

**Author:** ![Listing](https://avatars.discourse-cdn.com/v4/letter/l/3d9bf3/32.png) [@Listing](https://forum.ansible.com/u/Listing)\
**Post date:** [July 6, 2017, 8:47pm UTC](https://forum.ansible.com/t/clear-host-errors-not-working-as-supposed-cannot-retry-task-on-unreachable-host/24916/3 "2017-07-06T20:47:20Z")

</div>

That works partially, the host is not being cleared but it keeps hanging on that unreachable host.

I managed to do a ping -c 3 to all the hosts in combination with retries=10. I only need to exclude certain host groups when I include all hostnames via: with\_items: groups[‘all’]

with\_items: groups[‘all:!excluded\_group’] does not seem to work. Have you got any idea how to exclude here? 🙂

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 6, 2017, 8:57pm UTC](https://forum.ansible.com/t/clear-host-errors-not-working-as-supposed-cannot-retry-task-on-unreachable-host/24916/4 "2017-07-06T20:57:55Z")

</div>

with\_items: "{{ groups['all'] | difference(groups['excluded\_group']) }}"

---

<div class="post-metadata">

**Author:** ![Listing](https://avatars.discourse-cdn.com/v4/letter/l/3d9bf3/32.png) [@Listing](https://forum.ansible.com/u/Listing)\
**Post date:** [July 6, 2017, 9:06pm UTC](https://forum.ansible.com/t/clear-host-errors-not-working-as-supposed-cannot-retry-task-on-unreachable-host/24916/5 "2017-07-06T21:06:45Z")

</div>

Great, everything is working as I want it to be, thank you for your help!
