The with_items iterator doesnt stop on failures

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

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.

We might want to add a wayt to control this with failed_when.

Hi

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

Thanks

Kevin

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