diff --git a/images/capi/Makefile b/images/capi/Makefile index 754982380..9a5d40376 100644 --- a/images/capi/Makefile +++ b/images/capi/Makefile @@ -381,7 +381,7 @@ QEMU_BUILD_NAMES ?= qemu-ubuntu-2004 qemu-ubuntu-2204 qemu-ubuntu-2204-cloudim QEMU_KUBEVIRT_BUILD_NAMES := $(addprefix kubevirt-,$(QEMU_BUILD_NAMES)) -RAW_BUILD_NAMES ?= raw-ubuntu-2004 raw-ubuntu-2004-efi raw-flatcar raw-rhel-8 raw-rhel-9 raw-rhel-9-efi +RAW_BUILD_NAMES ?= raw-ubuntu-2004 raw-ubuntu-2004-efi raw-ubuntu-2204 raw-ubuntu-2204-efi raw-ubuntu-2404-efi raw-flatcar raw-rhel-8 raw-rhel-9 raw-rhel-9-efi POWERVS_BUILD_NAMES ?= powervs-centos-8 powervs-centos-9 @@ -833,6 +833,9 @@ build-raw-ubuntu-2004-efi: ## Builds Ubuntu 20.04 RAW image that EFI boots build-raw-rhel-8: ## Builds RHEL 8 RAW image build-raw-rhel-9: ## Builds RHEL 9 RAW image build-raw-rhel-9-efi: ## Builds RHEL 9 RAW image that EFI boots +build-raw-ubuntu-2204: ## Builds Ubuntu 22.04 RAW image +build-raw-ubuntu-2204-efi: ## Builds Ubuntu 22.04 RAW image that EFI boots +build-raw-ubuntu-2404-efi: ## Builds Ubuntu 24.04 RAW image that EFI boots build-raw-all: $(RAW_BUILD_TARGETS) ## Builds all RAW images build-oci-ubuntu-2004: ## Builds the OCI ubuntu-2004 image @@ -1011,6 +1014,8 @@ validate-raw-flatcar: ## Validates Flatcar RAW image packer config validate-raw-ubuntu-2004: ## Validates Ubuntu 20.04 RAW image packer config validate-raw-ubuntu-2004-efi: ## Validates Ubuntu 20.04 RAW EFI image packer config validate-raw-rhel-8: ## Validates RHEL 8 RAW image packer config +validate-raw-ubuntu-2204: ## Validates Ubuntu 22.04 RAW image packer config +validate-raw-ubuntu-2204-efi: ## Validates Ubuntu 22.04 RAW EFI image packer config validate-raw-all: $(RAW_VALIDATE_TARGETS) ## Validates all RAW Packer config validate-oci-ubuntu-2004: ## Validates the OCI ubuntu-2004 image packer config diff --git a/images/capi/packer/raw/.gitignore b/images/capi/packer/raw/.gitignore index 4a8abef2a..6c5ddce4e 100644 --- a/images/capi/packer/raw/.gitignore +++ b/images/capi/packer/raw/.gitignore @@ -3,3 +3,4 @@ ks.cfg ks-efi.cfg preseed.cfg preseed-efi.cfg +user-data diff --git a/images/capi/packer/raw/linux/ubuntu/http/22.04.efi/meta-data b/images/capi/packer/raw/linux/ubuntu/http/22.04.efi/meta-data new file mode 100644 index 000000000..e69de29bb diff --git a/images/capi/packer/raw/linux/ubuntu/http/22.04.efi/user-data.tmpl b/images/capi/packer/raw/linux/ubuntu/http/22.04.efi/user-data.tmpl new file mode 100644 index 000000000..f7a932266 --- /dev/null +++ b/images/capi/packer/raw/linux/ubuntu/http/22.04.efi/user-data.tmpl @@ -0,0 +1,114 @@ +#cloud-config +# Copyright 2022 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For more information on how autoinstall is configured, please refer to +# https://ubuntu.com/server/docs/install/autoinstall-reference +autoinstall: + version: 1 + # Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts + early-commands: + - systemctl stop ssh + # Configure the locale + locale: en_US.UTF-8 + keyboard: + layout: us + grub: + reorder_uefi: false + replace_linux_default: false + # For more information on how partitioning is configured, + # please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html. + storage: + swap: + size: 0 + grub: + reorder_uefi: false + replace_linux_default: false + config: + - ptable: gpt + path: /dev/sda + wipe: superblock-recursive + preserve: false + name: '' + grub_device: false + type: disk + id: disk-sda + - device: disk-sda + # Create EFI partition of 512MB same as in Ubuntu 20.04 + size: 536870912 + wipe: superblock + flag: boot + number: 1 + preserve: false + grub_device: true + type: partition + id: partition-0 + - fstype: fat32 + volume: partition-0 + preserve: false + type: format + id: format-0 + - device: disk-sda + size: -1 + wipe: superblock + flag: '' + number: 2 + preserve: false + grub_device: false + type: partition + id: partition-1 + - fstype: ext4 + volume: partition-1 + preserve: false + type: format + id: format-1 + - path: / + device: format-1 + type: mount + id: mount-1 + - path: /boot/efi + device: format-0 + type: mount + id: mount-0 + updates: "all" + ssh: + install-server: true + allow-pw: true + # Create the default user. + # Ensures the "builder" user doesn't require a password to use sudo. + user-data: + users: + - name: builder + # openssl passwd -6 -salt -stdin <<< + passwd: $ENCRYPTED_SSH_PASSWORD + groups: [adm, cdrom, dip, plugdev, lxd, sudo] + lock-passwd: false + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash + + # This command runs after all other steps; it: + # 1. Disables swapfiles + # 2. Removes the existing swapfile + # 3. Removes the swapfile entry from /etc/fstab + # 4. Removes snapd, https://bugs.launchpad.net/subiquity/+bug/1946609 + # 5. Cleans up any packages that are no longer required + # 6. Removes the cached list of packages + late-commands: + - curtin in-target --target=/target -- swapoff -a + - curtin in-target --target=/target -- rm -f /swap.img + - curtin in-target --target=/target -- sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab + - chroot /target apt-get purge -y snapd + - curtin in-target --target=/target -- apt-get purge --auto-remove -y + - curtin in-target --target=/target -- apt-get clean + - curtin in-target --target=/target -- rm -rf /var/lib/apt/lists/* diff --git a/images/capi/packer/raw/linux/ubuntu/http/22.04/meta-data b/images/capi/packer/raw/linux/ubuntu/http/22.04/meta-data new file mode 100644 index 000000000..e69de29bb diff --git a/images/capi/packer/raw/linux/ubuntu/http/22.04/user-data.tmpl b/images/capi/packer/raw/linux/ubuntu/http/22.04/user-data.tmpl new file mode 100644 index 000000000..d68fcf74c --- /dev/null +++ b/images/capi/packer/raw/linux/ubuntu/http/22.04/user-data.tmpl @@ -0,0 +1,84 @@ +#cloud-config +# Copyright 2022 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# For more information on how autoinstall is configured, please refer to +# https://ubuntu.com/server/docs/install/autoinstall-reference +autoinstall: + version: 1 + # Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts + early-commands: + - systemctl stop ssh + # Configure the locale + locale: en_US.UTF-8 + keyboard: + layout: us + # Create a single-partition with no swap space. Kubernetes + # really dislikes the idea of anyone else managing memory. + # For more information on how partitioning is configured, + # please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html. + storage: + config: + - type: disk + id: disk-0 + size: largest + grub_device: true + preserve: false + ptable: msdos + wipe: superblock + - type: partition + id: partition-0 + device: disk-0 + size: -1 + number: 1 + preserve: false + flag: boot + - type: format + id: format-0 + volume: partition-0 + fstype: ext4 + preserve: false + - type: mount + id: mount-0 + device: format-0 + path: / + updates: 'all' + ssh: + install-server: true + allow-pw: true + # Create the default user. + # Ensures the "builder" user doesn't require a password to use sudo. + user-data: + users: + - name: builder + # openssl passwd -6 -salt -stdin <<< + passwd: $ENCRYPTED_SSH_PASSWORD + groups: [adm, cdrom, dip, plugdev, lxd, sudo] + lock-passwd: false + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash + + # This command runs after all other steps; it: + # 1. Disables swapfiles + # 2. Removes the existing swapfile + # 3. Removes the swapfile entry from /etc/fstab + # 4. Cleans up any packages that are no longer required + # 5. Removes the cached list of packages + late-commands: + - swapoff -a + - rm -f /swapfile + - sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab + - apt-get purge --auto-remove -y + - rm -rf /var/lib/apt/lists/* diff --git a/images/capi/packer/raw/linux/ubuntu/http/24.04.efi/meta-data b/images/capi/packer/raw/linux/ubuntu/http/24.04.efi/meta-data new file mode 100644 index 000000000..e69de29bb diff --git a/images/capi/packer/raw/linux/ubuntu/http/24.04.efi/user-data.tmpl b/images/capi/packer/raw/linux/ubuntu/http/24.04.efi/user-data.tmpl new file mode 100644 index 000000000..45db946d4 --- /dev/null +++ b/images/capi/packer/raw/linux/ubuntu/http/24.04.efi/user-data.tmpl @@ -0,0 +1,114 @@ +#cloud-config +# Copyright 2024 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For more information on how autoinstall is configured, please refer to +# https://ubuntu.com/server/docs/install/autoinstall-reference +autoinstall: + version: 1 + # Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts + early-commands: + - systemctl stop ssh + # Configure the locale + locale: en_US.UTF-8 + keyboard: + layout: us + grub: + reorder_uefi: false + replace_linux_default: false + # For more information on how partitioning is configured, + # please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html. + storage: + swap: + size: 0 + grub: + reorder_uefi: false + replace_linux_default: false + config: + - ptable: gpt + path: /dev/sda + wipe: superblock-recursive + preserve: false + name: '' + grub_device: false + type: disk + id: disk-sda + - device: disk-sda + # Create EFI partition of 512MB same as in Ubuntu 20.04 + size: 536870912 + wipe: superblock + flag: boot + number: 1 + preserve: false + grub_device: true + type: partition + id: partition-0 + - fstype: fat32 + volume: partition-0 + preserve: false + type: format + id: format-0 + - device: disk-sda + size: -1 + wipe: superblock + flag: '' + number: 2 + preserve: false + grub_device: false + type: partition + id: partition-1 + - fstype: ext4 + volume: partition-1 + preserve: false + type: format + id: format-1 + - path: / + device: format-1 + type: mount + id: mount-1 + - path: /boot/efi + device: format-0 + type: mount + id: mount-0 + updates: "all" + ssh: + install-server: true + allow-pw: true + # Create the default user. + # Ensures the "builder" user doesn't require a password to use sudo. + user-data: + users: + - name: builder + # openssl passwd -6 -salt -stdin <<< + passwd: $ENCRYPTED_SSH_PASSWORD + groups: [adm, cdrom, dip, plugdev, lxd, sudo] + lock-passwd: false + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash + + # This command runs after all other steps; it: + # 1. Disables swapfiles + # 2. Removes the existing swapfile + # 3. Removes the swapfile entry from /etc/fstab + # 4. Removes snapd, https://bugs.launchpad.net/subiquity/+bug/1946609 + # 5. Cleans up any packages that are no longer required + # 6. Removes the cached list of packages + late-commands: + - curtin in-target --target=/target -- swapoff -a + - curtin in-target --target=/target -- rm -f /swap.img + - curtin in-target --target=/target -- sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab + - chroot /target apt-get purge -y snapd + - curtin in-target --target=/target -- apt-get purge --auto-remove -y + - curtin in-target --target=/target -- apt-get clean + - curtin in-target --target=/target -- rm -rf /var/lib/apt/lists/* diff --git a/images/capi/packer/raw/packer.json.tmpl b/images/capi/packer/raw/packer.json.tmpl index 383328b4a..f656376da 100644 --- a/images/capi/packer/raw/packer.json.tmpl +++ b/images/capi/packer/raw/packer.json.tmpl @@ -24,6 +24,12 @@ "net_device": "virtio-net", "output_directory": "{{user `output_directory`}}", "qemu_binary": "{{user `qemu_binary`}}", + "qemuargs": [ + [ + "-vga", + "virtio" + ] + ], "shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S -E sh -c 'usermod -L {{user `ssh_username`}} && {{user `shutdown_command`}}'", "ssh_password": "{{user `ssh_password`}}", "ssh_timeout": "2h", @@ -86,7 +92,7 @@ }, { "ansible_env_vars": [ - "ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} -o IdentitiesOnly=yes'" + "ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'" ], "extra_arguments": [ "--extra-vars", @@ -179,6 +185,6 @@ "qemu_binary": "qemu-system-x86_64", "ssh_password": "$SSH_PASSWORD", "ssh_username": "builder", - "vm_name": "{{user `build_name`}}-kube-{{user `kubernetes_semver`}}" + "vm_name": "{{user `build_name`}}-kube-{{user `kubernetes_semver`}}" } } diff --git a/images/capi/packer/raw/raw-ubuntu-2004-efi.json b/images/capi/packer/raw/raw-ubuntu-2004-efi.json index 7ed3ac8a3..35949abfb 100644 --- a/images/capi/packer/raw/raw-ubuntu-2004-efi.json +++ b/images/capi/packer/raw/raw-ubuntu-2004-efi.json @@ -3,7 +3,10 @@ "boot_command_suffix": "/20.04/preseed-efi.cfg -- initrd /install/initrd.gzboot", "build_name": "ubuntu-2004", "build_target": "raw", + "distro_arch": "amd64", "distro_name": "ubuntu", + "distro_version": "20.04", + "distro_version_slug": "2004", "firmware": "OVMF.fd", "guest_os_type": "ubuntu-64", "iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2", diff --git a/images/capi/packer/raw/raw-ubuntu-2004.json b/images/capi/packer/raw/raw-ubuntu-2004.json index 9e78e6384..c4debb15e 100644 --- a/images/capi/packer/raw/raw-ubuntu-2004.json +++ b/images/capi/packer/raw/raw-ubuntu-2004.json @@ -3,7 +3,10 @@ "boot_command_suffix": "/20.04/preseed.cfg -- ", "build_name": "ubuntu-2004", "build_target": "raw", + "distro_arch": "amd64", "distro_name": "ubuntu", + "distro_version": "20.04", + "distro_version_slug": "2004", "guest_os_type": "ubuntu-64", "iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2", "iso_checksum_type": "sha256", diff --git a/images/capi/packer/raw/raw-ubuntu-2204-efi.json b/images/capi/packer/raw/raw-ubuntu-2204-efi.json new file mode 100644 index 000000000..24ac6e826 --- /dev/null +++ b/images/capi/packer/raw/raw-ubuntu-2204-efi.json @@ -0,0 +1,19 @@ +{ + "boot_command_prefix": "clinux /casper/vmlinuz ipv6.disable={{ user `boot_disable_ipv6` }} autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/22.04.efi/' ---initrd /casper/initrdboot", + "boot_disable_ipv6": "1", + "boot_media_path": "/media/HTTP", + "build_name": "ubuntu-2204-efi", + "build_target": "raw", + "distro_arch": "amd64", + "distro_name": "ubuntu", + "distro_version": "22.04", + "distro_version_slug": "2204", + "firmware": "OVMF.fd", + "guest_os_type": "ubuntu-64", + "iso_checksum": "45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2", + "iso_checksum_type": "sha256", + "iso_url": "https://releases.ubuntu.com/22.04/ubuntu-22.04.4-live-server-amd64.iso", + "os_display_name": "Ubuntu 22.04", + "shutdown_command": "shutdown -P now", + "unmount_iso": "true" +} diff --git a/images/capi/packer/raw/raw-ubuntu-2204.json b/images/capi/packer/raw/raw-ubuntu-2204.json new file mode 100644 index 000000000..f70063184 --- /dev/null +++ b/images/capi/packer/raw/raw-ubuntu-2204.json @@ -0,0 +1,18 @@ +{ + "boot_command_prefix": "clinux /casper/vmlinuz ipv6.disable={{ user `boot_disable_ipv6` }} --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/22.04/'initrd /casper/initrdboot", + "boot_disable_ipv6": "1", + "boot_media_path": "/media/HTTP", + "build_name": "ubuntu-2204", + "build_target": "raw", + "distro_arch": "amd64", + "distro_name": "ubuntu", + "distro_version": "22.04", + "distro_version_slug": "2204", + "guest_os_type": "ubuntu-64", + "iso_checksum": "45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2", + "iso_checksum_type": "sha256", + "iso_url": "https://releases.ubuntu.com/22.04/ubuntu-22.04.4-live-server-amd64.iso", + "os_display_name": "Ubuntu 22.04", + "shutdown_command": "shutdown -P now", + "unmount_iso": "true" +} diff --git a/images/capi/packer/raw/raw-ubuntu-2404-efi.json b/images/capi/packer/raw/raw-ubuntu-2404-efi.json new file mode 100644 index 000000000..fb7c51ad2 --- /dev/null +++ b/images/capi/packer/raw/raw-ubuntu-2404-efi.json @@ -0,0 +1,19 @@ +{ + "boot_command_prefix": "clinux /casper/vmlinuz ipv6.disable={{ user `boot_disable_ipv6` }} autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/24.04.efi/' ---initrd /casper/initrdboot", + "boot_disable_ipv6": "1", + "boot_media_path": "/media/HTTP", + "build_name": "ubuntu-{{user `distro_version` | replace_all \".\" \"\" }}-efi", + "build_target": "raw", + "distro_arch": "amd64", + "distro_name": "ubuntu", + "distro_version": "24.04", + "distro_version_slug": "2404", + "firmware": "OVMF.fd", + "guest_os_type": "ubuntu-64", + "iso_checksum": "https://releases.ubuntu.com/noble/SHA256SUMS", + "iso_checksum_type": "file", + "iso_url": "https://releases.ubuntu.com/noble/ubuntu-24.04.1-live-server-amd64.iso", + "os_display_name": "Ubuntu 24.04", + "shutdown_command": "shutdown -P now", + "unmount_iso": "true" +} diff --git a/images/capi/packer/raw/raw-ubuntu-2404.json b/images/capi/packer/raw/raw-ubuntu-2404.json new file mode 100644 index 000000000..41ddbcb82 --- /dev/null +++ b/images/capi/packer/raw/raw-ubuntu-2404.json @@ -0,0 +1,18 @@ +{ + "boot_command_prefix": "clinux /casper/vmlinuz ipv6.disable={{ user `boot_disable_ipv6` }} --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/24.04/'initrd /casper/initrdboot", + "boot_disable_ipv6": "1", + "boot_media_path": "/media/HTTP", + "build_name": "ubuntu-{{user `distro_version` | replace_all \".\" \"\" }}", + "build_target": "raw", + "distro_arch": "amd64", + "distro_name": "ubuntu", + "distro_version": "24.04", + "distro_version_slug": "2404", + "guest_os_type": "ubuntu-64", + "iso_checksum": "https://releases.ubuntu.com/noble/SHA256SUMS", + "iso_checksum_type": "file", + "iso_url": "https://releases.ubuntu.com/noble/ubuntu-24.04.1-live-server-amd64.iso", + "os_display_name": "Ubuntu 24.04", + "shutdown_command": "shutdown -P now", + "unmount_iso": "true" +}