Folks have been asking how to reuse pieces of playbooks easily, and I have also been wanting to squash the need to use relative or absolute paths all over the place.
Done! Presenting roles! (in 1.2 devel)
Roles are mostly a way to save boilerplate – using a role automatically puts content in tasks, vars_files, and handlers for you.
I will admit first hand this structure looks a little bit like a puppet module, so I need to give credit where credit is due – I got this idea from that originally, because people wanted an analog of that, but have improved it to make paths not as fiddly. I hope this completely squashes the reuse of parts of playbooks now, and also enables git-submodule style workflows for those that want them.
There are some cool new things too, namely, variables are also loaded (via the vars_files internals), in addition to just tasks, so you can put less in group_vars now if you like.
You can also parameterize roles, so if you had, for example, a role for all the users you wanted to install, you could just include that list of users, and boom, it would work.
See details here and let me know what you think!
https://github.com/ansible/ansible/blob/devel/examples/playbooks/roletest.yml
I want to make it support lists of roles in the roles list, so I could do things like
define my roles in vars_files (or group_vars) for the users I want to include,
and then slurp them all in and make them exist.
Unlike included playbooks in playbooks, roles also minimize fact gathering, so I suspect the only use case for included playbooks now is when you want a site.yml that includes playbooks for all of your different group operations, and things like that.
Hope this is not too confusing and we will introduce this a lot more casually in the docs (probably on the best practices page).
Comments welcome!