From 4286d411a74024b634cefa49b0c3cbdcd71a7231 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 31 May 2023 10:59:04 -0400 Subject: [PATCH] fix project_update role/collection install - avoid looping - avoid using multiple files, only one should be provided and processed per type - use first_found and variables to locate existing file - skip if no file exists --- awx/playbooks/project_update.yml | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/awx/playbooks/project_update.yml b/awx/playbooks/project_update.yml index f1b9710f19..cb21405202 100644 --- a/awx/playbooks/project_update.yml +++ b/awx/playbooks/project_update.yml @@ -216,13 +216,15 @@ - block: - name: Fetch galaxy roles from roles/requirements.(yml/yaml) ansible.builtin.command: - cmd: "ansible-galaxy role install -r {{ item }} {{ verbosity }}" + cmd: "ansible-galaxy role install -r {{ req_file }} {{ verbosity }}" 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" - when: roles_enabled | bool + when: roles_enabled | bool and req_file is file tags: - install_roles @@ -230,28 +232,36 @@ ansible.builtin.command: cmd: "ansible-galaxy collection install -r {{ item }} {{ verbosity }}" register: galaxy_collection_result - with_fileglob: - - "{{ project_path | quote }}/collections/requirements.yaml" - - "{{ project_path | quote }}/collections/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: "'Nothing to do.' not in galaxy_collection_result.stdout" when: - "ansible_version.full is version_compare('2.9', '>=')" - collections_enabled | bool + - req_file is file tags: - install_collections - name: Fetch galaxy roles and collections from requirements.(yml/yaml) ansible.builtin.command: - cmd: "ansible-galaxy install -r {{ item }} {{ verbosity }}" + cmd: "ansible-galaxy install -r {{ req_file }} {{ verbosity }}" register: galaxy_combined_result - with_fileglob: - - "{{ project_path | quote }}/requirements.yaml" - - "{{ project_path | quote }}/requirements.yml" + vars: + req_file: "{{ req_candidates | first_found }}" + req_candidates: + - "{{ project_path | quote }}/requirements.yaml" + - "{{ project_path | quote }}/requirements.yml" changed_when: "'Nothing to do.' not in galaxy_combined_result.stdout" when: - "ansible_version.full is version_compare('2.10', '>=')" - collections_enabled | bool - roles_enabled | bool + - req_file is file tags: - install_collections - install_roles