# The with\_items iterator doesnt stop on failures

**URL:** <https://forum.ansible.com/t/the-with-items-iterator-doesnt-stop-on-failures/18009>\
**Category:** Ansible Developer\
**Created:** [April 17, 2015, 10:31pm UTC](https://forum.ansible.com/t/the-with-items-iterator-doesnt-stop-on-failures/18009 "2015-04-17T22:31:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spankthespam](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@spankthespam](https://forum.ansible.com/u/spankthespam)\
**Post date:** [April 17, 2015, 10:31pm UTC](https://forum.ansible.com/t/the-with-items-iterator-doesnt-stop-on-failures/18009/1 "2015-04-17T22:31:45Z")

</div>

Hi,

I’ve found a situation where task iteration over items using ‘with\_items’ will iterate over entire list, despite the fact that one or more iterations can fail, what causes issues when the iterations are dependant on all earliers iterations before them to succeed. I did some digging and it seems like the code (if I found the correct one) would want to break the loop if there’s a failure, but it doesnt - [https://github.com/ansible/ansible/blob/devel/lib/ansible/runner/\_\_init\_\_.py#L818](https://github.com/ansible/ansible/blob/devel/lib/ansible/runner/ __init__.py#L818)

Was it intended to break only the inner for loop over results objects instead of the entire loop, or is it a bug?

If this is ‘works as intended’ case, what’s the best way to implement such iterations if not using with\_items, when having quite large items list to be processed, that are depending one on another?

Regards,  
S.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 21, 2015, 4:35pm UTC](https://forum.ansible.com/t/the-with-items-iterator-doesnt-stop-on-failures/18009/2 "2015-04-21T16:35:10Z")

</div>

We might want to add a wayt to control this with failed\_when.

---

<div class="post-metadata">

**Author:** ![Kevin\_Yi](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kevin\_Yi](https://forum.ansible.com/u/Kevin_Yi)\
**Post date:** [November 16, 2015, 10:58pm UTC](https://forum.ansible.com/t/the-with-items-iterator-doesnt-stop-on-failures/18009/3 "2015-11-16T22:58:35Z")

</div>

Hi

Can I have some updates on this issue ? as I got same scenario to want to break loop on failure .

Thanks

Kevin

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 16, 2015, 11:07pm UTC](https://forum.ansible.com/t/the-with-items-iterator-doesnt-stop-on-failures/18009/4 "2015-11-16T23:07:58Z")

</div>

No work on it yet, I opened a ticket to keep track of this and other  
loop options  
[https://github.com/ansible/ansible/issues/12086](https://github.com/ansible/ansible/issues/12086)
