I am trying to create a master playbook where I am including multiple roles 
in it. I am using block for each role in playbook along with rescue and 
fail section. Rescue section should perform rollback of the previous 
completed role and should fail playbook after rolling back and email failed 
details. I tried rescue section and it works but playbook does not fail and 
continue to next role. I tried fail inside rescue section that does not 
work as well. I can create fail task after completion of every block to 
fail the playbook but not sure how to register previous role's results. Can 
anyone help how to achieve this? Also, for email I was thinking to register 
the output of block in a var and send as email but register does not work 
with block. I appreciate your help. Thanks

- hosts: all

  gather_facts: false



    - include_vars: 'vars.yml' 

    - include_vars: 'vault1.yml' 


- name Role1

  -  include_role:
      name: role1

- name: Role2

  - include_role:

     name: role2


    vm: create
 # - fail: 

  #  msg: "Error: Role1 failed.” 

 - fail: 
 - name: Debug msg 
   debug: msg="Error:Role 1 failed..Rolling back role1."

 - include_role:

   name: remove_role1

You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to