From 75892026b595f8c5b6b59cf8cafee8d2a54e10f7 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Wed, 23 Sep 2026 15:11:58 -0700 Subject: Fix SSH key and use multiple cpus during the build The SSH key variable being referenced was incorrect, so we had a syntax error. Furthermore, we need to use multiple CPUs during the image build since if we only use 1 CPU, OpenBSD will use the GENERIC kernel rather than the GENERIC.MP kernel, which means we'll only be able to use 1 CPU. --- build-hcloud-snapshot.sh | 12 ++++-------- openbsd-image/openbsd-amd64.pkr.hcl | 4 ++-- openbsd-image/openbsd-arm64.pkr.hcl | 4 ++-- openbsd-image/variables.pkr.hcl | 8 +++++++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/build-hcloud-snapshot.sh b/build-hcloud-snapshot.sh index 40f3dcb..00ec32d 100755 --- a/build-hcloud-snapshot.sh +++ b/build-hcloud-snapshot.sh @@ -16,7 +16,7 @@ SCRIPTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) VERSION=7.9 ARCH=amd64 -PUBLIC_SSH_KEY="$HOME/.ssh/id_rsa.pub" +SSH_KEY="default-key" main() ( parse_args "$@" @@ -29,7 +29,7 @@ main() ( -var "image_path=${img_path}.zst" \ -var "version=$VERSION" \ -var "arch=$ARCH" \ - -var "ssh_key=$(get_ssh_key_name "$PUBLIC_SSH_KEY")" \ + -var "ssh_key=$SSH_KEY" \ . ) @@ -44,8 +44,8 @@ parse_args() { ARCH="$2" shift 2 ;; - --public-ssh-key) - PUBLIC_SSH_KEY="$2" + --ssh-key) + SSH_KEY="$2" shift 2 ;; *) @@ -62,8 +62,4 @@ build_compressed_image() ( fi ) -get_ssh_key_name() { - awk '{print $3}' "$1" -} - main "$@" diff --git a/openbsd-image/openbsd-amd64.pkr.hcl b/openbsd-image/openbsd-amd64.pkr.hcl index 5d2c9f7..2fef98b 100644 --- a/openbsd-image/openbsd-amd64.pkr.hcl +++ b/openbsd-image/openbsd-amd64.pkr.hcl @@ -7,6 +7,7 @@ source "qemu" "openbsd-amd64" { machine_type = "q35" cpu_model = "max" accelerator = "tcg" + cpus = var.cpus memory = var.memory disk_interface = "virtio" disk_size = "${var.disk_size}G" @@ -20,7 +21,7 @@ source "qemu" "openbsd-amd64" { "/install.conf" = templatefile("${path.root}/templates/install.conf.pkrtpl.hcl", { hostname = var.hostname user = var.admin_user - ssh_key = var.ssh_public_key + ssh_key = var.ssh_key root_password = local.root_password mirror = var.mirror version = var.version @@ -31,7 +32,6 @@ source "qemu" "openbsd-amd64" { boot_command = [ "S", - "set tty com0", "autoinstall", "http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.conf", ] diff --git a/openbsd-image/openbsd-arm64.pkr.hcl b/openbsd-image/openbsd-arm64.pkr.hcl index dbe5833..a304426 100644 --- a/openbsd-image/openbsd-arm64.pkr.hcl +++ b/openbsd-image/openbsd-arm64.pkr.hcl @@ -7,6 +7,7 @@ source "qemu" "openbsd-arm64" { machine_type = "virt" cpu_model = "host" accelerator = "hvf" + cpus = var.cpus memory = var.memory disk_interface = "virtio" disk_size = "${var.disk_size}G" @@ -20,7 +21,7 @@ source "qemu" "openbsd-arm64" { "/install.conf" = templatefile("${path.root}/templates/install.conf.pkrtpl.hcl", { hostname = var.hostname user = var.admin_user - ssh_key = var.ssh_public_key + ssh_key = var.ssh_key root_password = local.root_password mirror = var.mirror version = var.version @@ -31,7 +32,6 @@ source "qemu" "openbsd-arm64" { boot_command = [ "S", - "set tty com0", "autoinstall", "http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.conf", ] diff --git a/openbsd-image/variables.pkr.hcl b/openbsd-image/variables.pkr.hcl index 4bc0860..e8340a9 100644 --- a/openbsd-image/variables.pkr.hcl +++ b/openbsd-image/variables.pkr.hcl @@ -21,7 +21,7 @@ variable "admin_user" { default = "admin" } -variable "ssh_public_key" { +variable "ssh_key" { type = string description = "Public SSH key to associate with the admin user for login" } @@ -42,6 +42,12 @@ variable "hostname" { default = "openbsd-vm" } +variable "cpus" { + type = number + description = "CPUs to allocate to the VM while building the ISO" + default = 2 +} + variable "memory" { type = number description = "Memory to allocate to the VM in MB while building the ISO" -- cgit v1.2.3