diff --git a/awx/playbooks/project_update.yml b/awx/playbooks/project_update.yml index 125b5ef312b5..c6b57c3e4457 100644 --- a/awx/playbooks/project_update.yml +++ b/awx/playbooks/project_update.yml @@ -214,38 +214,43 @@ - name: Fetch galaxy roles from requirements.(yml/yaml) ansible.builtin.command: > - ansible-galaxy role install -r {{ item }} + ansible-galaxy role install -r {{ req_file }} --roles-path {{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_roles {{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }} args: chdir: "{{ project_path | quote }}" register: galaxy_result - with_fileglob: - - "{{ project_path | quote }}/roles/requirements.yaml" - - "{{ project_path | quote }}/roles/requirements.yml" + vars: + req_file: "{{ req_candidates |first_found }}" + req_candidates: + - "{{ project_path | quote }}/roles/requirements.yml" + - "{{ project_path | quote }}/roles/requirements.yaml" changed_when: "'was installed successfully' in galaxy_result.stdout" environment: "{{ galaxy_task_env }}" - when: roles_enabled | bool + when: roles_enabled | bool and req_file is file tags: - install_roles - name: Fetch galaxy collections from collections/requirements.(yml/yaml) ansible.builtin.command: > - ansible-galaxy collection install -r {{ item }} + ansible-galaxy collection install -r {{ req_file }} --collections-path {{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_collections {{ ' -' + 'v' * ansible_verbosity if ansible_verbosity else '' }} args: chdir: "{{ project_path | quote }}" register: galaxy_collection_result - with_fileglob: - - "{{ project_path | quote }}/collections/requirements.yaml" - - "{{ project_path | quote }}/collections/requirements.yml" - - "{{ project_path | quote }}/requirements.yaml" - - "{{ project_path | quote }}/requirements.yml" + vars: + req_file: "{{ req_candidates|first_found }}" + req_candidates: + - "{{ project_path | quote }}/collections/requirements.yml" + - "{{ project_path | quote }}/collections/requirements.yaml" + - "{{ project_path | quote }}/requirements.yml" + - "{{ project_path | quote }}/requirements.yaml" changed_when: "'Installing ' in galaxy_collection_result.stdout" environment: "{{ additional_collections_env | combine(galaxy_task_env) }}" when: - "ansible_version.full is version_compare('2.9', '>=')" - collections_enabled | bool + - req_file is file tags: - install_collections