From 142ba820b47532a08d9054040df5db7e3adf17c5 Mon Sep 17 00:00:00 2001 From: "max.bed4d" Date: Tue, 4 Feb 2025 15:21:46 +0000 Subject: [PATCH 01/11] add image platform argument --- roles/os_images/tasks/images.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/os_images/tasks/images.yml b/roles/os_images/tasks/images.yml index d853ec7..d2da5a8 100644 --- a/roles/os_images/tasks/images.yml +++ b/roles/os_images/tasks/images.yml @@ -83,8 +83,9 @@ - name: Generate diskimage-builder images vars: dib_args: >- - {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default - %}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }} -o {{ item.name }} + {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if os_images_architecture is defined %}-a {{ os_images_architecture }}{% endif %} + {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} + {{ os_images_common }} {{ item.elements | join(' ') }} -o {{ item.name }} -a {{ os_images_architecture }} ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr args: chdir: "{{ os_images_cache }}/{{ item.name }}" From 1a478b66d9c4daf73a9cd77c3e2e471e01a8d9cb Mon Sep 17 00:00:00 2001 From: "max.bed4d" Date: Thu, 6 Feb 2025 13:15:48 +0000 Subject: [PATCH 02/11] Tidy role --- roles/os_images/tasks/images.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/os_images/tasks/images.yml b/roles/os_images/tasks/images.yml index d2da5a8..3d0b02c 100644 --- a/roles/os_images/tasks/images.yml +++ b/roles/os_images/tasks/images.yml @@ -83,9 +83,9 @@ - name: Generate diskimage-builder images vars: dib_args: >- - {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if os_images_architecture is defined %}-a {{ os_images_architecture }}{% endif %} - {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} - {{ os_images_common }} {{ item.elements | join(' ') }} -o {{ item.name }} -a {{ os_images_architecture }} + {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %} + {% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }} + -o {{ item.name }} -a {{ os_images_architecture }} ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr args: chdir: "{{ os_images_cache }}/{{ item.name }}" From 32e0a085cb62a6c32df460f6897e0580602b1737 Mon Sep 17 00:00:00 2001 From: Massimiliano Favaro-Bedford <78351765+MaxBed4d@users.noreply.github.com> Date: Fri, 7 Feb 2025 14:36:55 +0000 Subject: [PATCH 03/11] Add default arch --- roles/os_images/tasks/images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/os_images/tasks/images.yml b/roles/os_images/tasks/images.yml index 3d0b02c..a15460b 100644 --- a/roles/os_images/tasks/images.yml +++ b/roles/os_images/tasks/images.yml @@ -85,7 +85,7 @@ dib_args: >- {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }} - -o {{ item.name }} -a {{ os_images_architecture }} + -o {{ item.name }} -a {{ os_images_architecture | default('amd64') }} ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr args: chdir: "{{ os_images_cache }}/{{ item.name }}" From bae5ebe02bde0438b3ddcee3a7a466a0e0194357 Mon Sep 17 00:00:00 2001 From: Massimiliano Favaro-Bedford <78351765+MaxBed4d@users.noreply.github.com> Date: Fri, 7 Feb 2025 14:39:47 +0000 Subject: [PATCH 04/11] Update pattern for default --- roles/os_images/tasks/images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/os_images/tasks/images.yml b/roles/os_images/tasks/images.yml index a15460b..ee3a018 100644 --- a/roles/os_images/tasks/images.yml +++ b/roles/os_images/tasks/images.yml @@ -85,7 +85,7 @@ dib_args: >- {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }} - -o {{ item.name }} -a {{ os_images_architecture | default('amd64') }} + -o {{ item.name }} {% if os_images_architecture is defined %}-a {{ os_images_architecture }}{% endif %} ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr args: chdir: "{{ os_images_cache }}/{{ item.name }}" From 3b11112e663e687380f288764dbda6a2cc93113e Mon Sep 17 00:00:00 2001 From: Massimiliano Favaro-Bedford <78351765+MaxBed4d@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:03:09 +0000 Subject: [PATCH 05/11] Update roles/os_images/tasks/images.yml Co-authored-by: Matt Crees --- roles/os_images/tasks/images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/os_images/tasks/images.yml b/roles/os_images/tasks/images.yml index ee3a018..242d990 100644 --- a/roles/os_images/tasks/images.yml +++ b/roles/os_images/tasks/images.yml @@ -85,7 +85,7 @@ dib_args: >- {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }} - -o {{ item.name }} {% if os_images_architecture is defined %}-a {{ os_images_architecture }}{% endif %} + -o {{ item.name }} {% if item.properties.cpu_arch is defined %}-a {{ item.properties.cpu_arch }}{% endif %} ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr args: chdir: "{{ os_images_cache }}/{{ item.name }}" From c5b0d4ca37a98e5f33ed7a839e4cc23f69c6a138 Mon Sep 17 00:00:00 2001 From: "max.bed4d" Date: Mon, 10 Feb 2025 09:52:34 +0000 Subject: [PATCH 06/11] README update for CPU Arch --- roles/os_images/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/roles/os_images/README.md b/roles/os_images/README.md index fd9a008..15633e8 100644 --- a/roles/os_images/README.md +++ b/roles/os_images/README.md @@ -118,6 +118,33 @@ will be replaced with the newly built image if `os_images_upload` is set to `Tru `os_images_hide`: Whether or not to hide the images in Glance list. Hiding images is available as an option in image retirement/promotion process. Defaults to `False`. +Changing platform architecture in os_images +------------------------------------------- + +The `Generate diskimage-builder images` job in the ``os_images`` role can build an +image for a chosen CPU architecture by defining the ``cpu_arch`` image property before +calling the ``os_images`` role. This is an [example](https://github.com/stackhpc/kayobe/blob/18ca11b47af42ce10507516c2f9e34f447d5e39a/ansible/overcloud-host-image-build.yml#L21_) +of a playbook calling the ``os_image`` role & below is an example of how to set the +``cpu_arch`` image property in a configuration like StackHPC-Kayobe-Config: + +```yaml + stackhpc_overcloud_dib_host_image: + name: "{{ image_name }}" + elements: "{{ dib_elements }}" + env: "{{ dib_env_vars }}" + packages: "{{ dib_packages }}" + properties: + - cpu_arch: "arm64" +``` + +The ``cpu_arch`` variable will also be set as an image property within the `Upload +cloud tenant images` task in the ``upload.yml`` task. + +If left unset the ``cpu_arch`` variable will default to `x86_64` for ``upload.yml``. +However, if not set, the `Generate diskimage-builder images` job will takes the +disk image builder's default. + + Dependencies ------------ From 134b1411f10fb10c77ec542c72b788bf5aa571cc Mon Sep 17 00:00:00 2001 From: Matt Anson Date: Tue, 1 Apr 2025 13:08:43 +0100 Subject: [PATCH 07/11] Separate architecture from properties.cpu_arch Allow both to be independent, but retain the original behaviour of setting cpu_arch: "x86_64" when no architecture is provided. --- roles/os_images/defaults/main.yml | 3 +-- roles/os_images/tasks/images.yml | 2 +- roles/os_images/tasks/upload.yml | 11 ++++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/os_images/defaults/main.yml b/roles/os_images/defaults/main.yml index 02c4033..41e5e54 100644 --- a/roles/os_images/defaults/main.yml +++ b/roles/os_images/defaults/main.yml @@ -45,8 +45,7 @@ os_images_common: cloud-init enable-serial-console stable-interface-names # type: qcow2 os_images_list: [] # Common properties to apply to all glance images. -os_images_common_properties: - cpu_arch: x86_64 +os_images_common_properties: {} # OpenStack authentication type: passed to the os_image Ansible module os_images_auth_type: password diff --git a/roles/os_images/tasks/images.yml b/roles/os_images/tasks/images.yml index 242d990..2536d59 100644 --- a/roles/os_images/tasks/images.yml +++ b/roles/os_images/tasks/images.yml @@ -85,7 +85,7 @@ dib_args: >- {% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %} {% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }} - -o {{ item.name }} {% if item.properties.cpu_arch is defined %}-a {{ item.properties.cpu_arch }}{% endif %} + -o {{ item.name }} {% if item.architecture is defined %}-a {{ item.architecture }}{% endif %} ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr args: chdir: "{{ os_images_cache }}/{{ item.name }}" diff --git a/roles/os_images/tasks/upload.yml b/roles/os_images/tasks/upload.yml index 8653098..90c695e 100644 --- a/roles/os_images/tasks/upload.yml +++ b/roles/os_images/tasks/upload.yml @@ -110,10 +110,19 @@ container_format: bare disk_format: "{{ item.0.type | default('qcow2') }}" filename: "{{ os_images_cache }}/{{ item.0.name }}/{{ item.0.name }}.{{ item.0.type | default('qcow2') }}" - properties: "{{ os_images_common_properties | combine(item.0.properties | default({})) or omit }}" + properties: "{{ os_images_common_properties | combine(cpu_arch_properties) | combine(item.0.properties | default({})) or omit }}" kernel: "{{ item.1.id if is_baremetal else omit }}" ramdisk: "{{ item.2.id if is_baremetal else omit }}" vars: + # NOTE(m-anson): When architecture isn't defined for an + # image, assume that we should set cpu_arch: x86_64 as + # this is the diskimage-builder default. + cpu_arch_properties: >- + {{ + {} + if item.0.architecture is defined + else {"cpu_arch": "x86_64"} + }} is_baremetal: "{{ item.0.elements is defined and 'baremetal' in item.0.elements }}" visibility: "{{ item.0.visibility | default(item.0.is_public | ternary('public', 'private') if item.0.is_public is defined else os_images_visibility) }}" with_together: From 9191ae76f1452010bab0aa16d85938cf078d4a9f Mon Sep 17 00:00:00 2001 From: Matt Anson Date: Tue, 1 Apr 2025 13:09:06 +0100 Subject: [PATCH 08/11] Simplify documentation and note architecture/cpu_arch split --- roles/os_images/README.md | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/roles/os_images/README.md b/roles/os_images/README.md index 15633e8..66e6a79 100644 --- a/roles/os_images/README.md +++ b/roles/os_images/README.md @@ -57,6 +57,10 @@ mutually exclusive where each contain: This is a dict of the form of `KEY: VALUE`. * `packages`: (optional) list of packages to install in the image. * `size`: (optional) size to make the image filesystem. +* `architecture`: (optional) image CPU architecture to pass to diskimage-builder `-a`. + If unset, default to the diskimage-builder default architecture: `x86_64`, and upload + Glance images with the `cpu_arch: "x86_64"` image property. + When setting, consider also setting `properties.cpu_arch` to a corresponding value. * `properties`: (optional) dict of properties to set on the glance image. Common image properties are available [here](https://docs.openstack.org/glance/latest/user/common-image-properties.html). @@ -76,6 +80,9 @@ or 'community'. Default is 'public' `os_images_common`: A set of elements to include in every image listed. Defaults to `cloud-init enable-serial-console stable-interface-names`. +`os_images_common_properties`: A dict of Glance image properties to set on all images. +Defaults to an empty dict, and is overridden by `os_images_list.*.properties`. + `os_images_dib_pkg_name`: Optionally customise the name parameter passed to the ansible.builtin.pip module when installing diskimage-builder. This can be used to install diskimage-builder from version control. @@ -121,30 +128,31 @@ will be replaced with the newly built image if `os_images_upload` is set to `Tru Changing platform architecture in os_images ------------------------------------------- -The `Generate diskimage-builder images` job in the ``os_images`` role can build an -image for a chosen CPU architecture by defining the ``cpu_arch`` image property before -calling the ``os_images`` role. This is an [example](https://github.com/stackhpc/kayobe/blob/18ca11b47af42ce10507516c2f9e34f447d5e39a/ansible/overcloud-host-image-build.yml#L21_) -of a playbook calling the ``os_image`` role & below is an example of how to set the -``cpu_arch`` image property in a configuration like StackHPC-Kayobe-Config: +The target CPU architecture for each image defined in `os_images_list` may be set to any architecture supported by diskimage-builder with the `architecture` parameter. + +If it is unset, an image with the default diskimage-builder architecture (`x86_64`) will be built and optionally uploaded to Glance, with the Glance image property `cpu_arch` set to `x86_64`. + +If `architecture` is set for an image, consider also setting `properties.cpu_arch` to an architecture [supported by Glance](https://docs.openstack.org/glance/latest/admin/useful-image-properties.html#image-property-keys-and-values). An example is given below. ```yaml - stackhpc_overcloud_dib_host_image: - name: "{{ image_name }}" - elements: "{{ dib_elements }}" - env: "{{ dib_env_vars }}" - packages: "{{ dib_packages }}" + os_images_list: + - name: ubuntu + elements: + - ubuntu + packages: + - biosdevname + type: qcow2 + - name: ubuntu-aarch64 + architecture: arm64 + elements: + - ubuntu properties: - - cpu_arch: "arm64" + cpu_arch: aarch64 + packages: + - biosdevname + type: qcow2 ``` -The ``cpu_arch`` variable will also be set as an image property within the `Upload -cloud tenant images` task in the ``upload.yml`` task. - -If left unset the ``cpu_arch`` variable will default to `x86_64` for ``upload.yml``. -However, if not set, the `Generate diskimage-builder images` job will takes the -disk image builder's default. - - Dependencies ------------ From c10724863ca341cf6edc2ce48962a1b4173347f4 Mon Sep 17 00:00:00 2001 From: Matt Anson Date: Wed, 2 Apr 2025 17:06:15 +0100 Subject: [PATCH 09/11] Make arm64/aarch64 and x86_64 first-class citizens for images Detect their glance cpu_arch property directly from their architecture. --- roles/os_images/README.md | 31 +++++++------------------------ roles/os_images/tasks/upload.yml | 11 +++++++---- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/roles/os_images/README.md b/roles/os_images/README.md index 66e6a79..fddd1c0 100644 --- a/roles/os_images/README.md +++ b/roles/os_images/README.md @@ -59,8 +59,10 @@ mutually exclusive where each contain: * `size`: (optional) size to make the image filesystem. * `architecture`: (optional) image CPU architecture to pass to diskimage-builder `-a`. If unset, default to the diskimage-builder default architecture: `x86_64`, and upload - Glance images with the `cpu_arch: "x86_64"` image property. - When setting, consider also setting `properties.cpu_arch` to a corresponding value. + Glance images with the `cpu_arch: "x86_64"` image property. If architecture is set + to `arm64` or `aarch64`, Glance images with the `cpu_arch: "aarch64"` image property + When setting to other values, consider also setting `properties.cpu_arch` to a + corresponding value. * `properties`: (optional) dict of properties to set on the glance image. Common image properties are available [here](https://docs.openstack.org/glance/latest/user/common-image-properties.html). @@ -130,28 +132,9 @@ Changing platform architecture in os_images The target CPU architecture for each image defined in `os_images_list` may be set to any architecture supported by diskimage-builder with the `architecture` parameter. -If it is unset, an image with the default diskimage-builder architecture (`x86_64`) will be built and optionally uploaded to Glance, with the Glance image property `cpu_arch` set to `x86_64`. - -If `architecture` is set for an image, consider also setting `properties.cpu_arch` to an architecture [supported by Glance](https://docs.openstack.org/glance/latest/admin/useful-image-properties.html#image-property-keys-and-values). An example is given below. - -```yaml - os_images_list: - - name: ubuntu - elements: - - ubuntu - packages: - - biosdevname - type: qcow2 - - name: ubuntu-aarch64 - architecture: arm64 - elements: - - ubuntu - properties: - cpu_arch: aarch64 - packages: - - biosdevname - type: qcow2 -``` +If it is unset, an image with the default diskimage-builder architecture (`x86_64`) will be built and optionally uploaded to Glance, with the Glance image property `cpu_arch` set to `x86_64`. If it is set to `arm64` or `aarch64`, images will be uploaded to Glance with the Glance image property `cpu_arch` set to `aarch64`. + +If setting to a different `architecture`, consider also setting `properties.cpu_arch` to an architecture [supported by Glance](https://docs.openstack.org/glance/latest/admin/useful-image-properties.html#image-property-keys-and-values). Dependencies ------------ diff --git a/roles/os_images/tasks/upload.yml b/roles/os_images/tasks/upload.yml index 90c695e..4cbef18 100644 --- a/roles/os_images/tasks/upload.yml +++ b/roles/os_images/tasks/upload.yml @@ -116,12 +116,15 @@ vars: # NOTE(m-anson): When architecture isn't defined for an # image, assume that we should set cpu_arch: x86_64 as - # this is the diskimage-builder default. + # this is the diskimage-builder default. If an architecture + # of arm64 or aarch64 is defined, set cpu_arch: aarch64. In + # all other cases, leave it up to the operator to set + # properties.cpu_arch. cpu_arch_properties: >- {{ - {} - if item.0.architecture is defined - else {"cpu_arch": "x86_64"} + {"cpu_arch": "aarch64"} + if (item.0.architecture is defined and item.0.architecture in ["arm64", "aarch64"]) + else ({"cpu_arch": "x86_64"} if item.0.architecture is not defined else {}) }} is_baremetal: "{{ item.0.elements is defined and 'baremetal' in item.0.elements }}" visibility: "{{ item.0.visibility | default(item.0.is_public | ternary('public', 'private') if item.0.is_public is defined else os_images_visibility) }}" From 25d22ff11f5a0831bcae109de1c22ed4650b83dc Mon Sep 17 00:00:00 2001 From: Matt Anson Date: Fri, 4 Apr 2025 15:50:03 +0100 Subject: [PATCH 10/11] Fixup README --- roles/os_images/README.md | 56 ++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/roles/os_images/README.md b/roles/os_images/README.md index fddd1c0..c8c3879 100644 --- a/roles/os_images/README.md +++ b/roles/os_images/README.md @@ -27,8 +27,8 @@ on the build host. `os_images_cache`: a path to a directory in which to cache build artefacts. It defaults to `~/disk_images` -`NOTE`: new images will NOT be built, even if changes are made in config, if an image is already cached. -Use `force_rebuild` flag in order to apply new config changes. +`NOTE`: new images will NOT be built, even if changes are made in config, if an image +is already cached. Use `force_rebuild` flag in order to apply new config changes. `os_images_auth_type`: OpenStack authentication endpoint and credentials. Defaults to `password`. @@ -68,15 +68,15 @@ mutually exclusive where each contain: [here](https://docs.openstack.org/glance/latest/user/common-image-properties.html). * `type`: (optional) image type. Default in DIB is qcow2. Image formats are available [here](https://docs.openstack.org/glance/latest/user/formats.html). -* `force_rebuild`: (optional) boolean flag indicating whether or not the image should always - be built (even if an existing image that name has been built before). The images on glance - will be replaced if `os_images_upload` is set to `True`. This defaults to +* `force_rebuild`: (optional) boolean flag indicating whether or not the image should + always be built (even if an existing image that name has been built before). The images + in glance will be replaced if `os_images_upload` is set to `True`. This defaults to `os_images_force_rebuild`if left unset. -* `is_public`: (optional) (deprecated - use `visibility`) whether the image should be set as visible to all - projects or kept private. Note that if both `is_public` and `visibility` are provided, `is_public` will - be preferred. +* `is_public`: (optional) (deprecated - use `visibility`) whether the image should be set + as visible to all projects or kept private. Note that if both `is_public` and `visibility` + are provided, `is_public` will be preferred. * `visibility`: (optional) Allowed values are 'public', 'private', 'shared' -or 'community'. Default is 'public' + or 'community'. Default is 'public' * `owner`: (optional) ID of the project that should own the uploaded image. `os_images_common`: A set of elements to include in every image listed. @@ -105,36 +105,50 @@ following parameters: `os_images_upload`: Whether to upload built images to Glance. Defaults to `True`. -`os_images_force_rebuild`: Whether or not to force a rebuild of the DIB image. The images on Glance -will be replaced with the newly built image if `os_images_upload` is set to `True`. Defaults to -`False`. +`os_images_force_rebuild`: Whether or not to force a rebuild of the DIB image. +The images on Glance will be replaced with the newly built image if `os_images_upload` +is set to `True`. Defaults to `False`. -`os_images_public`: (Deprecated - use `os_images_visibility`) Whether uploaded images are public. Defaults to `True` - note this requires admin permissions. +`os_images_public`: (Deprecated - use `os_images_visibility`) Whether uploaded +images are public. Defaults to `True` - note this requires admin permissions. -`os_images_visibility`: The visibility of images uploaded. One of `community`,`public` or `private`. If unset, defaults to `os_images_public` (requires admin permissions for anything other than `private`) +`os_images_visibility`: The visibility of images uploaded. One of `community`, +`public` or `private`. If unset, defaults to `os_images_public` (requires admin +permissions for anything other than `private`) -`os_images_venv`: Path to virtualenv in which to install python dependencies to upload images. +`os_images_venv`: Path to virtualenv in which to install python dependencies to +upload images. `os_images_dib_venv`: Path to virtualenv in which to install DIB to build images. `os_images_promote`: Whether or not to promote new images. Defaults to `False`. -`os_images_retire`: Whether or not to retire old images. Defaults to `os_image_promote`. May be necessary to set separately if you are promoting a new candidate image for which there is no existing one to retire, for example. +`os_images_retire`: Whether or not to retire old images. Defaults to `os_image_promote`. +May be necessary to set separately if you are promoting a new candidate image for which +there is no existing one to retire, for example. `os_images_build`: Whether or not to build the images. -`os_images_name_suffix`: Image suffix which would be removed during image promotion, for exmple: -rc, -dev, -test etc. Mandatory for promotion functionality. Empty by default. +`os_images_name_suffix`: Image suffix which would be removed during image promotion, for +exmple: -rc, -dev, -test etc. Mandatory for promotion functionality. Empty by default. -`os_images_hide`: Whether or not to hide the images in Glance list. Hiding images is available as an option in image retirement/promotion process. Defaults to `False`. +`os_images_hide`: Whether or not to hide the images in Glance list. Hiding images is +available as an option in image retirement/promotion process. Defaults to `False`. Changing platform architecture in os_images ------------------------------------------- -The target CPU architecture for each image defined in `os_images_list` may be set to any architecture supported by diskimage-builder with the `architecture` parameter. +The target CPU architecture for each image defined in `os_images_list` may be set to any +architecture supported by diskimage-builder with the `architecture` parameter. -If it is unset, an image with the default diskimage-builder architecture (`x86_64`) will be built and optionally uploaded to Glance, with the Glance image property `cpu_arch` set to `x86_64`. If it is set to `arm64` or `aarch64`, images will be uploaded to Glance with the Glance image property `cpu_arch` set to `aarch64`. +If it is unset, an image with the default diskimage-builder architecture (`x86_64`) will +be built and optionally uploaded to Glance, with the Glance image property `cpu_arch` set +to `x86_64`. If it is set to `arm64` or `aarch64`, images will be uploaded to Glance with +the Glance image property `cpu_arch` set to `aarch64`. -If setting to a different `architecture`, consider also setting `properties.cpu_arch` to an architecture [supported by Glance](https://docs.openstack.org/glance/latest/admin/useful-image-properties.html#image-property-keys-and-values). +If setting to a different `architecture`, consider also setting `properties.cpu_arch` to an +architecture +[supported by Glance](https://docs.openstack.org/glance/latest/admin/useful-image-properties.html#image-property-keys-and-values). Dependencies ------------ From 8ecd7ef25027eff29e221054eb1b929911d764d8 Mon Sep 17 00:00:00 2001 From: Matt Anson Date: Fri, 4 Apr 2025 15:51:04 +0100 Subject: [PATCH 11/11] Run multiarch/qemu-user-static image for cross-arch This approach is taken in Kolla CI and Kayobe for building cross-arch OCI images, reuse it here. --- roles/os_images/tasks/prereqs.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roles/os_images/tasks/prereqs.yml b/roles/os_images/tasks/prereqs.yml index 2301614..4d75345 100644 --- a/roles/os_images/tasks/prereqs.yml +++ b/roles/os_images/tasks/prereqs.yml @@ -29,3 +29,15 @@ state: directory mode: "0755" become: true + +- name: Run multiarch/qemu-user-static image to support cross-arch build + ansible.builtin.command: + # We already have a precheck for presence of docker executable so use it here + cmd: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + # Using --reset means that we always change something + changed_when: true + become: true + when: os_images_list | + selectattr("architecture", "defined") | + rejectattr("architecture", "equalto", ansible_facts.architecture) | + length > 0