For different apps I want to use Ansible for setup/deployment, using my own roles, and I want to re-use those roles between apps. I could have everything in one directory tree (living in git for version control), but that means keeping deployment configuration for all apps in a single repo; I would rather like to have those configurations separated.
I couldn't find any authoritative info on how to do this, so here's my approach.
- Every role lives in its own git repo. An example is Vincent Rischmann's ansible-role-java.
- Every app (or project) has its own git repo for its Ansible configuration (inventory definition and playbooks etc.).
- The app repo has a roles sub directory. Actual roles (e.g. the java role) are then added as git submodules.
git submodule add https://github.com/vrischmann/ansible-role-java.git roles/java
and, voilá, Vincent's role is now available as a role 'java' in my project's Ansible configuration.
This comment has been removed by the author.
ReplyDeleteChris,
ReplyDeleteThis sounds like the right way to go. Did you get any useful comments?
The author of this article seems to agree with your approach at least: https://www.theodo.fr/blog/2015/10/best-practices-to-build-great-ansible-playbooks/
ReplyDeleteWell explained .Keep updating Devops Online Training
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteSeth DaemenDecember 19, 2018 at 4:45 AM
ReplyDeletesubmodules was my idea also but it seems not to work with awx/tower