Thank you for your suggestion.
I'm afraid though it does not help. Blocking this way in large role makes it quick complex and adds a lot of code, making it harder to read and maintain.
fails same as end_host will prevent other roles in the stack from being executed which is really my main issue.
I do also have checks which is really source of this issue. Consider below
if condition A is true exit else continue checking Condition B (if true exit else continue ) -> etc. Now you have 8 or 10 of those. It's much cleaner to say end role if condition is met (or not depending on what you are trying to achieve) then having block for all of those conditions.
Simple example of this might be roleA supports only RHEL while roleB supports only Ubuntu - Let's say we are installing something that only is available on one of those (more realistic would be if we consider versions of distros but using distors to keep is simple).
plybook:
- name: Install A and B
hosts: linux_servers
roles:
- roleA # Installs software A that only supports RHEL
- roleB # Installs software B that only supports Ubuntu
both of the roles have a condition at the top of the main file that checks if this is indeed supported OS and exists if it is not.
In that case if we execute role A on system that is not RHEL we will never get to execute roleB on the same server. This means Ubuntu servers will never be managed.
Again I know this can be done with include_taks for specyfic distro without need to end role but this is very simple example, to illustrate that it often makes more sense to end role if condition is/is not met then trying to work around it.
Even in this simple example if we would have inlcude_taks for specyfic distro and we suddently run on distro we have not included in our logic then role fails. This again results in skipping all other roles in the stack (end if RHEL - where we don't really care what distro it is unless it's RHEL VS include tasks for RHEL or Ubuntu where we need to have one for each distro we might need to run the role on - and there are many :) )
Hopefully this makes sense :)
Lukasz