Breaking a loop

232 views
Skip to first unread message

Dario

unread,
Jun 5, 2014, 12:04:58 PM6/5/14
to ansible...@googlegroups.com
Hello,

I have a loop that loops over a result from program execution. On every iteration a shell command is executed. However, it may happen that one of these shell commands fails. Is possible to prevent continuing the loop if this happens? From what I can see, other iterations are executed even though one of them failed.

Thanks.

James Cammarata

unread,
Jun 5, 2014, 12:20:11 PM6/5/14
to ansible...@googlegroups.com
That's odd, the task should fail unless you're specifying other failed_when conditions or retries. Could you share an example of the task you're executing?


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bb6290e3-7d90-4fea-8a81-2852c7d1aef8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Serge van Ginderachter

unread,
Jun 5, 2014, 2:37:07 PM6/5/14
to ansible...@googlegroups.com

On 5 June 2014 18:20, James Cammarata <jcamm...@ansible.com> wrote:
That's odd, the task should fail unless you're specifying other failed_when conditions or retries.

​No, the task as a whole will fail ​if one of the iterations fails, but even if one iteration fails, the other iterations in that same task still get executed.

I don't think failed_when will impact on iterations, only the task as a whole.

  Serge

Michael DeHaan

unread,
Jun 6, 2014, 8:41:04 AM6/6/14
to ansible...@googlegroups.com
Serge is correct in the above.

The registration of a loop variable results in a list being stored.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages