Yes but if i want one procedure for install one application, exemple:
- block:
- name: task 1
......
.....
- name: task 2
......
......
i want that if one task fails, I want him to go back on all the tasks that
play it.
You can write rollback tasks in a `rescue` section, followed by a fail task, but there is no automatic rollback functionality unless you write it yourself.
The problem you have is that ansible does not retain the old state of the machine when it makes changes. The fact that you executed the command “touch test_file.txt” does not indicate whether test_file.txt did or did not exist prior to running the command. So to “roll back”, do you erase the file? Change the date-stamp back to what it was?
Probably the closest thing you will find is a “block” with a “rescue” section attached, to specify what you want to happen in the event of an error.
It is really very interesting this section rescue but if in my block I execute for example a script sql which does a lot of actions and that there is an error …
It is really very interesting this section rescue but if in my block I
execute for example a script sql which does a lot of actions and that there
is an error ...
This is beyond the scope of ansible. You should have the rescue block do what is necessary to recover from your SQL script, or use something like a SQL transaction, but, again, it's beyond the scope of ansible.