As you may remember, roles are a 1.2 feature that allow for easy modularity and reuse of playbook steps.
I encountered something today where I wanted to do some tasks before a role was invoked and then after a role was invoked.
I came up with this:
https://github.com/ansible/ansible/blob/devel/examples/playbooks/roletest.yml
The whole point of this is to be able to apply a role in a play for rolling updates.
Rolling updates of course worked before, but with the ability of free tasks surrounding the role to only come after the role steps, it wasn’t sufficient to use roles inside the rolling update idiom.
So basically, in set_up, you would have
-
signal outage window for host
-
take host out of load balancer
Then you would apply your roles and any loose tasks
and in tear_down, you would have
-
put host back in load balancer
-
end outage window for host
Naturally this is just a new thing that makes roles easier to use, and you don’t have to use it and it doesn’t affect your existing playbooks if you don’t.
Though I think this kind of being able to split out pre and post steps in a play could be useful for some people.
Let me know if this makes sense or not