set_containers – Generate and optionally apply an OpenStackVersion CR
Synopsis
Generates an OpenStackVersion custom resource that controls which container images OpenStack services, AnsibleEE, and EDPM nodes use.
With state=present the CR file is written and optionally applied to the cluster with oc apply -f.
With state=absent the CR is optionally deleted from the cluster and the local file is removed.
Module-level registry, org, name_prefix, and tag act as defaults for all image URL construction. Every images entry can override any of those four fields individually, so callers only need to specify what differs from the module defaults.
include_openstack=true populates the full standard set of OpenStack service images using the module-level (or per-image) defaults.
The images list handles everything else and can also transparently override individual images from the include_openstack set. Overrides are merged on top; unspecified images keep their default values.
URL resolution order for each images entry. 1. full_registry is set - used as the complete URL. 2. container_suffix is set - URL built from the effective registry/org/name_prefix-suffix:tag (per-image values take precedence over module-level values). 3. Partial overrides only (e.g. tag alone) - the standard suffix for the field name is looked up in the built-in OpenStack image table and the URL is rebuilt with only the specified fields changed. Useful for overriding a single image from the include_openstack set without repeating the suffix.
Requirements
The below requirements are needed on the host that executes this module.
PyYAML
oc (only when apply=true or state=absent)
Parameters
- state (optional, str, present)
presentwrites the CR file and optionally applies it.
absentoptionally deletes it from the cluster then removes the file.- apply (optional, bool, False)
When
trueandstate=present, runoc apply -f dest_path.- preserve_unlisted (optional, bool, False)
When
true, read the current OpenStackVersion CR from the cluster and keepspec.customContainerImagesentries that are not overridden before writing/applying the manifest.Requires
kubeconfigwhen the cluster lookup is needed.A missing OpenStackVersion is treated as an empty map. Any other
oc getfailure is an error.- namespace (optional, str, openstack)
Kubernetes namespace for the OpenStackVersion CR.
- metadata_name (optional, str, controlplane)
Name field of the OpenStackVersion CR metadata.
- dest_path (True, path, None)
Absolute path where the generated CR YAML file is written.
- registry (optional, str, None)
Default container registry host (e.g.
quay.io).Required when
include_openstack=trueor anyimagesentry needs to build a URL from parts and does not provide its ownregistry.- org (optional, str, None)
Default registry namespace or organisation.
Required under the same conditions as
registry.- tag (optional, str, None)
Default container image tag.
Required under the same conditions as
registry.- name_prefix (optional, str, openstack)
Default container image name prefix prepended before the suffix when building an image URL.
- include_openstack (optional, bool, False)
Populate the full set of standard OpenStack service container images using the module-level
registry,org,name_prefix, andtag. Whentruethose four parameters are required.- images (optional, list, [])
List of container image specifications added to or overriding
spec.customContainerImages.Entries are merged on top of images produced by
include_openstack.Each entry can override the module-level
registry,org,name_prefix, andtagindividually. Only the fields that differ from the module defaults need to be specified.
- name (True, str, None)
CR field name, e.g.
ironicPythonAgentImageorcinderVolumeImages. When only partial overrides are given with nocontainer_suffix, this name is looked up in the built-in OpenStack suffix table to rebuild the URL.- full_registry (optional, str, None)
Complete image URL including the tag. When set, all other image- building fields are ignored. Mutually exclusive with
container_suffix.- container_suffix (optional, str, None)
Image name suffix. The URL is built as
registry/org/name_prefix-container_suffix:tagusing the effective per-image or module-level values. Mutually exclusive withfull_registry.- registry (optional, str, None)
Per-image registry override. Falls back to the module-level
registry.- org (optional, str, None)
Per-image organisation override. Falls back to the module-level
org.- name_prefix (optional, str, None)
Per-image name prefix override. Falls back to the module-level
name_prefix.- tag (optional, str, None)
Per-image tag override. Falls back to the module-level
tag.- backends (optional, list, None)
List of backend names. When present the CR field becomes a dict mapping each backend name to its image URL (e.g.
cinderVolumeImagesormanilaShareImages).Each item is either a plain string (inherits the parent image URL) or a dict with
nameplus any subset offull_registry,container_suffix,registry,org,name_prefix,tag.- kubeconfig (optional, path, None)
Path to the kubeconfig file used when running
occommands.Falls back to the
KUBECONFIGenvironment variable when not set.
Examples
- name: Generate CR with the full OpenStack image set (no apply)
cifmw.general.set_containers:
metadata_name: controlplane
dest_path: /home/zuul/ci-framework-data/artifacts/manifests/set_containers.yml
registry: quay.io
org: openstack-k8s-operators
tag: current-podified
include_openstack: true
- name: Full set, override barbican tag and add AnsibleEE, then apply
cifmw.general.set_containers:
metadata_name: controlplane
dest_path: /home/zuul/ci-framework-data/artifacts/manifests/set_containers.yml
registry: quay.io
org: openstack-k8s-operators
tag: current-podified
include_openstack: true
apply: true
kubeconfig: /home/zuul/.kube/config
images:
# override only the tag - suffix is looked up from the built-in table
- name: barbicanAPIImage
tag: my-hsm-tag
- name: barbicanWorkerImage
tag: my-hsm-tag
# pull from a different registry with a different prefix
- name: octaviaAPIImage
registry: mirror.example.com
org: myorg
name_prefix: rhosp
tag: "18.0"
# full URL override
- name: ansibleeeImage
full_registry: quay.rdoproject.org/openstack-k8s-operators/openstack-ansibleee-runner:current-podified
- name: Watcher and cinder/manila backends (no include_openstack)
cifmw.general.set_containers:
dest_path: /tmp/set_containers.yml
registry: quay.io
org: openstack-k8s-operators
tag: current-podified
images:
- name: watcherAPIImage
container_suffix: watcher-api
- name: watcherApplierImage
container_suffix: watcher-applier
- name: watcherDecisionEngineImage
container_suffix: watcher-decision-engine
- name: cinderVolumeImages
container_suffix: cinder-volume
backends:
- default
- name: netapp
full_registry: registry.example.com/netapp/cinder-volume:24.1
- name: hpe
name_prefix: hpe
org: hpe-storage
tag: "1.2.3"
- name: manilaShareImages
container_suffix: manila-share
backends:
- share1
- share2
- name: Remove the CR from the cluster and delete the local file
cifmw.general.set_containers:
state: absent
dest_path: /home/zuul/ci-framework-data/artifacts/manifests/set_containers.yml
kubeconfig: /home/zuul/.kube/config
Return Values
- dest_path (when state=present, str, )
Absolute path to the generated CR file.
- changed (always, bool, )
Whether the module made any changes.