From c0523e61b85a204c1acc76cd07d8b1637b0e4b11 Mon Sep 17 00:00:00 2001 From: Kevin Velarde Date: Thu, 2 Jan 2025 15:34:21 -0700 Subject: [PATCH 1/4] Update IAG Ansible version Add support for installing Ansible collections on IAG servers --- roles/common_vars/defaults/main/main.yml | 3 + roles/gateway/defaults/main.yml | 3 + .../tasks/download-ansible-collections.yml | 23 +++++++ .../tasks/download-packages-python.yml | 8 +++ roles/gateway/tasks/download-packages.yml | 60 ++++++++++--------- .../tasks/download-python-dependencies.yml | 10 ++++ .../tasks/install-ansible-collections.yml | 29 +++++++++ roles/gateway/tasks/main.yml | 53 ++++++++++------ roles/gateway/tasks/upgrade-iag.yml | 33 +++++++++- roles/gateway/templates/ansible.cfg.j2 | 2 +- roles/gateway/vars/2023.1-redhat-8.yml | 3 + roles/gateway/vars/2023.1-redhat-9.yml | 3 + roles/gateway/vars/2023.1-rocky-8.yml | 3 + roles/gateway/vars/2023.1-rocky-9.yml | 3 + roles/gateway/vars/2023.2-redhat-8.yml | 2 +- roles/gateway/vars/2023.2-redhat-9.yml | 2 +- roles/gateway/vars/2023.2-rocky-8.yml | 2 +- roles/gateway/vars/2023.2-rocky-9.yml | 2 +- roles/gateway/vars/2023.3-redhat-8.yml | 2 +- roles/gateway/vars/2023.3-redhat-9.yml | 2 +- roles/gateway/vars/2023.3-rocky-8.yml | 2 +- roles/gateway/vars/2023.3-rocky-9.yml | 2 +- 22 files changed, 196 insertions(+), 56 deletions(-) create mode 100644 roles/gateway/tasks/download-ansible-collections.yml create mode 100644 roles/gateway/tasks/install-ansible-collections.yml diff --git a/roles/common_vars/defaults/main/main.yml b/roles/common_vars/defaults/main/main.yml index 3ef94998..072c0439 100644 --- a/roles/common_vars/defaults/main/main.yml +++ b/roles/common_vars/defaults/main/main.yml @@ -21,6 +21,7 @@ rpms_path: "{{ packages_path }}/rpms" wheels_path: "{{ packages_path }}/wheels" archives_path: "{{ packages_path }}/archives" adapters_path: "{{ packages_path }}/adapters" +ansible_collections_path: "{{ packages_path }}/ansible_collections" packages_download_root_control_node: "{{ playbook_dir }}/files" packages_download_dir_control_node: "{{ packages_download_root_control_node }}/{{ packages_path }}" @@ -28,6 +29,7 @@ rpms_download_dir_control_node: "{{ packages_download_dir_control_node }}/rpms" wheels_download_dir_control_node: "{{ packages_download_dir_control_node }}/wheels" archives_download_dir_control_node: "{{ packages_download_dir_control_node }}/archives" adapters_download_dir_control_node: "{{ packages_download_dir_control_node }}/adapters" +ansible_collections_download_dir_control_node: "{{ packages_download_dir_control_node }}/ansible_collections" packages_download_root_target_node: /var/tmp packages_download_dir_target_node: "{{ packages_download_root_target_node }}/{{ packages_path }}" @@ -35,3 +37,4 @@ rpms_download_dir_target_node: "{{ packages_download_dir_target_node }}/rpms" wheels_download_dir_target_node: "{{ packages_download_dir_target_node }}/wheels" archives_download_dir_target_node: "{{ packages_download_dir_target_node }}/archives" adapters_download_dir_target_node: "{{ packages_download_dir_target_node }}/adapters" +ansible_collections_download_dir_target_node: "{{ packages_download_dir_target_node }}/ansible_collections" diff --git a/roles/gateway/defaults/main.yml b/roles/gateway/defaults/main.yml index 554189ec..90680f94 100644 --- a/roles/gateway/defaults/main.yml +++ b/roles/gateway/defaults/main.yml @@ -20,6 +20,9 @@ iag_enable_git: true # Location of IAG assets iag_install_dir: /opt/automation-gateway +# Location of IAG Ansible collections +iag_ansible_collections_path: "{{ iag_install_dir }}/ansible/collections" + # Location of IAG data iag_data_dir: /var/lib/automation-gateway diff --git a/roles/gateway/tasks/download-ansible-collections.yml b/roles/gateway/tasks/download-ansible-collections.yml new file mode 100644 index 00000000..b7307d0f --- /dev/null +++ b/roles/gateway/tasks/download-ansible-collections.yml @@ -0,0 +1,23 @@ +# Copyright (c) 2024, Itential, Inc +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Create Ansible collections download directory + ansible.builtin.file: + path: "{{ ansible_collections_download_dir_target_node }}" + state: directory + mode: '0755' + +- name: Download Ansible collections + ansible.builtin.command: + chdir: "{{ ansible_collections_download_dir_target_node }}" + cmd: "{{ iag_pkgs_temp_dir.path }}/offline_install/bin/ansible-galaxy collection download {{ item }}" + with_items: "{{ iag_ansible_collections }}" + changed_when: true + +- name: Copy Ansible collections to control node + ansible.builtin.import_role: + name: offline + tasks_from: fetch-packages + vars: + src_dir: "{{ ansible_collections_download_dir_target_node }}/collections" + dest_dir: "{{ ansible_collections_download_dir_control_node }}" diff --git a/roles/gateway/tasks/download-packages-python.yml b/roles/gateway/tasks/download-packages-python.yml index e1a9d264..550e8b49 100644 --- a/roles/gateway/tasks/download-packages-python.yml +++ b/roles/gateway/tasks/download-packages-python.yml @@ -12,6 +12,14 @@ download_dir: "{{ rpms_download_dir_target_node }}" tags: download_gateway_python_packages +- name: Copy Gateway Python rpms to control node + ansible.builtin.import_role: + name: offline + tasks_from: fetch-packages + vars: + src_dir: "{{ rpms_download_dir_target_node }}" + dest_dir: "{{ rpms_download_dir_control_node }}" + - name: Install Python ansible.builtin.include_role: name: python diff --git a/roles/gateway/tasks/download-packages.yml b/roles/gateway/tasks/download-packages.yml index d13ecb72..2017c0d8 100644 --- a/roles/gateway/tasks/download-packages.yml +++ b/roles/gateway/tasks/download-packages.yml @@ -1,30 +1,32 @@ # Copyright (c) 2024, Itential, Inc # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) --- +- name: Validation steps + tags: always + block: + - name: Validate distribution major version + ansible.builtin.fail: + msg: Download not supported for version 7 + when: ansible_distribution_major_version == "7" -- name: Validate distribution major version - ansible.builtin.fail: - msg: Download not supported for version 7 - when: ansible_distribution_major_version == "7" + - name: Validate offline_install variable + ansible.builtin.fail: + msg: offline_install must be set to false for download + when: + - offline_install is defined + - offline_install -- name: Validate offline_install variable - ansible.builtin.fail: - msg: offline_install must be set to false for download - when: - - offline_install is defined - - offline_install + - name: Include release vars + ansible.builtin.include_vars: + file: "{{ item }}" + with_first_found: + - "{{ iag_release }}-{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml" + - "release-undefined.yml" -- name: Include release vars - ansible.builtin.include_vars: - file: "{{ item }}" - with_first_found: - - "{{ iag_release }}-{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml" - - "release-undefined.yml" - -- name: Check for valid IAG release - ansible.builtin.fail: - msg: "Deployer does not support installing Gateway version {{ iag_release }} on {{ ansible_distribution }}-{{ ansible_distribution_major_version }}" - when: invalid_iag_release is defined + - name: Check for valid IAG release + ansible.builtin.fail: + msg: "Deployer does not support installing Gateway version {{ iag_release }} on {{ ansible_distribution }}-{{ ansible_distribution_major_version }}" + when: invalid_iag_release is defined - name: Download Gateway OS rpms ansible.builtin.import_role: @@ -36,6 +38,14 @@ download_dir: "{{ rpms_download_dir_target_node }}" tags: download_gateway_packages +- name: Copy rpms to control node + ansible.builtin.import_role: + name: offline + tasks_from: fetch-packages + vars: + src_dir: "{{ rpms_download_dir_target_node }}" + dest_dir: "{{ rpms_download_dir_control_node }}" + - name: Install Gateway rpms ansible.builtin.dnf: name: "{{ item }}" @@ -62,14 +72,6 @@ src_dir: "{{ archives_download_dir_target_node }}" dest_dir: "{{ archives_download_dir_control_node }}" -- name: Copy rpms to control node - ansible.builtin.import_role: - name: offline - tasks_from: fetch-packages - vars: - src_dir: "{{ rpms_download_dir_target_node }}" - dest_dir: "{{ rpms_download_dir_control_node }}" - - name: Uninstall Gateway packages ansible.builtin.dnf: name: "{{ item }}" diff --git a/roles/gateway/tasks/download-python-dependencies.yml b/roles/gateway/tasks/download-python-dependencies.yml index bb392773..a80e2f5a 100644 --- a/roles/gateway/tasks/download-python-dependencies.yml +++ b/roles/gateway/tasks/download-python-dependencies.yml @@ -68,6 +68,16 @@ extra_args: --log /var/log/pip.log when: iag_enable_ansible | bool +- name: Download Ansible collections + tags: download_ansible_collections + block: + - name: Download Ansible collections + ansible.builtin.include_tasks: + file: download-ansible-collections.yml + when: + - iag_ansible_collections is defined + - iag_ansible_collections | length > 0 + - name: Copy IAG wheel file to target node ansible.builtin.copy: src: "{{ iag_whl_file }}" diff --git a/roles/gateway/tasks/install-ansible-collections.yml b/roles/gateway/tasks/install-ansible-collections.yml new file mode 100644 index 00000000..7db83843 --- /dev/null +++ b/roles/gateway/tasks/install-ansible-collections.yml @@ -0,0 +1,29 @@ +# Copyright (c) 2024, Itential, Inc +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Create temporary working directory + ansible.builtin.tempfile: + state: directory + register: install_collections_temp_dir + +- name: Copy collections to target node + ansible.builtin.copy: + src: "{{ item }}" + dest: "{{ install_collections_temp_dir.path }}/{{ item | basename }}" + mode: '0644' + with_fileglob: + - "{{ ansible_collections_download_dir_control_node }}/*.tar.gz" + - "{{ ansible_collections_download_dir_control_node }}/requirements.yml" + +- name: Install collections + ansible.builtin.command: + cmd: "ansible-galaxy collection install -p {{ iag_ansible_collections_path }} -r requirements.yml" + chdir: "{{ install_collections_temp_dir.path }}" + register: install_result + changed_when: '"Nothing to do" not in install_result.stdout' + failed_when: install_result.failed + +- name: Remove temporary working directory + ansible.builtin.file: + path: "{{ install_collections_temp_dir.path }}" + state: absent diff --git a/roles/gateway/tasks/main.yml b/roles/gateway/tasks/main.yml index d6179a15..857386be 100644 --- a/roles/gateway/tasks/main.yml +++ b/roles/gateway/tasks/main.yml @@ -1,18 +1,20 @@ # Copyright (c) 2024, Itential, Inc # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) --- -- name: Include release vars - ansible.builtin.include_vars: - file: "{{ item }}" - with_first_found: - - "{{ iag_release }}-{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml" - - "release-undefined.yml" +- name: Validation steps tags: always - -- name: Check for valid IAG release - ansible.builtin.fail: - msg: "Deployer does not support installing Gateway version {{ iag_release }} on {{ ansible_distribution }}-{{ ansible_distribution_major_version }}" - when: invalid_iag_release is defined + block: + - name: Include release vars + ansible.builtin.include_vars: + file: "{{ item }}" + with_first_found: + - "{{ iag_release }}-{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml" + - "release-undefined.yml" + + - name: Check for valid IAG release + ansible.builtin.fail: + msg: "Deployer does not support installing Gateway version {{ iag_release }} on {{ ansible_distribution }}-{{ ansible_distribution_major_version }}" + when: invalid_iag_release is defined - name: Install base OS packages ansible.builtin.include_role: @@ -64,11 +66,10 @@ - "{{ iag_properties_location }}" - "{{ iag_data_dir }}" - "{{ iag_install_dir }}" - - "{{ iag_install_dir }}/ansible/collections" + - "{{ iag_ansible_collections_path }}" - "{{ iag_install_dir }}/ansible/inventory" - "{{ iag_install_dir }}/ansible/modules" - "{{ iag_install_dir }}/ansible/roles" - - "{{ iag_install_dir }}/ansible/collections" - "{{ iag_install_dir }}/ansible/playbooks" - "{{ iag_install_dir }}/ansible/plugins/modules" - "{{ iag_install_dir }}/ansible/scripts" @@ -104,13 +105,31 @@ # Need to install ansible within the virtual environment - name: Install Ansible + tags: install_ansible when: iag_enable_ansible | bool block: - - name: Install Ansible into the python virtual environment - ansible.builtin.pip: - name: "{{ iag_ansible_version }}" - virtualenv: "{{ iag_install_dir }}/venv" + - name: Install Ansible and Ansible collections when: not offline_install + block: + - name: Install Ansible into the python virtual environment + ansible.builtin.pip: + name: "{{ iag_ansible_version }}" + virtualenv: "{{ iag_install_dir }}/venv" + + - name: Install collections + ansible.builtin.command: + cmd: "ansible-galaxy collection install -p {{ iag_ansible_collections_path }} {{ iag_ansible_collections | join(' ') }}" + register: install_result + changed_when: '"Nothing to do" not in install_result.stdout' + failed_when: install_result.failed + when: + - iag_ansible_collections is defined + - iag_ansible_collections | length > 0 + + - name: Install Ansible collections (offline) + ansible.builtin.include_tasks: + file: install-ansible-collections.yml + when: offline_install - name: Create Ansible config file ansible.builtin.template: diff --git a/roles/gateway/tasks/upgrade-iag.yml b/roles/gateway/tasks/upgrade-iag.yml index bfa41eda..431c45f9 100644 --- a/roles/gateway/tasks/upgrade-iag.yml +++ b/roles/gateway/tasks/upgrade-iag.yml @@ -6,11 +6,42 @@ state: directory register: workingdir -- name: Copy IAG to host +- name: Copy IAG archive from local ansible.builtin.copy: src: "{{ iag_whl_file }}" dest: "{{ workingdir.path }}/{{ iag_whl_file | basename }}" mode: '0644' + when: + - iag_whl_file is defined + - iag_archive_download_url is not defined + +- name: Download IAG archive from repository + when: + - iag_archive_download_url is defined + - iag_whl_file is not defined + block: + - name: Download IAG archive from repository + ansible.builtin.get_url: + url: "{{ iag_archive_download_url }}" + dest: "{{ workingdir.path }}/" + mode: '0644' + # Sets the appropriate header based on the repository type: + # - For JFrog: Uses the "X-JFrog-Art-Api" header with the API key if "repository_api_key" is defined and "jfrog" is part of the download URL. + # - For Nexus: Uses a default header ("Accept: application/octet-stream") since Nexus doesn't support API key authentication. + headers: >- + {%- if repository_api_key is defined and iag_archive_download_url is search("jfrog") -%} + {"X-JFrog-Art-Api": "{{ repository_api_key }}", "Accept": "application/octet-stream"} + {%- else -%} + {"Accept": "application/octet-stream"} + {%- endif -%} + url_username: "{{ repository_username | default(omit) }}" + url_password: "{{ repository_password | default(omit) }}" + validate_certs: true + register: download_result + + - name: Set iag_whl_file destination from download + ansible.builtin.set_fact: + iag_whl_file: "{{ download_result.dest }}" - name: Upgrade IAG ansible.builtin.pip: diff --git a/roles/gateway/templates/ansible.cfg.j2 b/roles/gateway/templates/ansible.cfg.j2 index b3f6c8d1..36f88e1a 100644 --- a/roles/gateway/templates/ansible.cfg.j2 +++ b/roles/gateway/templates/ansible.cfg.j2 @@ -1,2 +1,2 @@ [defaults] -collections_path={{ iag_install_dir }}/ansible/collections:/usr/share/ansible/collections \ No newline at end of file +collections_path={{ iag_ansible_collections_path }}:/usr/share/ansible/collections diff --git a/roles/gateway/vars/2023.1-redhat-8.yml b/roles/gateway/vars/2023.1-redhat-8.yml index b38c4e3e..d52149d3 100644 --- a/roles/gateway/vars/2023.1-redhat-8.yml +++ b/roles/gateway/vars/2023.1-redhat-8.yml @@ -25,3 +25,6 @@ base_python_dependencies: - wheel==0.42.0 iag_ansible_version: ansible==7.7.0 + +iag_ansible_collections: + - ansible.netcommon:5.1.0 diff --git a/roles/gateway/vars/2023.1-redhat-9.yml b/roles/gateway/vars/2023.1-redhat-9.yml index 24f77055..8de7c04d 100644 --- a/roles/gateway/vars/2023.1-redhat-9.yml +++ b/roles/gateway/vars/2023.1-redhat-9.yml @@ -23,3 +23,6 @@ app_python_dependencies: - ansible-pylibssh iag_ansible_version: ansible==7.7.0 + +iag_ansible_collections: + - ansible.netcommon:5.1.0 diff --git a/roles/gateway/vars/2023.1-rocky-8.yml b/roles/gateway/vars/2023.1-rocky-8.yml index b38c4e3e..d52149d3 100644 --- a/roles/gateway/vars/2023.1-rocky-8.yml +++ b/roles/gateway/vars/2023.1-rocky-8.yml @@ -25,3 +25,6 @@ base_python_dependencies: - wheel==0.42.0 iag_ansible_version: ansible==7.7.0 + +iag_ansible_collections: + - ansible.netcommon:5.1.0 diff --git a/roles/gateway/vars/2023.1-rocky-9.yml b/roles/gateway/vars/2023.1-rocky-9.yml index 24f77055..8de7c04d 100644 --- a/roles/gateway/vars/2023.1-rocky-9.yml +++ b/roles/gateway/vars/2023.1-rocky-9.yml @@ -23,3 +23,6 @@ app_python_dependencies: - ansible-pylibssh iag_ansible_version: ansible==7.7.0 + +iag_ansible_collections: + - ansible.netcommon:5.1.0 diff --git a/roles/gateway/vars/2023.2-redhat-8.yml b/roles/gateway/vars/2023.2-redhat-8.yml index 4012d893..17953f05 100644 --- a/roles/gateway/vars/2023.2-redhat-8.yml +++ b/roles/gateway/vars/2023.2-redhat-8.yml @@ -37,4 +37,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 diff --git a/roles/gateway/vars/2023.2-redhat-9.yml b/roles/gateway/vars/2023.2-redhat-9.yml index 6df5224a..562ff77a 100644 --- a/roles/gateway/vars/2023.2-redhat-9.yml +++ b/roles/gateway/vars/2023.2-redhat-9.yml @@ -32,4 +32,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 diff --git a/roles/gateway/vars/2023.2-rocky-8.yml b/roles/gateway/vars/2023.2-rocky-8.yml index 4012d893..17953f05 100644 --- a/roles/gateway/vars/2023.2-rocky-8.yml +++ b/roles/gateway/vars/2023.2-rocky-8.yml @@ -37,4 +37,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 diff --git a/roles/gateway/vars/2023.2-rocky-9.yml b/roles/gateway/vars/2023.2-rocky-9.yml index 6df5224a..562ff77a 100644 --- a/roles/gateway/vars/2023.2-rocky-9.yml +++ b/roles/gateway/vars/2023.2-rocky-9.yml @@ -32,4 +32,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 diff --git a/roles/gateway/vars/2023.3-redhat-8.yml b/roles/gateway/vars/2023.3-redhat-8.yml index 4012d893..17953f05 100644 --- a/roles/gateway/vars/2023.3-redhat-8.yml +++ b/roles/gateway/vars/2023.3-redhat-8.yml @@ -37,4 +37,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 diff --git a/roles/gateway/vars/2023.3-redhat-9.yml b/roles/gateway/vars/2023.3-redhat-9.yml index 6df5224a..562ff77a 100644 --- a/roles/gateway/vars/2023.3-redhat-9.yml +++ b/roles/gateway/vars/2023.3-redhat-9.yml @@ -32,4 +32,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 diff --git a/roles/gateway/vars/2023.3-rocky-8.yml b/roles/gateway/vars/2023.3-rocky-8.yml index 4012d893..17953f05 100644 --- a/roles/gateway/vars/2023.3-rocky-8.yml +++ b/roles/gateway/vars/2023.3-rocky-8.yml @@ -37,4 +37,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 diff --git a/roles/gateway/vars/2023.3-rocky-9.yml b/roles/gateway/vars/2023.3-rocky-9.yml index 6df5224a..562ff77a 100644 --- a/roles/gateway/vars/2023.3-rocky-9.yml +++ b/roles/gateway/vars/2023.3-rocky-9.yml @@ -32,4 +32,4 @@ app_python_dependencies: - nornir-utils==0.2.0 - pygnmi==0.8.9 -iag_ansible_version: ansible==7.7.0 +iag_ansible_version: ansible==8.7.0 From 9c0d0bac4ede190a9ff304f5ff024cab386a6275 Mon Sep 17 00:00:00 2001 From: Kevin Velarde Date: Thu, 2 Jan 2025 16:39:53 -0700 Subject: [PATCH 2/4] Fix bug when IAG Ansible collection list is empty --- roles/gateway/tasks/install-ansible-collections.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/gateway/tasks/install-ansible-collections.yml b/roles/gateway/tasks/install-ansible-collections.yml index 7db83843..797c3c3c 100644 --- a/roles/gateway/tasks/install-ansible-collections.yml +++ b/roles/gateway/tasks/install-ansible-collections.yml @@ -22,6 +22,9 @@ register: install_result changed_when: '"Nothing to do" not in install_result.stdout' failed_when: install_result.failed + when: + - iag_ansible_collections is defined + - iag_ansible_collections | length > 0 - name: Remove temporary working directory ansible.builtin.file: From fcea5aac847d53a87914f5ec9443f5e59e86a4e4 Mon Sep 17 00:00:00 2001 From: Kevin Velarde Date: Thu, 2 Jan 2025 21:22:58 -0700 Subject: [PATCH 3/4] Add size check when installing IAG packages --- roles/gateway/tasks/download-packages.yml | 4 ++++ roles/gateway/tasks/main.yml | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/roles/gateway/tasks/download-packages.yml b/roles/gateway/tasks/download-packages.yml index 2017c0d8..0c934a9f 100644 --- a/roles/gateway/tasks/download-packages.yml +++ b/roles/gateway/tasks/download-packages.yml @@ -52,6 +52,10 @@ state: present with_items: "{{ gateway_packages }}" register: gateway_packages_installed + when: + - gateway_packages is defined + - gateway_packages is iterable + - gateway_packages | length > 0 tags: install_gateway_packages - name: Download Python packages diff --git a/roles/gateway/tasks/main.yml b/roles/gateway/tasks/main.yml index 857386be..c9a08998 100644 --- a/roles/gateway/tasks/main.yml +++ b/roles/gateway/tasks/main.yml @@ -31,7 +31,11 @@ name: "{{ item }}" state: present with_items: "{{ gateway_packages }}" - when: not offline_install + when: + - not offline_install + - gateway_packages is defined + - gateway_packages is iterable + - gateway_packages | length > 0 tags: install_gateway_packages - name: Install Gateway packages (offline) From dfdb095cf1d54e9f4c679cd9288f1ebcba806c11 Mon Sep 17 00:00:00 2001 From: Kevin Velarde Date: Fri, 3 Jan 2025 14:48:09 -0700 Subject: [PATCH 4/4] Rename install-ansible-collections to install-ansible-collections-offline --- roles/gateway/tasks/download-python-dependencies.yml | 1 + ...collections.yml => install-ansible-collections-offline.yml} | 1 + roles/gateway/tasks/main.yml | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) rename roles/gateway/tasks/{install-ansible-collections.yml => install-ansible-collections-offline.yml} (96%) diff --git a/roles/gateway/tasks/download-python-dependencies.yml b/roles/gateway/tasks/download-python-dependencies.yml index a80e2f5a..212cf614 100644 --- a/roles/gateway/tasks/download-python-dependencies.yml +++ b/roles/gateway/tasks/download-python-dependencies.yml @@ -76,6 +76,7 @@ file: download-ansible-collections.yml when: - iag_ansible_collections is defined + - iag_ansible_collections is iterable - iag_ansible_collections | length > 0 - name: Copy IAG wheel file to target node diff --git a/roles/gateway/tasks/install-ansible-collections.yml b/roles/gateway/tasks/install-ansible-collections-offline.yml similarity index 96% rename from roles/gateway/tasks/install-ansible-collections.yml rename to roles/gateway/tasks/install-ansible-collections-offline.yml index 797c3c3c..2ec9f324 100644 --- a/roles/gateway/tasks/install-ansible-collections.yml +++ b/roles/gateway/tasks/install-ansible-collections-offline.yml @@ -24,6 +24,7 @@ failed_when: install_result.failed when: - iag_ansible_collections is defined + - iag_ansible_collections is iterable - iag_ansible_collections | length > 0 - name: Remove temporary working directory diff --git a/roles/gateway/tasks/main.yml b/roles/gateway/tasks/main.yml index c9a08998..f4e7da36 100644 --- a/roles/gateway/tasks/main.yml +++ b/roles/gateway/tasks/main.yml @@ -128,11 +128,12 @@ failed_when: install_result.failed when: - iag_ansible_collections is defined + - iag_ansible_collections is iterable - iag_ansible_collections | length > 0 - name: Install Ansible collections (offline) ansible.builtin.include_tasks: - file: install-ansible-collections.yml + file: install-ansible-collections-offline.yml when: offline_install - name: Create Ansible config file