Reputation: 105
Follow these project structures:
ansible-project1
+--playbooks
playbook1.yml
+--roles
+--role1
+--role2
ansible-project2
+--playbooks
playbook2.yml
+--roles
+--role3
+--role4
Is it possible to have two different ansible projects, where a playbook of ansible-project2 use its own roles and roles from ansible-project1?
Is it possible to include a playbook from ansible-project1 in other playbook on ansible-project2 where first playbook is using roles from its roles folder? For example, following projects structures: playbook2.yml include playbook1.yml, where playbook1.yml use role1.
I don't know if it's important to mention but ansible-project1 and ansible-project2 are different git repos.
Upvotes: 1
Views: 1577
Reputation: 266
We can reuse custom ansible roles if they are in same repo but I'm not sure if reuse is possible if they are in different Git Repo. Ansible Galaxy roles can be reused.
Upvotes: 0
Reputation: 51
Ansible galaxy solves this problem and it’s included with Ansible. Generate a new role using it and, rather than sharing it publicly, store it in your version control system as a separate repo.
Shareable Ansible galaxy roles can then be added to a requirements file and downloaded, as is a standard with python.
Upvotes: 2