Hi Together,
I have installed a working AWX and tried to import a new project with existing ansible git repo.
The git repo contains several playbooks and roles creates by myself.
The playbook and roles are working great with the plain ansible engine.
Now i try to migrate to AWX.
The repo is structured as follow:
.
β README.md
β ansible.cfg
β
ββββplaybooks
β ββββfolder1
β β ping-test.yml
β β mytest-x.yml
β β ...
β ββββfolder2
β β mytest-y.yml
β β mytest-z.yml
β β ...
β
ββββroles
β ββββfolder1
β ββββping-test
β - tasks/main.yml
β ββββmytest-x
β - tasks, vars, defaults, handlers, meta, tests
β ββββfolder2
β ββββmytest-y
β - tasks, vars, defaults, handlers, meta, tests
β ββββmytest-z
β - tasks, vars, defaults, handlers, meta, tests
I had expected that AWX will recursive found the "roles" in mygit repo.
With plain ansible I configured ansible role path variable to include roles/folder1 and roles/folder2.
I believe AWX cannot set dynamically role paths for /tmp/awx_... folder.
Becuase these are permanently changing names with every template run.
ping-test.yml playbook:
---
- hosts: all
gather_facts: no
roles:
- ping-test
main.yml role:
---
- name: ping
ping:
When running a template with ping-test.yml playbook following error occurs.
ERROR! the role 'ping-test' was not found in
/tmp/awx_...../project/playbook/folder1/roles:
/tmp/axw_...../project/playbook/folder1:
/tmp/axw_...../requirements_roles:
Questions:
Thanks for your help!
You list an ansible.cfg in your project, what did you put in that? I would think you should _want_ to put in
roles_path=roles/folder1:roles/folder2
I get that this doesn't work for every situation.
The very important implied knowledge that AWX relies on here is that the working directory will be the root of the project. That plays out in a very particular way with how Ansible config file preference goes:
https://docs.ansible.com/ansible/latest/reference_appendices/general_precedence.html#configuration-settings
Because the playbook directory is not in those 4 potential config paths, right now we don't have any way to support different settings for different playbooks within a single project. The top-level ansible.cfg will take effect. For your situation, however, the config values can take _relative_ paths. That should be the most portable way to configure roles nested in subdirectories like that.
Yes, thats the solution, relatives path in ansible.cfg!
roles_path=roles/folder1:roles/folder2
AWX will get it inside the /tmp/awx_.... running folder :)
I didn't thought of it, because I was migrating an existing repo with absolute paths to /etc/ansible/roles/folder1 and 2.
Answering my own questions:
@AlanCoding Thanks a lot for your help!