Skip to content

Commit

Permalink
Add aarch64 centos-stream-9 harness
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorific committed Jun 23, 2024
1 parent 3478099 commit 94d22b1
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
11 changes: 11 additions & 0 deletions centos/cloud/aarch64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CentOS Cloud Images

## CentOS Stream 9 UEFI virtual firmware

```
cd centos/cloud/aarch64
packer init .
PACKER_LOG=1 packer build \
-var-file centos-stream-9-aarch64.pkrvars.hcl \
centos.pkr.hcl
```
3 changes: 3 additions & 0 deletions centos/cloud/aarch64/centos-stream-9-aarch64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
iso_checksum = "file:https://cloud.centos.org/centos/9-stream/aarch64/images/CentOS-Stream-GenericCloud-9-latest.aarch64.qcow2.SHA256SUM"
iso_url = "https://cloud.centos.org/centos/9-stream/aarch64/images/CentOS-Stream-GenericCloud-9-latest.aarch64.qcow2"
vm_name = "centos-stream-9-aarch64"
102 changes: 102 additions & 0 deletions centos/cloud/aarch64/centos.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
packer {
required_plugins {
qemu = {
version = "~> 1"
source = "github.com/hashicorp/qemu"
}
}
}

variable "ssh_username" {
type = string
default = "packer"
}

variable "ssh_password" {
type = string
default = "packer"
}

variable "vm_name" {
type = string
default = "centos-stream-9-aarch64"
}

source "file" "user_data" {
content = <<EOF
#cloud-config
user: ${var.ssh_username}
password: ${var.ssh_password}
chpasswd: { expire: False }
ssh_pwauth: True
EOF
target = "boot-${var.vm_name}/user-data"
}

source "file" "meta_data" {
content = <<EOF
instance-id: centos-cloud
local-hostname: centos-cloud
EOF
target = "boot-${var.vm_name}/meta-data"
}

build {
sources = ["sources.file.user_data", "sources.file.meta_data"]

provisioner "shell-local" {
inline = ["genisoimage -output boot-${var.vm_name}/cidata.iso -input-charset utf-8 -volid cidata -joliet -r boot-${var.vm_name}/user-data boot-${var.vm_name}/meta-data"]
}
}

variable "iso_checksum" {
type = string
default = "file:https://cloud.centos.org/centos/9-stream/aarch64/images/CentOS-Stream-GenericCloud-9-latest.aarch64.qcow2.SHA256SUM"
}

variable "iso_url" {
type = string
default = "https://cloud.centos.org/centos/9-stream/aarch64/images/CentOS-Stream-GenericCloud-9-latest.aarch64.qcow2"
}

source "qemu" "centos" {
disk_compression = true
disk_image = true
disk_size = "30G"
format = "qcow2"
iso_checksum = var.iso_checksum
iso_url = var.iso_url
machine_type = "virt,gic-version=max"
net_device = "virtio-net"
disk_interface = "virtio"
qemu_binary = "qemu-system-aarch64"
qemuargs = [
["-cdrom", "boot-${var.vm_name}/cidata.iso"],
["-cpu", "max"],
["-boot", "strict=on"],
["-monitor", "none"],
/* ["-device", "virtio-gpu-pci"], */
]
output_directory = "output-${var.vm_name}"
shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now"
ssh_password = var.ssh_password
ssh_timeout = "120s"
ssh_username = var.ssh_username
vm_name = "${var.vm_name}.qcow2"
efi_boot = true
efi_firmware_code = "/usr/share/AAVMF/AAVMF_CODE.fd"
efi_firmware_vars = "/usr/share/AAVMF/AAVMF_VARS.fd"
}

build {
sources = ["source.qemu.centos"]

# cloud-init may still be running when we start executing scripts
# To avoid race conditions, make sure cloud-init is done first
provisioner "shell" {
execute_command = "echo '${var.ssh_password}' | {{ .Vars }} sudo -S -E sh -eux '{{ .Path }}'"
scripts = [
"../scripts/cloud-init-wait.sh",
]
}
}

0 comments on commit 94d22b1

Please sign in to comment.