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
14.05k stars 3.42k forks source link

Support of unified requirements.yml file with roles/collections do not work #12364

Closed dacofr closed 1 year ago

dacofr commented 2 years ago

Please confirm the following

Bug Summary

Even what is mentioned in this issue : https://github.com/ansible/awx/issues/6270, support of unified requirements.yml at top level do not work.

In file https://github.com/ansible/awx/blob/devel/awx/playbooks/project_update.yml#L214 we are looking at the requirements.yml file at the root folder, but we install it with ansible-galaxy collection install (https://github.com/ansible/awx/blob/devel/awx/playbooks/project_update.yml#L204)

AWX version

20.1

Select the relevant components

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

Linux

Web browser

No response

Steps to reproduce

roles:

Expected results

Collections and roles are installed

Actual results

Only collections are installed

Additional information

No response

AlanCoding commented 2 years ago

It sounds like what you want is:

diff --git a/awx/playbooks/project_update.yml b/awx/playbooks/project_update.yml
index 6d90b8d586..9da65be5d2 100644
--- a/awx/playbooks/project_update.yml
+++ b/awx/playbooks/project_update.yml
@@ -193,6 +193,8 @@
       with_fileglob:
         - "{{project_path|quote}}/roles/requirements.yaml"
         - "{{project_path|quote}}/roles/requirements.yml"
+        - "{{project_path|quote}}/requirements.yaml"
+        - "{{project_path|quote}}/requirements.yml"
       changed_when: "'was installed successfully' in galaxy_result.stdout"
       environment: "{{ galaxy_task_env }}"
       when: roles_enabled|bool

We didn't used to support requirements at requirements.yml, this was added in a (somewhat) recent version. As that was done, it was clear that we were hesitant to install roles from this file, because it might wind up doing unwated installs.

The behavior could be trivially changed with that diff, but should we? I am unwilling to answer that myself. If @ffirg wants to give a green light for that, then it's easy to do. Otherwise I will close this as won't-fix.

dacofr commented 2 years ago

Hello Alan,

thanks for your feedback :) For my understanding of unified requirements.yml at top level is that :

   with_fileglob:
         - "{{project_path|quote}}/roles/requirements.yaml"
         - "{{project_path|quote}}/roles/requirements.yml"

use ansible-galaxy role install -r {{ item }}

   with_fileglob:
         - "{{project_path|quote}}/collections/requirements.yaml"
         - "{{project_path|quote}}/collections/requirements.yml"

use ansible-galaxy collection install -r{{ item }}

   with_fileglob:
         - "{{project_path|quote}}/requirements.yaml"
         - "{{project_path|quote}}/requirements.yml"

use ansible-galaxy install -r {{ item }}

After, maybe they are some constraints to use ansible-galaxy install with AWX that i do not see.

Thanks

ng-bsy commented 1 year ago

Hi there! Is there an ETA for the implementation to comply with the Ansible Documentation? These kind of incompliances of AWX with Ansible, make AWX quite difficult to use. Developing Ansible Playbooks, Roles and Collections following the Ansible Documentation to find out, they are not working in AWX...

Maybe there should be a list of incompliances documented somewhere? What about an issue label, which indicates incompliance issues?

john-westcott-iv commented 1 year ago

@dacofr I love the suggestion you made. We did a little research and found that the unified installer came out in ansible 2.10 so we could also use a when clause on your last task for the unified install only when ansible >= 2.10 is being used.