From bdaeed184bf41163b9b410995ad021cee93fb39b Mon Sep 17 00:00:00 2001
From: Matt Crees <mattc@stackhpc.com>
Date: Mon, 16 Jan 2023 10:10:24 +0000
Subject: [PATCH] Build Ubuntu images with IPA when on Ubuntu

Change ``ipa_build_dib_elements_default`` and
``ipa_build_dib_env_default`` to use ``os_distribution`` and
``os_release`` by default. This allows for Ubuntu images to be built
when running on Ubuntu.

Rocky will still build CentOS images, as Rocky IPA images have not been
tested yet.

Change-Id: Iefd2d0b7a3a3e07f5c112d58e2ec0b3da0a747d3
---
 ansible/inventory/group_vars/all/ipa                     | 9 ++++-----
 playbooks/kayobe-seed-base/overrides.yml.j2              | 7 ++++++-
 ...buntu-ipa-images-when-on-ubuntu-5dfcdfdb673343ea.yaml | 8 ++++++++
 3 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 releasenotes/notes/build-ubuntu-ipa-images-when-on-ubuntu-5dfcdfdb673343ea.yaml

diff --git a/ansible/inventory/group_vars/all/ipa b/ansible/inventory/group_vars/all/ipa
index 050b7610..a9adeca8 100644
--- a/ansible/inventory/group_vars/all/ipa
+++ b/ansible/inventory/group_vars/all/ipa
@@ -26,8 +26,8 @@ ipa_build_dib_host_packages_extra: []
 # images. Default is ["centos", "enable-serial-console",
 # "ironic-python-agent-ramdisk"].
 ipa_build_dib_elements_default:
-  # TODO(mgoddard): Use {{ os_distribution }} here when Ubuntu IPA builds work.
-  - centos
+  # TODO(mattcrees): Use {{ os_distribution }} here when Rocky IPA builds work.
+  - "{{ 'centos' if os_distribution == 'rocky' else os_distribution }}"
   - enable-serial-console
   - ironic-python-agent-ramdisk
 
@@ -45,9 +45,8 @@ ipa_build_dib_elements: >
 # Dictionary of default environment variables to provide to Diskimage Builder
 # (DIB) during IPA image build.
 ipa_build_dib_env_default:
-  # TODO(mgoddard): Use {{ os_release }} here when we use os_distribution
-  # above.
-  DIB_RELEASE: "9-stream"
+  # TODO(mattcrees): Use {{ os_release }} here when Rocky IPA builds work.
+  DIB_RELEASE: "{{ '9-stream' if os_distribution == 'rocky' else os_release }}"
   DIB_REPOLOCATION_ironic_python_agent: "{{ ipa_build_source_url }}"
   DIB_REPOREF_ironic_python_agent: "{{ ipa_build_source_version }}"
 
diff --git a/playbooks/kayobe-seed-base/overrides.yml.j2 b/playbooks/kayobe-seed-base/overrides.yml.j2
index c317414f..f5cca32d 100644
--- a/playbooks/kayobe-seed-base/overrides.yml.j2
+++ b/playbooks/kayobe-seed-base/overrides.yml.j2
@@ -32,9 +32,14 @@ aio_bridge_ports:
 # Build seed deployment images (IPA) with extra-hardware element
 ipa_build_images: {{ build_images }}
 ipa_build_dib_elements_extra:
-  - "extra-hardware"
+  # extra-hardware is currently failing on Ubuntu
+  - "{% raw %}{{ 'extra-hardware' if os_distribution != 'ubuntu' else '' }}{% endraw %}"
   - "openstack-ci-mirrors"
 
+# Workaround for limited tmpfs space in CI
+ipa_build_dib_env_extra:
+  DIB_NO_TMPFS: 1
+
 # Build overcloud host image.
 overcloud_dib_build_host_images: {{ build_images }}
 overcloud_dib_elements_extra:
diff --git a/releasenotes/notes/build-ubuntu-ipa-images-when-on-ubuntu-5dfcdfdb673343ea.yaml b/releasenotes/notes/build-ubuntu-ipa-images-when-on-ubuntu-5dfcdfdb673343ea.yaml
new file mode 100644
index 00000000..a46e4bb1
--- /dev/null
+++ b/releasenotes/notes/build-ubuntu-ipa-images-when-on-ubuntu-5dfcdfdb673343ea.yaml
@@ -0,0 +1,8 @@
+---
+upgrade:
+  - |
+    ``ipa_build_dib_elements_default`` and ``ipa_build_dib_env_default`` now
+    use ``os_distribution`` and ``os_release`` by default. This means that
+    Ubuntu images will now be built with the Ironic Python Agent when running
+    on Ubuntu. Rocky will still build CentOS images, as Rocky IPA images have
+    not been tested yet.
-- 
GitLab