# Iterating through hosts until a successful response is received

**URL:** <https://forum.ansible.com/t/iterating-through-hosts-until-a-successful-response-is-received/18928>\
**Category:** Ansible Project\
**Created:** [August 3, 2015, 7:35pm UTC](https://forum.ansible.com/t/iterating-through-hosts-until-a-successful-response-is-received/18928 "2015-08-03T19:35:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pete\_Ahearn](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@Pete\_Ahearn](https://forum.ansible.com/u/Pete_Ahearn)\
**Post date:** [August 3, 2015, 7:35pm UTC](https://forum.ansible.com/t/iterating-through-hosts-until-a-successful-response-is-received/18928/1 "2015-08-03T19:35:15Z")

</div>

Hi everyone:

I’m new to Ansible and am hoping there’s an easy answer for this. I have a playbook which needs to iterate through a list of IP addresses POSTing a request to each via the uri module, but _only until_ the first successful response is received. Once a 200 is returned I don’t want it to continue. I’ve done the following but it hits all three endpoints even if the second one returns 200:
