ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.55k stars 3.35k forks source link

Playbooks are not discovered in subdirectories within git project #15187

Closed YaronL16 closed 2 weeks ago

YaronL16 commented 2 weeks ago

Please confirm the following

Bug Summary

Suppose I have this repo:

+ Git Repository
    playbook1.yml
    + ansible_directory
        playbook2.yaml
        + playbooks_directory
            playbook3.yml

When creating a template, only playbook 1 and 2 will be available to choose. files more than one directories deep within the repo are not discovered, which is a shame for those using large repos.

AWX version

24.2

Select the relevant components

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

normal install using operator add a git based project with playbooks inside subdirectories

Expected results

I'd expect too be able to choose all playbooks in the repo

Actual results

I can only choose playbooks which are 0 or 1 subdirectories deep

Additional information

No response

kurokobo commented 2 weeks ago

Hi, is your playbook3.yml valid playbook? AWX does not list all existing YAML files but list YAML files that can be determined as playbooks. Also there is no limitation about the depth of the sub directories.

TheRealHaoLiu commented 2 weeks ago

https://github.com/ansible/awx/blob/devel/awx/main/utils/ansible.py/#L42-L66 this is how we determine if a yaml file "could be a playbook"

TheRealHaoLiu commented 2 weeks ago

and here's the regex used to https://github.com/ansible/awx/blob/devel/awx/main/utils/ansible.py#L20 to scan the lines to determine if it "could be a playbook"

YaronL16 commented 2 weeks ago

Hi, is your playbook3.yml valid playbook? AWX does not list all existing YAML files but list YAML files that can be determined as playbooks. Also there is no limitation about the depth of the sub directories.

@kurokobo all 3 playbooks are exactly the same. It couldn't be a problem with the file itself

YaronL16 commented 2 weeks ago

and here's the regex used to https://github.com/ansible/awx/blob/devel/awx/main/utils/ansible.py#L20 to scan the lines to determine if it "could be a playbook"

That shouldn't make much difference because the playbooks are identical yet only the first two are detected

kurokobo commented 2 weeks ago

Hmm okay, so please check:

YaronL16 commented 2 weeks ago

Okay after diving into the code I realize my problem

Apparently the project function skips any directory named roles which is exactly where my playbooks were placed, and ignores any files under it

Thats why my playbooks did not show up, after renaming roles to playbooks it works perfectly