# failed\_when to fail after retries have been used

**URL:** <https://forum.ansible.com/t/failed-when-to-fail-after-retries-have-been-used/20047>\
**Category:** Ansible Project\
**Created:** [December 18, 2015, 12:01pm UTC](https://forum.ansible.com/t/failed-when-to-fail-after-retries-have-been-used/20047 "2015-12-18T12:01:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jepper](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jepper](https://forum.ansible.com/u/jepper)\
**Post date:** [December 18, 2015, 12:01pm UTC](https://forum.ansible.com/t/failed-when-to-fail-after-retries-have-been-used/20047/1 "2015-12-18T12:01:23Z")

</div>

I am looking for a way for below to cause a failure, if the health check fails to see an “UP” message after 10 attempts.

- name: health check - wait for endpoints to become available  
action: shell curl [http://endpoint/health](http://endpoint/health)"  
register: curl\_output

until: curl\_output.stdout.find(“UP”) \> -1  
changed\_when: false  
retries: 10  
delay: 10

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [December 20, 2015, 9:11am UTC](https://forum.ansible.com/t/failed-when-to-fail-after-retries-have-been-used/20047/2 "2015-12-20T09:11:25Z")

</div>

Could you add a task straight after to use the assert module to check the contents of curl\_output?

Jon

---

<div class="post-metadata">

**Author:** ![jepper](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jepper](https://forum.ansible.com/u/jepper)\
**Post date:** [December 28, 2015, 10:17am UTC](https://forum.ansible.com/t/failed-when-to-fail-after-retries-have-been-used/20047/3 "2015-12-28T10:17:04Z")

</div>

I may try to check the value of “attempts”, and fail the task if we reach 10 attempts.
