On a normal system, I would install all of my roles into a common place (e.g. /etc/ansible/roles/). Then, any playbook on the system can use any of them. I store each role in a separate git repo.
In AWX, projects seem to be completed self-contained units. It appears as though, if I wanted to reuse the same role in multiple projects, I would have to import that role (requirements.yml) into each of the projects, but that playbooks/roles in project1 are unable to re-use roles in project2.
Is there any way around this? Is there some directory where I can install roles that can be used by any playbook in any project?
The problem I have with this is that I have one git repo that stores all of my playbooks (that use these roles) that are organized in subdirectories. If I were to install this as a single project, then the requirements.yml would install all of the roles in a directory not accessible by the playbooks:
My tree in git:
.
├── playbooks/
│ ├── collection1/
│ │ └── playbook1.yml
│ └── collection2/
│ ├── playbook1.yml
│ └── playbook2.yml
└── roles/
└── requirements.yml
Tree after installing roles:
.
├── playbooks/
│ ├── collection1/
│ │ └── playbook1.yml
│ └── collection2/
│ ├── playbook1.yml
│ └── playbook2.yml
└── roles/
├── role1/
├── role2/
└── requirements.yml
The idea of creating a separate git repo for every collection saddens me, so I’d prefer to not have to do that.
I haven’t gotten AWX to successfully install the requirements, so I haven’t been able to verify that that tree structure won’t work, but it doesn’t work when running ansible-playbook in a typical setting.
So, can I use relative paths in the cfg file (e.g. roles_path=…/roles/ or roles_path=…/…/)? I don’t want my playbooks to have to remember the absolute path that might change based on how these are deployed.
Will this work with role dependencies? e.g. I have one role that is just libs (modules, plugins, etc) and then other roles that require these. Currently, I list the libs role in the dependencies so that they are loaded and I can use the libs in my role tasks. With normal cmdline ansible, this all works perfectly (my /etc/ansible/ansible.cfg file just sets the roles_path and I use ansible-galaxy to install all of the roles into the appropriate dir).
And yeah, I wanted to try as many things as I could before posting, so I waited until the end of the day to post everything that I couldn’t figure out.