Skip to content

Commit 134b141

Browse files
committed
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.
1 parent c5b0d4c commit 134b141

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

roles/os_images/defaults/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ os_images_common: cloud-init enable-serial-console stable-interface-names
4545
# type: qcow2
4646
os_images_list: []
4747
# Common properties to apply to all glance images.
48-
os_images_common_properties:
49-
cpu_arch: x86_64
48+
os_images_common_properties: {}
5049

5150
# OpenStack authentication type: passed to the os_image Ansible module
5251
os_images_auth_type: password

roles/os_images/tasks/images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
dib_args: >-
8686
{% if item.size is defined %}--image-size {{ item.size }}{% endif %} {% if item.type is defined %}-t {{ item.type }}{% endif %}
8787
{% if item.packages | default %}-p {{ item.packages | join(',') }}{% endif %} {{ os_images_common }} {{ item.elements | join(' ') }}
88-
-o {{ item.name }} {% if item.properties.cpu_arch is defined %}-a {{ item.properties.cpu_arch }}{% endif %}
88+
-o {{ item.name }} {% if item.architecture is defined %}-a {{ item.architecture }}{% endif %}
8989
ansible.builtin.shell: . {{ os_images_dib_venv }}/bin/activate && disk-image-create {{ dib_args }} > {{ item.name }}.stdout 2> {{ item.name }}.stderr
9090
args:
9191
chdir: "{{ os_images_cache }}/{{ item.name }}"

roles/os_images/tasks/upload.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,19 @@
110110
container_format: bare
111111
disk_format: "{{ item.0.type | default('qcow2') }}"
112112
filename: "{{ os_images_cache }}/{{ item.0.name }}/{{ item.0.name }}.{{ item.0.type | default('qcow2') }}"
113-
properties: "{{ os_images_common_properties | combine(item.0.properties | default({})) or omit }}"
113+
properties: "{{ os_images_common_properties | combine(cpu_arch_properties) | combine(item.0.properties | default({})) or omit }}"
114114
kernel: "{{ item.1.id if is_baremetal else omit }}"
115115
ramdisk: "{{ item.2.id if is_baremetal else omit }}"
116116
vars:
117+
# NOTE(m-anson): When architecture isn't defined for an
118+
# image, assume that we should set cpu_arch: x86_64 as
119+
# this is the diskimage-builder default.
120+
cpu_arch_properties: >-
121+
{{
122+
{}
123+
if item.0.architecture is defined
124+
else {"cpu_arch": "x86_64"}
125+
}}
117126
is_baremetal: "{{ item.0.elements is defined and 'baremetal' in item.0.elements }}"
118127
visibility: "{{ item.0.visibility | default(item.0.is_public | ternary('public', 'private') if item.0.is_public is defined else os_images_visibility) }}"
119128
with_together:

0 commit comments

Comments
 (0)