Hi,

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

  vars:

  pre_tasks:

    - include_vars: 'vars.yml' 

    - include_vars: 'vault1.yml' 

  tasks: 

- name Role1

  -  include_role:
      name: role1

- name: Role2

 block:
  - include_role:

     name: role2

 vars:

    vm: create
 # - fail: 

  #  msg: "Error: Role1 failed.” 

rescue: 
 - 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 
https://groups.google.com/d/msgid/ansible-project/0f22f1ed-ec4c-4c4c-8693-c258e0358dad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to