Make Ansible throw an error inside the role

0 votes
I'm trying to provision ec2 instance. I'm trying to do it in such a way that if something goes wrong during execution then the entire set up should be demolished. But how do I do this?
Mar 13 in Ansible by Nisha
31 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey @Nisha, you can use the block/rescue feature of ansible here. You can wrap your roles inside them. something like this:

- block:
    - name: task 1

    ... # something bad may happen here

    - name: task N

  rescue: 
    - assert: # we need a dummy task here to prevent our host from being failed
        that: ansible_failed_task is defined
answered Mar 13 by Kim

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+13 votes
2 answers
0 votes
1 answer
0 votes
3 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.