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, 2019 in Ansible by Nisha
1,002 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, 2019 by Kim

Related Questions In Ansible

0 votes
1 answer

SSH encountered an unknown error during the connection - Ansible Error

I think you have not configured your ...READ MORE

answered Feb 9, 2019 in Ansible by Monish
2,336 views
0 votes
1 answer
0 votes
1 answer
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,035 views
+2 votes
1 answer
+1 vote
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP