I use ansible to manage a wide range of VMs, all with their own specifics, but each have some roles commonly defined under them.
Eg. multiple playbooks reference a role, that sets up admin users with access, same goes for ssh setup, timesync, timezone etc.
Now these roles are explicitly referenced in the same way in these playbooks, which is hard to maintain if a role happens to change.
I tried two methods:
- Include playbooks: While an included playbook can be ran for an inventory file, which would cover all the needed VMs, it still has a separate configuration set, and I would try to avoid possible misconfigurations with included playbooks
- Master role with included roles: I managed to make this method work by passing variables, however it is a bit hard to set up, not to mention because of this maintainability and tracability of variable flow defeats the purpose of ease of use.
If anyone more experienced, is there a suggested way to group commonly used roles together while still having the option to use the separately if needed?
run_roles.yml
. Can pass in a list of roles that will be run. – Jackextra_vars
. If you are using Ansible Tower, each job wraps a playbook. You just have different jobs all running therun_roles
playbook, and theextra_vars
tells it which role to run. You can then string those jobs together in a Workflow. – Jack