From 2669148a9cbfec9540b67581bdd58a9fd1a07707 Mon Sep 17 00:00:00 2001 From: rabi Date: Wed, 12 Aug 2026 18:23:23 +0530 Subject: [PATCH] [edpm_prepare] Discover cinder and manila backend keys Emit the OpenStackVersion CR via the cifmw.general.set_containers module instead of the update_containers role. Resolve cinder volume and manila share image map keys from the kustomized OpenStackControlPlane CR when callers do not provide them explicitly, via the new cifmw_edpm_prepare_cindervolumes / cifmw_edpm_prepare_manilashares overrides. This avoids emitting misleading default backend names and keeps the update_containers role defaults untouched for its remaining callers (edpm_baremetal_update), which keep working exactly as before. Signed-off-by: rabi --- roles/edpm_prepare/README.md | 2 + .../tasks/kustomize_and_deploy.yml | 137 +++++++++++++++--- 2 files changed, 120 insertions(+), 19 deletions(-) diff --git a/roles/edpm_prepare/README.md b/roles/edpm_prepare/README.md index d11229585..c84f193b7 100644 --- a/roles/edpm_prepare/README.md +++ b/roles/edpm_prepare/README.md @@ -21,3 +21,5 @@ This role doesn't need privilege escalation. openstack control plane deployment status. Useful when using the role to only update the control plane resource, scenario where it may be in a `ready` status. Defaults to `30`. * `cifmw_edpm_prepare_extra_kustomizations`: (List) Extra Kustomizations to apply on top of the controlplane CRs. Defaults to `[]`. * `cifmw_edpm_prepare_bootc_os_image_url`: (String) Default bootc OS container image used when content-provider did not build one. Defaults to `quay.io/openstack-k8s-operators/edpm-bootc:latest-qcow2`. +* `cifmw_edpm_prepare_cindervolumes`: (List) cinder volume backend names used as keys under `customContainerImages.cinderVolumeImages`. When empty, discovered from the kustomized `OpenStackControlPlane` CR. Defaults to `[]`. +* `cifmw_edpm_prepare_manilashares`: (List) manila share backend names used as keys under `customContainerImages.manilaShareImages`. When empty, discovered from the kustomized `OpenStackControlPlane` CR. Defaults to `[]`. diff --git a/roles/edpm_prepare/tasks/kustomize_and_deploy.yml b/roles/edpm_prepare/tasks/kustomize_and_deploy.yml index caa147c7e..87e6f850c 100644 --- a/roles/edpm_prepare/tasks/kustomize_and_deploy.yml +++ b/roles/edpm_prepare/tasks/kustomize_and_deploy.yml @@ -28,25 +28,6 @@ cifmw_update_containers_tag: "{{ content_provider_dlrn_md5_hash }}" cifmw_update_containers_openstack: true -- name: Prepare OpenStackVersion CR - when: >- - (cifmw_prepare_openstackversion | bool) and - ((cifmw_update_containers_edpm_image_url is defined and - cifmw_update_containers_openstack is defined and - cifmw_update_containers_openstack | bool) or - (cifmw_update_containers_ansibleee_image_url is defined) or - (cifmw_update_containers_openstack is defined and - cifmw_update_containers_openstack | bool) or - (cifmw_update_containers_watcher is defined and - cifmw_update_containers_watcher | bool) or - (cifmw_update_containers_ceilometersgcoreImage is defined) or - (cifmw_update_containers_ceilometermysqldexporterImage is defined) or - (cifmw_update_containers_edpmpodmanexporterImage is defined)) - vars: - cifmw_update_containers_metadata: "{{ _ctlplane_name }}" - ansible.builtin.include_role: - name: update_containers - - name: Controlplane name kustomization ansible.builtin.set_fact: _ctlplane_name_kustomizations: @@ -98,6 +79,124 @@ ansible.builtin.debug: var: cifmw_edpm_prepare_crs_kustomize_result +# Runs after kustomize (so backends injected via kustomizations are visible) and +# before the OSCP apply (so the OpenStackVersion custom images are seeded first). +- name: Prepare OpenStackVersion CR + when: >- + (cifmw_prepare_openstackversion | bool) and + ((cifmw_update_containers_edpm_image_url is defined and + cifmw_update_containers_openstack is defined and + cifmw_update_containers_openstack | bool) or + (cifmw_update_containers_ansibleee_image_url is defined) or + (cifmw_update_containers_openstack is defined and + cifmw_update_containers_openstack | bool) or + (cifmw_update_containers_watcher is defined and + cifmw_update_containers_watcher | bool) or + (cifmw_update_containers_ceilometersgcoreImage is defined) or + (cifmw_update_containers_ceilometermysqldexporterImage is defined) or + (cifmw_update_containers_edpmpodmanexporterImage is defined)) + block: + - name: Derive cinder/manila backend names from the control plane CR + vars: + _ctlplane_spec: >- + {{ + ((lookup('file', cifmw_edpm_prepare_crs_kustomize_result.output_path) + | from_yaml_all | selectattr('kind', 'equalto', 'OpenStackControlPlane') + | map(attribute='spec') | list) + [{}]) | first + }} + ansible.builtin.set_fact: + cifmw_edpm_prepare_cindervolumes: >- + {{ + (cifmw_edpm_prepare_cindervolumes | default([])) + or (((_ctlplane_spec.get('cinder') or {}).get('template') or {}).get('cinderVolumes') | default({}, true) | list) + }} + cifmw_edpm_prepare_manilashares: >- + {{ + (cifmw_edpm_prepare_manilashares | default([])) + or (((_ctlplane_spec.get('manila') or {}).get('template') or {}).get('manilaShares') | default({}, true) | list) + }} + + - name: Generate the OpenStackVersion CR with custom images + cifmw.general.set_containers: + dest_path: >- + {{ + cifmw_set_containers_dest_path | default( + (cifmw_basedir, 'artifacts', 'manifests', 'set_containers.yml') | + ansible.builtin.path_join + ) + }} + metadata_name: "{{ _ctlplane_name }}" + registry: >- + {{ + cifmw_set_containers_registry | + default(cifmw_update_containers_registry | default(cifmw_default_registry)) + }} + org: >- + {{ + cifmw_set_containers_org | + default(cifmw_update_containers_org | default(cifmw_default_container_image_namespace)) + }} + tag: >- + {{ + cifmw_set_containers_tag | + default(cifmw_update_containers_tag | default(cifmw_default_container_image_tag)) + }} + include_openstack: >- + {{ + cifmw_set_containers_include_openstack | + default(cifmw_update_containers_openstack | default(false)) | bool + }} + apply: >- + {{ + cifmw_set_containers_apply | + default(cifmw_update_containers | default(false)) | bool + }} + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" + images: >- + {{ + (cifmw_set_containers_images | default([])) + + ( + [{'name': 'cinderVolumeImages', 'container_suffix': 'cinder-volume', 'backends': cifmw_edpm_prepare_cindervolumes}] + if cifmw_edpm_prepare_cindervolumes else [] + ) + + ( + [{'name': 'manilaShareImages', 'container_suffix': 'manila-share', 'backends': cifmw_edpm_prepare_manilashares}] + if cifmw_edpm_prepare_manilashares else [] + ) + + ( + [{'name': 'osContainerImage', 'full_registry': cifmw_update_containers_edpm_image_url}] + if cifmw_update_containers_edpm_image_url is defined else [] + ) + + ( + [{'name': 'ironicPythonAgentImage', 'full_registry': cifmw_update_containers_ipa_image_url}] + if cifmw_update_containers_ipa_image_url is defined else [] + ) + + ( + [{'name': 'ansibleeeImage', 'full_registry': cifmw_update_containers_ansibleee_image_url}] + if cifmw_update_containers_ansibleee_image_url is defined else [] + ) + + ( + [{'name': 'ceilometerSgcoreImage', 'full_registry': cifmw_update_containers_ceilometersgcoreImage}] + if cifmw_update_containers_ceilometersgcoreImage is defined else [] + ) + + ( + [{'name': 'ceilometerMysqldExporterImage', 'full_registry': cifmw_update_containers_ceilometermysqldexporterImage}] + if cifmw_update_containers_ceilometermysqldexporterImage is defined else [] + ) + + ( + [{'name': 'edpmPodmanExporterImage', 'full_registry': cifmw_update_containers_edpmpodmanexporterImage}] + if cifmw_update_containers_edpmpodmanexporterImage is defined else [] + ) + + ( + [ + {'name': 'watcherAPIImage', 'container_suffix': 'watcher-api'}, + {'name': 'watcherApplierImage', 'container_suffix': 'watcher-applier'}, + {'name': 'watcherDecisionEngineImage', 'container_suffix': 'watcher-decision-engine'} + ] + if (cifmw_update_containers_watcher | default(false) | bool) else [] + ) + }} + - name: Apply the OpenStackControlPlane CR environment: KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"