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
74 views

1 answer to this question.

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

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
209 views
0 votes
1 answer
0 votes
3 answers