Awx: Ansible Roles not found

Created on 1 Sep 2020  Β·  2Comments  Β·  Source: ansible/awx

ISSUE TYPE
  • Bug Report
SUMMARY

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
ENVIRONMENT
  • AWX version: 14.0.0
  • AWX install method: docker (compose)
  • Ansible version: 2.9.11
  • Operating System: CentOS 8
  • Web Browser: Chrome 84
STEPS TO REPRODUCE
  1. Import SCM Repo
  2. Create Template with playbook
  3. Run Template
EXPECTED RESULTS

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:
ACTUAL RESULTS

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:

ADDITIONAL INFORMATION

Questions:

  1. Is my repo folder structure possible at all?
  2. Can requirements file or adjusting "dynamically" ansible.cfg role path variable solve the problem for AWX?
  3. How do you guys solve the issue with many playbooks and roles in the same git repo?

Thanks for your help!

bug

All 2 comments

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:

  1. Yes
  2. Yes with relative paths
  3. Split up in separatly repos

@AlanCoding Thanks a lot for your help!

Was this page helpful?
0 / 5 - 0 ratings