I have a playbook running well, but I want to be able to restore files if it fails.
So I want to add a block/rescue, I am allowed to tag the rescue so the restore of files will only run if I run my playbook with the --tags=“restore” ?
Or do I Have to tag all the tasks in the rescue block ?
here is an example:
block:
tasks: save the config file
shell: chdir=/{{ Directoryname }} mv config {{ dirsav }}/
thank you but my question is about the rescue reserved word ?
Is it possible to run the rescue block with a tag instead of tagging all tasks in the rescue block ?
Thank you, finally i cannot figure out how to work on my playbook.
I have a main.yml with some includes, some are tags to skip them with the --skip-tags option.
main.yml:
include: existence.yml
…
include: installation.yml
tags:
installation
…
include: demarrage_karaf.yml
so if I use --skip-tags “installation”, this will only restart the karaf instance.
If I don’t use any tags, the installation will be done and karaf will be restarted
What I want is to add a restore option (tags) so if installation or any tasks failed, I can restore the old installation and restart karaf.
I thought adding the main in a block rescue this way would work:
block:
include: existence.yml
…
include: installation.yml
tags:
installation
…
include: demarrage_karaf.yml
rescue:
include: failure.yml
tags:
restore
but if I run the playbook with only the --tags “restore” , it won’t run any tasks not tagged or the include tagged with the “installation” tags.
Shall I tag all tasks with “always” tag ?
Is there another way to proceed than using a restore tag ?