Sorry to revive this old thread but I (and many others) got the same 
problem which seems not to be addressed yet. My original post was 
at 
https://stackoverflow.com/questions/45983636/how-to-always-run-some-ansible-roles-after-previous-failures

If you you wrote is still true (ansible 2.3.x), it means that ansible 
*roles* are not really as useful as they were marketed as because once you 
get a failure inside a role it is impossible to run some other code after.

This "design limitation" is forcing people to abuse the use of 
"ignore_errors" in order to still be able to do something after the 
failure, ending up with tons of roles full of ignore_errors which we all 
know how nice they look in the console logs, where they are NOT colored 
red, hiding the original error.

So how are we supposed to re-use roles when is impossible to use them? 
Starting to replace role: foo with something like include: 
"../roles/foo/tasks/main.yaml" ?

On Thursday, December 1, 2016 at 8:10:36 PM UTC, Brian Coca wrote:
>
> To clarify as the question indicates some misunderstanding, roles can only 
> fail on import, what is failing is a task (which happens to be in a role)​.
>
> Tasks in post_tasks, are just like any other task, the only difference is 
> ordering,  they get executed after all previous tasks/role sections.
>
> Any normal task won't execute for a host if that host is in a failed state.
>
> There is only one way to execute tasks after a failed state is via 
> locating them inside the 'rescue' section of a block which contains the 
> failing task. 
>
> A different approach is negating the fail state to begin with, using 
> failed_when or ignore_errors.
>
>
> ----------
> Brian Coca
>

-- 
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/1b5bf895-4b01-451d-85ba-3e4d76438001%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to