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.