diff --git a/.github/workflows/e2e_run_all.yaml b/.github/workflows/e2e_run_all.yaml index bba0124bf..cea5d57d9 100644 --- a/.github/workflows/e2e_run_all.yaml +++ b/.github/workflows/e2e_run_all.yaml @@ -76,6 +76,17 @@ jobs: debug: true secrets: inherit + podvm_mkosi_amd64_cloudinit: + uses: ./.github/workflows/podvm_mkosi.yaml + with: + registry: ${{ inputs.registry }} + image_tag: ${{ inputs.podvm_image_tag }} + git_ref: ${{ inputs.git_ref }} + arch: amd64 + debug: true + cloud-init: true + secrets: inherit + podvm_mkosi_s390x: uses: ./.github/workflows/podvm_mkosi.yaml with: @@ -247,7 +258,7 @@ jobs: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'test_e2e_libvirt') || contains(github.event.pull_request.labels.*.name, 'test_e2e_libvirt_amd64') - needs: [podvm_mkosi_amd64, libvirt_e2e_arch_prep, caa_image_amd64] + needs: [podvm_mkosi_amd64_cloudinit, libvirt_e2e_arch_prep, caa_image_amd64] strategy: fail-fast: false matrix: ${{ fromJSON(needs.libvirt_e2e_arch_prep.outputs.matrix) }} @@ -255,7 +266,7 @@ jobs: with: runner: ubuntu-24.04 caa_image: ${{ inputs.registry }}/cloud-api-adaptor:${{ inputs.caa_image_tag }}-amd64-dev - podvm_image: ${{ needs.podvm_mkosi_amd64.outputs.qcow2_oras_image }} + podvm_image: ${{ needs.podvm_mkosi_amd64_cloudinit.outputs.qcow2_oras_image }} install_directory_artifact: install_directory git_ref: ${{ inputs.git_ref }} oras: true diff --git a/.github/workflows/podvm_mkosi.yaml b/.github/workflows/podvm_mkosi.yaml index 2cd948d98..472e41f64 100644 --- a/.github/workflows/podvm_mkosi.yaml +++ b/.github/workflows/podvm_mkosi.yaml @@ -25,6 +25,11 @@ on: default: false required: false type: boolean + cloud-init: + description: Whether to build the image with cloudinit enabled + default: false + required: false + type: boolean workflow_call: inputs: @@ -50,6 +55,11 @@ on: default: false required: false type: boolean + cloud-init: + description: Whether to build the image with cloudinit enabled + default: false + required: false + type: boolean outputs: qcow2_oras_image: description: The location of the qcow2 oras container this workflow pushed @@ -250,6 +260,8 @@ jobs: echo "Making non-debug image" make image fi + env: + CLOUD_INIT: ${{ inputs.cloud-init == true && 'true' || 'false' }} - name: Upload the qcow2 with oras id: publish_oras_qcow2 @@ -263,6 +275,9 @@ jobs: if [ "${{inputs.debug}}" = "true" ]; then image=${image}-debug fi + if [ "${{inputs.cloud-init}}" = "true" ]; then + image=${image}-cloudinit + fi tag=${{ steps.image_tag.outputs.image_tag }} arch_tag=${tag}_${{ inputs.arch }} oras push "${image}:${arch_tag}" podvm.tar.xz diff --git a/.github/workflows/podvm_publish.yaml b/.github/workflows/podvm_publish.yaml index 6a5edaeea..5a7e62bd6 100644 --- a/.github/workflows/podvm_publish.yaml +++ b/.github/workflows/podvm_publish.yaml @@ -36,10 +36,15 @@ jobs: strategy: fail-fast: false matrix: - arch: [amd64, s390x] + images: [ + { amd64: x86_64, cloud-init: false }, + { arch: s390x, cloud-init: true }, # Note cloud-init is always used in s390x, so this setting it ignored + { amd64: x86_64, cloud-init: true }, + ] with: git_ref: ${{ github.sha }} image_tag: ${{ github.sha }} - arch: ${{ matrix.arch}} + arch: ${{ matrix.images.arch }} + cloud-init: ${{ matrix.images.cloud-init }} debug: false secrets: inherit diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 90fca28c5..aaab479fb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -59,11 +59,16 @@ jobs: strategy: fail-fast: false matrix: - arch: [amd64, s390x] + images: [ + { amd64: x86_64, cloud-init: false }, + { arch: s390x, cloud-init: true }, # Note cloud-init is always used in s390x, so this setting it ignored + { amd64: x86_64, cloud-init: true }, + ] with: image_tag: ${{ github.event.release.tag_name }} git_ref: ${{ github.ref }} - arch: ${{ matrix.arch}} + arch: ${{ matrix.images.arch }} + cloudinit: ${{ matrix.images.cloud-init }} debug: false secrets: inherit diff --git a/src/cloud-api-adaptor/podvm-mkosi/Makefile b/src/cloud-api-adaptor/podvm-mkosi/Makefile index 867101612..909fda781 100644 --- a/src/cloud-api-adaptor/podvm-mkosi/Makefile +++ b/src/cloud-api-adaptor/podvm-mkosi/Makefile @@ -14,6 +14,7 @@ PODVM_BINARIES_IMAGE ?= $(REGISTRY)/podvm-binaries-$(PODVM_DISTRO)-$(ARCH):$(POD PODVM_IMAGE ?= $(REGISTRY)/podvm-generic-$(PODVM_DISTRO)$(if $(filter $(SE_BOOT),true),-se,)-$(ARCH):$(PODVM_TAG) PODVM_CONTAINER_NAME ?= $(REGISTRY)/podvm-docker-image-$(ARCH) VERIFY_PROVENANCE ?= no +CLOUD_INIT ?= false PUSH ?= false # If not pushing `--load` into the local docker cache @@ -86,6 +87,11 @@ else ifeq ($(ARCH),s390x) touch resources/buildS390xImage sudo mkosi --profile production.conf --image system sudo -E ../hack/build-s390x-image.sh +else ifeq ($(CLOUD_INIT),true) + touch resources/buildCloudInitImage + touch resources/buildBootableImage + sudo -E env PATH=$(PATH) nix develop ..#podvm-mkosi --command mkosi --environment=VARIANT_ID=production + qemu-img convert -f raw -O qcow2 build/system.raw build/podvm-amd64-cloudinit.qcow2 else touch resources/buildBootableImage sudo -E env PATH=$(PATH) nix develop ..#podvm-mkosi --command mkosi --environment=VARIANT_ID=production @@ -109,6 +115,11 @@ else ifeq ($(ARCH),s390x) sudo mkosi --profile debug.conf sudo -E ../hack/build-s390x-image.sh @echo "Building docker image..." +else ifeq ($(CLOUD_INIT),true) + touch resources/buildCloudInitImage + touch resources/buildBootableImage + sudo -E env PATH=$(PATH) nix develop ..#podvm-mkosi --command mkosi --environment=VARIANT_ID=debug + qemu-img convert -f raw -O qcow2 build/system.raw build/podvm-amd64-cloudinit.qcow2 else touch resources/buildBootableImage sudo -E env PATH=$(PATH) nix develop ..#podvm-mkosi --command mkosi --environment=VARIANT_ID=debug diff --git a/src/cloud-api-adaptor/podvm-mkosi/mkosi.presets/system/mkosi.conf.d/fedora-cloudinit.conf b/src/cloud-api-adaptor/podvm-mkosi/mkosi.presets/system/mkosi.conf.d/fedora-cloudinit.conf new file mode 100644 index 000000000..aa388616d --- /dev/null +++ b/src/cloud-api-adaptor/podvm-mkosi/mkosi.presets/system/mkosi.conf.d/fedora-cloudinit.conf @@ -0,0 +1,7 @@ +[Match] +Distribution=fedora + +PathExists=../../resources/buildCloudInitImage + +[Content] +Packages=cloud-init diff --git a/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/20-coco-sys.preset b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/20-coco-sys.preset index c69558105..372ee2307 100644 --- a/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/20-coco-sys.preset +++ b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/20-coco-sys.preset @@ -10,3 +10,7 @@ enable afterburn-checkin.service enable sshd.service enable sshd-keygen@.service enable ssh-host-keys-migration.service + +# For cloudinit +# This unit isn't part of the non-cloudinit image. +enable cloud-init.service