Forcing a stop on failure

34 views
Skip to first unread message

Guy Matz

unread,
Oct 19, 2015, 4:23:05 PM10/19/15
to ansible...@googlegroups.com
Hi!  I have a playbook that has three plays, each one deploying software to a set of servers . . .  if any of these plays fail I want the playbook to stop running.  Is that what any_errors_fatal is for?  It sounds like it's close, but I can't tell if in the case of multiple plays it will work as I need.

So the top-level playbook is something like this:

- hosts: set_a
  roles:
    - foo

- hosts: set_b
  roles:
    - bar

- hosts: set_c
  roles:
    - baz

At specific points within the roles foo and bar I would like to stop the run if there are failures, most importantly, I do not want set_c to get updated.  Any thoughts are greatly appreciated!

Thanks a lot!
Guy

Guy Matz

unread,
Oct 21, 2015, 2:44:11 PM10/21/15
to ansible...@googlegroups.com

Serge van Ginderachter

unread,
Oct 21, 2015, 2:58:51 PM10/21/15
to ansible...@googlegroups.com

On 21 October 2015 at 20:44, Guy Matz <guy...@gmail.com> wrote:
At specific points within the roles foo and bar I would like to stop the run if there are failures, most importantly, I do not want set_c to get updated.  Any thoughts are greatly appreciated!


​There's the fail module for that, to be combined with a when: conditional.

Guy Matz

unread,
Oct 22, 2015, 2:28:17 PM10/22/15
to ansible...@googlegroups.com
Thanks! What I'm not clear on, though, is where that fail would go?  or what the condition would be . . ?


- hosts: set_b
  roles:
    - bar

- tasks:
  fail: msg='i have failed you'
  when: any tasks for set_b hosts have failed

- hosts: set_c
  roles:
    - baz

--
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/CAEhzMJBGJ7JzpXLZuESnjiSF9LLk3hwzboaGAu5gYXOGVhcoNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages