diff --git a/images/capi/Makefile b/images/capi/Makefile index 7f8f4290d..eacfd520f 100644 --- a/images/capi/Makefile +++ b/images/capi/Makefile @@ -117,6 +117,7 @@ deps-qemu: ## Installs/checks dependencies for QEMU builds deps-qemu: deps-common hack/ensure-goss.sh $(PACKER) init packer/config.pkr.hcl + $(PACKER) plugins install github.com/hashicorp/qemu .PHONY: deps-raw deps-raw: ## Installs/checks dependencies for RAW builds @@ -369,7 +370,7 @@ OPENSTACK_BUILD_NAMES ?= openstack-ubuntu-2004 openstack-ubuntu-2204 openstack- OSC_BUILD_NAMES ?= osc-ubuntu-2004 osc-ubuntu-2204 -QEMU_BUILD_NAMES ?= qemu-ubuntu-2004 qemu-ubuntu-2204 qemu-ubuntu-2304 qemu-ubuntu-2204-efi qemu-centos-7 qemu-centos-9 qemu-ubuntu-2004-efi qemu-rhel-8 qemu-rhel-9 qemu-rockylinux-8 qemu-rockylinux-9 qemu-flatcar +QEMU_BUILD_NAMES ?= qemu-ubuntu-2004 qemu-ubuntu-2204 qemu-ubuntu-2204-cloudimg qemu-ubuntu-2304 qemu-ubuntu-2204-efi qemu-centos-7 qemu-centos-9 qemu-ubuntu-2004-efi qemu-rhel-8 qemu-rhel-9 qemu-rockylinux-8 qemu-rockylinux-8-cloudimg qemu-rockylinux-9 qemu-rockylinux-9-cloudimg qemu-flatcar QEMU_KUBEVIRT_BUILD_NAMES := $(addprefix kubevirt-,$(QEMU_BUILD_NAMES)) @@ -792,6 +793,7 @@ build-qemu-flatcar: ## Builds Flatcar QEMU image build-qemu-ubuntu-2004: ## Builds Ubuntu 20.04 QEMU image build-qemu-ubuntu-2004-efi: ## Builds Ubuntu 20.04 QEMU image that EFI boots build-qemu-ubuntu-2204: ## Builds Ubuntu 22.04 QEMU image +build-qemu-ubuntu-2204-cloudimg: ## Builds Ubuntu 22.04 QEMU image using cloud image build-qemu-ubuntu-2204-efi: ## Builds Ubuntu 22.04 QEMU image that EFI boots build-qemu-ubuntu-2304: ## Builds Ubuntu 23.04 QEMU image build-qemu-centos-7: ## Builds CentOS 7 QEMU image @@ -799,7 +801,9 @@ build-qemu-centos-9: ## Builds CentOS 9 Stream QEMU image build-qemu-rhel-8: ## Builds RHEL 8 QEMU image build-qemu-rhel-9: ## Builds RHEL 9 QEMU image build-qemu-rockylinux-8: ## Builds Rocky 8 QEMU image +build-qemu-rockylinux-8-cloudimg: ## Builds Rocky 8 QEMU image using cloud image build-qemu-rockylinux-9: ## Builds Rocky 9 QEMU image +build-qemu-rockylinux-9-cloudimg: ## Builds Rocky 9 QEMU image using cloud image build-qemu-all: $(QEMU_BUILD_TARGETS) ## Builds all Qemu images build-raw-flatcar: ## Builds Flatcar RAW image @@ -959,13 +963,16 @@ validate-qemu-flatcar: ## Validates Flatcar QEMU image packer config validate-qemu-ubuntu-2004: ## Validates Ubuntu 20.04 QEMU image packer config validate-qemu-ubuntu-2004-efi: ## Validates Ubuntu 20.04 QEMU EFI image packer config validate-qemu-ubuntu-2204: ## Validates Ubuntu 22.04 QEMU image packer config +validate-qemu-ubuntu-2204-cloudimg: ## Validates Ubuntu 22.04 QEMU image packer config using cloud image validate-qemu-ubuntu-2204-efi: ## Validates Ubuntu 22.04 QEMU EFI image packer config validate-qemu-ubuntu-2304: ## Validates Ubuntu 23.04 QEMU image packer config validate-qemu-centos-7: ## Validates CentOS 7 QEMU image packer config validate-qemu-rhel-8: ## Validates RHEL 8 QEMU image validate-qemu-rhel-9: ## Validates RHEL 9 QEMU image validate-qemu-rockylinux-8: ## Validates Rocky Linux 8 QEMU image packer config +validate-qemu-rockylinux-8-cloudimg: ## Validates Rocky Linux 8 QEMU image packer config using cloud image validate-qemu-rockylinux-9: ## Validates Rocky Linux 9 QEMU image packer config +validate-qemu-rockylinux-9-cloudimg: ## Validates Rocky Linux 9 QEMU image packer config using cloud image validate-qemu-all: $(QEMU_VALIDATE_TARGETS) ## Validates all Qemu Packer config validate-raw-flatcar: ## Validates Flatcar RAW image packer config diff --git a/images/capi/ansible/firstboot.yml b/images/capi/ansible/firstboot.yml index 093937e68..779383808 100644 --- a/images/capi/ansible/firstboot.yml +++ b/images/capi/ansible/firstboot.yml @@ -12,6 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. --- +- name: Bootstrap Python + hosts: all + become: true + gather_facts: false + tasks: + - name: Check if Python is installed + changed_when: false + failed_when: false + ansible.builtin.raw: test -e "{{ ansible_python_interpreter | default('/usr/bin/python3') }}" + register: python_installed + + - name: Install Python + changed_when: true + ansible.builtin.raw: test -e /usr/bin/apt && (apt-get update && apt-get install -y python3) || (yum install -y python3) + when: python_installed.rc != 0 + - hosts: all become: true vars: diff --git a/images/capi/packer/qemu/cloud-init/meta-data b/images/capi/packer/qemu/cloud-init/meta-data new file mode 100644 index 000000000..e69de29bb diff --git a/images/capi/packer/qemu/cloud-init/user-data b/images/capi/packer/qemu/cloud-init/user-data new file mode 100644 index 000000000..0df503993 --- /dev/null +++ b/images/capi/packer/qemu/cloud-init/user-data @@ -0,0 +1,9 @@ +#cloud-config +ssh_pwauth: true +users: + - name: builder + passwd: $6$xyz$UtXVazU08Q5b8AW.TJ3MPYZglyXa3Ttf2RCel8MCUPlEYO1evWxeWBhZ2QqivU/Ij4tqYAxMCqc2ujEM4dMSe1 + groups: [adm, cdrom, dip, plugdev, lxd, sudo] + lock-passwd: false + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash diff --git a/images/capi/packer/qemu/packer.json b/images/capi/packer/qemu/packer.json index 8c201c17d..c7ce98de2 100644 --- a/images/capi/packer/qemu/packer.json +++ b/images/capi/packer/qemu/packer.json @@ -8,10 +8,15 @@ "{{user `boot_command_suffix`}}" ], "boot_wait": "{{user `boot_wait`}}", + "cd_files": [ + "{{user `cd_files`}}" + ], + "cd_label": "cidata", "cpu_model": "host", "cpus": "{{user `cpus`}}", "disk_compression": "{{ user `disk_compression`}}", "disk_discard": "{{user `disk_discard`}}", + "disk_image": "{{ user `disk_image` }}", "disk_interface": "virtio-scsi", "disk_size": "{{user `disk_size`}}", "firmware": "{{user `firmware`}}", @@ -156,6 +161,7 @@ "boot_media_path": "http://{{ .HTTPIP }}:{{ .HTTPPort }}", "boot_wait": "10s", "build_timestamp": "{{timestamp}}", + "cd_files": "linux/base/*.nothing", "containerd_sha256": null, "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz", "containerd_version": null, @@ -164,6 +170,7 @@ "crictl_version": null, "disk_compression": "false", "disk_discard": "unmap", + "disk_image": "false", "disk_size": "20480", "existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}", "firmware": "", diff --git a/images/capi/packer/qemu/qemu-rockylinux-8-cloudimg.json b/images/capi/packer/qemu/qemu-rockylinux-8-cloudimg.json new file mode 100644 index 000000000..8c204d7a7 --- /dev/null +++ b/images/capi/packer/qemu/qemu-rockylinux-8-cloudimg.json @@ -0,0 +1,17 @@ +{ + "build_name": "rockylinux-8", + "cd_files": "./packer/qemu/cloud-init/*", + "disk_image": "true", + "distribution_version": "8", + "distro_arch": "amd64", + "distro_name": "rockylinux", + "distro_version": "8", + "epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8", + "guest_os_type": "centos8-64", + "iso_checksum": "https://dl.rockylinux.org/pub/rocky/8/images/x86_64/CHECKSUM", + "iso_checksum_type": "file", + "iso_url": "https://dl.rockylinux.org/pub/rocky/8/images/x86_64/Rocky-8-GenericCloud-Base.latest.x86_64.qcow2", + "os_display_name": "RockyLinux 8", + "redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm", + "shutdown_command": "/sbin/halt -h -p" +} diff --git a/images/capi/packer/qemu/qemu-rockylinux-9-cloudimg.json b/images/capi/packer/qemu/qemu-rockylinux-9-cloudimg.json new file mode 100644 index 000000000..0d6e9fde5 --- /dev/null +++ b/images/capi/packer/qemu/qemu-rockylinux-9-cloudimg.json @@ -0,0 +1,17 @@ +{ + "build_name": "rockylinux-9", + "cd_files": "./packer/qemu/cloud-init/*", + "disk_image": "true", + "distribution_version": "9", + "distro_arch": "amd64", + "distro_name": "rockylinux", + "distro_version": "9", + "epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-9", + "guest_os_type": "centos9-64", + "iso_checksum": "https://dl.rockylinux.org/pub/rocky/9/images/x86_64/CHECKSUM", + "iso_checksum_type": "file", + "iso_url": "https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2", + "os_display_name": "RockyLinux 9", + "redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm", + "shutdown_command": "/sbin/halt -h -p" +} diff --git a/images/capi/packer/qemu/qemu-ubuntu-2204-cloudimg.json b/images/capi/packer/qemu/qemu-ubuntu-2204-cloudimg.json new file mode 100644 index 000000000..aa5f5ecc7 --- /dev/null +++ b/images/capi/packer/qemu/qemu-ubuntu-2204-cloudimg.json @@ -0,0 +1,13 @@ +{ + "build_name": "ubuntu-2204", + "cd_files": "./packer/qemu/cloud-init/*", + "disk_image": "true", + "distribution_version": "2204", + "distro_name": "ubuntu", + "guest_os_type": "ubuntu-64", + "iso_checksum": "https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS", + "iso_checksum_type": "file", + "iso_url": "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img", + "os_display_name": "Ubuntu 22.04", + "shutdown_command": "shutdown -P now" +}