# Exit role without failure (stop processing role on condition) without ending play or stoping execution of other roles in a stack/ Ensure all roles in a stack get run even if one ends with failure

**URL:** <https://forum.ansible.com/t/exit-role-without-failure-stop-processing-role-on-condition-without-ending-play-or-stoping-execution-of-other-roles-in-a-stack-ensure-all-roles-in-a-stack-get-run-even-if-one-ends-with-failure/37512>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [December 30, 2022, 12:58pm UTC](https://forum.ansible.com/t/exit-role-without-failure-stop-processing-role-on-condition-without-ending-play-or-stoping-execution-of-other-roles-in-a-stack-ensure-all-roles-in-a-stack-get-run-even-if-one-ends-with-failure/37512 "2022-12-30T12:58:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sinnl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sinnl/32/1532_2.png) [@sinnl](https://forum.ansible.com/u/sinnl)\
**Post date:** [December 30, 2022, 12:58pm UTC](https://forum.ansible.com/t/exit-role-without-failure-stop-processing-role-on-condition-without-ending-play-or-stoping-execution-of-other-roles-in-a-stack-ensure-all-roles-in-a-stack-get-run-even-if-one-ends-with-failure/37512/1 "2022-12-30T12:58:34Z")

</div>

Hi,

Trying what I believe to be common use case where a playbook has set of roles to configure system.

this looks something like

- name: Do X, Y and Z  
hosts: all

roles:

- role: roleA  
var1: value1  
var2: value2
- role: roleB  
var1: value1  
var2: value2
- role: roleC  
var1: value1  
var2: value2

I found 2 issues with this set up.

1 - I have checks in each role to end\_host in case there is no need to run the playbook. I do understand that with correctly written (idempotent) playbook this is not necessary but I found it to be very useful as one, it does save a lot of execution time, especially when your play is big and inventory even bigger but also when you are creating timestamped audit logs that you want to be executed only if change happened. I also considered breaking up tasks in more files so that they can be included on condition but depending on the role it can get bit messy and hard to follow for other contributors.  
I’ve been using end\_host but it ends play and not a role. **Is there a way to end role and not play, and most of all not stop processing of other roles in the lis** t?

2 - If role fails due to unhandled error, fail hat role but **again not a play, and most of all do not stop processing of other roles in the lis** t?

I’ve looked into ignoring\_errors but again that work on play level and not role level. If role A fails ignore\_errors will allow next play to be executed but not roles B and C

So far the only solutions I can think of are:

- Have play for each role - not the end of the world, just a lot of unnecessary code
- in AWX, have a playbook/job template for each role and string them together using workflow - again a lot of unnecessary code and potentially job templates.
- try and rap all in blocks and use rescue that just includes task with nothing bur debug module
- have main task in the role to just do includes based on the conditions and within blocks. Gets messy very quick

Is there a way to deal with 2 issues mentioned above? **What is the standard approach to dealing with roles failing or exiting roles on condition when executed in a stack/list?**

Thanks!
