diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2023-05-31 16:59:04 +0200 |
---|---|---|
committer | Dave <dmz.oneill@gmail.com> | 2024-02-21 15:36:41 +0100 |
commit | 4286d411a74024b634cefa49b0c3cbdcd71a7231 (patch) | |
tree | 30dd4598431e9261a1fa28dfd6513c048918a511 | |
parent | Enhance the dashboard job summary endpoint to contain canceled and error job ... (diff) | |
download | awx-4286d411a74024b634cefa49b0c3cbdcd71a7231.tar.xz awx-4286d411a74024b634cefa49b0c3cbdcd71a7231.zip |
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
-rw-r--r-- | awx/playbooks/project_update.yml | 34 |
1 files 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 |