Skip to content

Commit ed97aae

Browse files
committed
Make arm64/aarch64 and x86_64 first-class citizens for images
Detect their glance cpu_arch property directly from their architecture.
1 parent 9191ae7 commit ed97aae

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

roles/os_images/README.md

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ mutually exclusive where each contain:
5959
* `size`: (optional) size to make the image filesystem.
6060
* `architecture`: (optional) image CPU architecture to pass to diskimage-builder `-a`.
6161
If unset, default to the diskimage-builder default architecture: `x86_64`, and upload
62-
Glance images with the `cpu_arch: "x86_64"` image property.
63-
When setting, consider also setting `properties.cpu_arch` to a corresponding value.
62+
Glance images with the `cpu_arch: "x86_64"` image property. If architecture is set
63+
to `arm64` or `aarch64`, Glance images with the `cpu_arch: "aarch64"` image property
64+
When setting to other values, consider also setting `properties.cpu_arch` to a
65+
corresponding value.
6466
* `properties`: (optional) dict of properties to set on the glance image.
6567
Common image properties are available
6668
[here](https://docs.openstack.org/glance/latest/user/common-image-properties.html).
@@ -130,28 +132,9 @@ Changing platform architecture in os_images
130132

131133
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.
132134

133-
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`.
134-
135-
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.
136-
137-
```yaml
138-
os_images_list:
139-
- name: ubuntu
140-
elements:
141-
- ubuntu
142-
packages:
143-
- biosdevname
144-
type: qcow2
145-
- name: ubuntu-aarch64
146-
architecture: arm64
147-
elements:
148-
- ubuntu
149-
properties:
150-
cpu_arch: aarch64
151-
packages:
152-
- biosdevname
153-
type: qcow2
154-
```
135+
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`.
136+
137+
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).
155138

156139
Dependencies
157140
------------

roles/os_images/tasks/upload.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,21 @@
116116
vars:
117117
# NOTE(m-anson): When architecture isn't defined for an
118118
# image, assume that we should set cpu_arch: x86_64 as
119-
# this is the diskimage-builder default.
119+
# this is the diskimage-builder default. If an architecture
120+
# of arm64 or aarch64 is defined, set cpu_arch: aarch64. In
121+
# all other cases, leave it up to the operator to set
122+
# properties.cpu_arch.
120123
cpu_arch_properties: >-
121124
{{
122-
{}
123-
if item.0.architecture is defined
124-
else {"cpu_arch": "x86_64"}
125+
{} | combine(
126+
{"cpu_arch": "x86_64"}
127+
if item.0.architecture is not defined
128+
else {}
129+
) | combine(
130+
{"cpu_arch": "aarch64"}
131+
if item.0.architecture is defined and item.0.architecture in ["arm64", "aarch64"]
132+
else {}
133+
)
125134
}}
126135
is_baremetal: "{{ item.0.elements is defined and 'baremetal' in item.0.elements }}"
127136
visibility: "{{ item.0.visibility | default(item.0.is_public | ternary('public', 'private') if item.0.is_public is defined else os_images_visibility) }}"

0 commit comments

Comments
 (0)