From 1c7eecee1246a1600cdf364845199c07ff51c4ff Mon Sep 17 00:00:00 2001 From: Roberto Alfieri Date: Wed, 24 Apr 2024 17:28:47 +0200 Subject: [PATCH] [edpm_download_cache] Download packages and containers images only when service will be deployed on the EDPM node. Signed-off-by: Roberto Alfieri --- roles/edpm_download_cache/defaults/main.yml | 2 ++ .../meta/argument_specs.yml | 6 ++++++ .../molecule/default/converge.yml | 11 +++++++++++ .../molecule/default/prepare.yml | 7 ------- .../tasks/container_images.yml | 13 +++++++++++++ roles/edpm_download_cache/tasks/packages.yml | 18 ++++++++++++++++-- 6 files changed, 48 insertions(+), 9 deletions(-) diff --git a/roles/edpm_download_cache/defaults/main.yml b/roles/edpm_download_cache/defaults/main.yml index 741220640..78cbd7422 100644 --- a/roles/edpm_download_cache/defaults/main.yml +++ b/roles/edpm_download_cache/defaults/main.yml @@ -24,3 +24,5 @@ edpm_download_role_install_requirements: true edpm_download_cache_packages: true edpm_download_cache_container_images: true + +edpm_download_cache_running_services: "{{ edpm_services_override | default(edpm_services) }}" diff --git a/roles/edpm_download_cache/meta/argument_specs.yml b/roles/edpm_download_cache/meta/argument_specs.yml index a505fe1d7..a535bb304 100644 --- a/roles/edpm_download_cache/meta/argument_specs.yml +++ b/roles/edpm_download_cache/meta/argument_specs.yml @@ -16,3 +16,9 @@ argument_specs: type: bool default: true description: Enable caching of container images + edpm_download_cache_running_services: + type: list + default: edpm_services + description: > + Used to select which list of services are running + on the machine. The list is provided by dataplane-operator. diff --git a/roles/edpm_download_cache/molecule/default/converge.yml b/roles/edpm_download_cache/molecule/default/converge.yml index 3f73e5a77..38c82806f 100644 --- a/roles/edpm_download_cache/molecule/default/converge.yml +++ b/roles/edpm_download_cache/molecule/default/converge.yml @@ -17,5 +17,16 @@ - name: Converge hosts: all + vars: + edpm_services: + - bootstrap + - configure-network + - validate-network + - install-os + - ceph-hci-pre + - configure-os + - ssh-known-hosts + - run-os + - reboot-os roles: - role: "edpm_download_cache" diff --git a/roles/edpm_download_cache/molecule/default/prepare.yml b/roles/edpm_download_cache/molecule/default/prepare.yml index e58ee34ab..7f5c673f5 100644 --- a/roles/edpm_download_cache/molecule/default/prepare.yml +++ b/roles/edpm_download_cache/molecule/default/prepare.yml @@ -18,13 +18,6 @@ hosts: all roles: - role: ../../../../molecule/common/test_deps - test_deps_extra_packages: - - podman test_deps_setup_edpm: true test_deps_setup_stream: true - test_deps_edpm_packages: - - openvswitch -- name: Prepare container - hosts: instance - roles: - role: osp.edpm.env_data diff --git a/roles/edpm_download_cache/tasks/container_images.yml b/roles/edpm_download_cache/tasks/container_images.yml index 2c98e9228..61dacd5bb 100644 --- a/roles/edpm_download_cache/tasks/container_images.yml +++ b/roles/edpm_download_cache/tasks/container_images.yml @@ -9,6 +9,7 @@ - download_cache - name: Download images for edpm_iscsid role + when: '"nova-storage" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_iscsid tasks_from: download_cache.yml @@ -17,6 +18,7 @@ - download_cache - name: Download images for edpm_ovn role + when: '"ovn" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_ovn tasks_from: download_cache.yml @@ -25,6 +27,7 @@ - download_cache - name: Download images for edpm_frr role + when: '"frr" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_frr tasks_from: download_cache.yml @@ -33,6 +36,7 @@ - download_cache - name: Download images for edpm_ovn_bgp_agent role + when: '"ovn-bgp-agent" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_ovn_bgp_agent tasks_from: download_cache.yml @@ -40,6 +44,7 @@ - edpm_ovn_bgp_agent - name: Download images for edpm_neutron_metadata role + when: '"neutron-metadata" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_neutron_metadata tasks_from: download_cache.yml @@ -48,6 +53,7 @@ - download_cache - name: Download images for edpm_neutron_ovn role + when: '"neutron-ovn" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_neutron_ovn tasks_from: download_cache.yml @@ -56,6 +62,7 @@ - download_cache - name: Download images for edpm_multipathd role + when: '"nova-storage" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_multipathd tasks_from: download_cache.yml @@ -64,6 +71,7 @@ - download_cache - name: Download images for edpm_nova role + when: '"nova" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_nova tasks_from: download_cache.yml @@ -72,6 +80,7 @@ - download_cache - name: Download images for edpm_neutron_sriov role + when: '"neutron-sriov" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_neutron_sriov tasks_from: download_cache.yml @@ -80,11 +89,15 @@ - download_cache - name: Download images for edpm_neutron_dhcp role + when: '"neutron-dhcp" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_neutron_dhcp tasks_from: download_cache.yml - name: Download images for edpm_logrotate_crond role + when: ("install-os" in edpm_download_cache_running_services) or + ("configure-os" in edpm_download_cache_running_services) or + ("run-os" in edpm_download_cache_running_services) ansible.builtin.include_role: name: osp.edpm.edpm_logrotate_crond tasks_from: download_cache_images.yml diff --git a/roles/edpm_download_cache/tasks/packages.yml b/roles/edpm_download_cache/tasks/packages.yml index 7b5ee5fd7..b54a7b458 100644 --- a/roles/edpm_download_cache/tasks/packages.yml +++ b/roles/edpm_download_cache/tasks/packages.yml @@ -1,14 +1,18 @@ --- - name: Download packages for edpm_bootstrap role + when: '"bootstrap" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_bootstrap tasks_from: download_cache.yml tags: - - edpm_kernel + - edpm_bootstrap - download_cache - name: Download packages for edpm_podman role + when: ("install-os" in edpm_download_cache_running_services) or + ("configure-os" in edpm_download_cache_running_services) or + ("run-os" in edpm_download_cache_running_services) ansible.builtin.include_role: name: osp.edpm.edpm_podman tasks_from: download_cache.yml @@ -17,6 +21,7 @@ - download_cache - name: Download packages for edpm_tuned role + when: '"bootstrap" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_tuned tasks_from: download_cache.yml @@ -25,6 +30,7 @@ - download_cache - name: Download packages for edpm_kernel role + when: '"bootstrap" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_kernel tasks_from: download_cache.yml @@ -33,6 +39,7 @@ - download_cache - name: Download packages for edpm_network_config role + when: '"configure-network" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_network_config tasks_from: download_cache.yml @@ -41,6 +48,9 @@ - download_cache - name: Download packages for edpm_logrotate_crond role + when: ("install-os" in edpm_download_cache_running_services) or + ("configure-os" in edpm_download_cache_running_services) or + ("run-os" in edpm_download_cache_running_services) ansible.builtin.include_role: name: osp.edpm.edpm_logrotate_crond tasks_from: download_cache_packages.yml @@ -49,6 +59,9 @@ - download_cache - name: Download packages for edpm_sshd role + when: ("install-os" in edpm_download_cache_running_services) or + ("configure-os" in edpm_download_cache_running_services) or + ("run-os" in edpm_download_cache_running_services) ansible.builtin.include_role: name: osp.edpm.edpm_sshd tasks_from: download_cache.yml @@ -56,7 +69,8 @@ - edpm_sshd - download_cache -- name: Download images for edpm_libvirt role +- name: Download packages for edpm_libvirt role + when: '"libvirt" in edpm_download_cache_running_services' ansible.builtin.include_role: name: osp.edpm.edpm_libvirt tasks_from: download_cache.yml