Skip to main content
1 of 2

define rollback or rescue in ansible folder structure

I would like to define rescue or rollback executions within my ansible structure. Iam using this recommended structure:

roles
  rolename
    files
    tasks
    templates
    handlers
    ...

I know, that I can set blocks and within them a rescue section. But this seems a little clumsy to me and I would like to define all the rollback/rescue options within its own folder like

roles
  rolename
    ...
    tasks
    rollback/rescue
    handlers
    ...

this would make much more sense to me. I am speaking here about rollback, because I would like to be able to rollback a setup that I have created once with this role. I understand that the concept of rescue is a little bit different because it aims to fire when there is an error approached in executing a role. But I was hoping, that I could use the concepts together while defining an anti-step to each step that I have defined in the role. And these anti-steps should have their own place and not included in the tasks files.