Clear the entire provision setup if fails to execute even a single command

0 votes
I'm trying to create and provision aws/ec2 instance. But if it fails, I want to clear the entire setup. Is that possible?
Feb 7 in Ansible by Kiara
21 views

1 answer to this question.

0 votes

Of course this is possible @Kiara, you can wrap all the tasks in the block/rescue block. 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 Feb 7 by Pragya

Related Questions In Ansible

0 votes
1 answer

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 13, 2018 in Ansible by DareDev
• 6,810 points
175 views
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 6,890 points
777 views
0 votes
1 answer
0 votes
1 answer

Execute a command using ansible playbook

Hey @Reshma, You can use the URI ...READ MORE

answered Jan 17 in Ansible by Sameer
178 views
+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
152 views
0 votes
1 answer
0 votes
1 answer

Hey I'm trying to execute a playbook but I get the following error:

Hey, you have a syntax error as ...READ MORE

answered Mar 26 in Ansible by Kalgi
• 40,460 points
22 views
0 votes
3 answers