We have 3 repository, let say repo Y,Z and W.
There are roles under repository W that repository Y and Z want to use.
From reading, it seem we need to set requirements.yml as below,
- src: git@github.com:SOMEREPOSITORY/test-role.git
version: main
name: test_role
However, we still not success to use the share roles,
ERROR! the role 'test_role' was not found in /home/coder/provision/Build/roles:/home/coder/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/coder/provision/Build
is there need to be configure in ansible.cfg file that we missed?
I found the solution after multiple days.
Not Using Ansible Tower.
The solution is when we not using Ansible Tower, then we can install the role from another repository using below steps,
Create the requirements.yml file under your ./roles folder The content of requirements.yml example:
---
- src: git@github.com:SOMEREPOSITORY/testing-repository.git
name: test_role
scm: git
Then, run below command to install the role from another repository, ensure you in the directory same level with roles directory before execute below command:
ansible-galaxy install --role-file roles/requirements.yml --roles-path roles/
Using Ansible Tower.
Let say the Git repository name is Test_Repository, then ./roles directory should be inside the 'Test_Repository' folder. Since the playbook structure is essential for Ansible Tower to find the requirements.yml.
Hope this helps others.