diff options
Diffstat (limited to 'openbsd.pkr.hcl')
| -rw-r--r-- | openbsd.pkr.hcl | 72 |
1 files changed, 51 insertions, 21 deletions
diff --git a/openbsd.pkr.hcl b/openbsd.pkr.hcl index 80cae35..893439a 100644 --- a/openbsd.pkr.hcl +++ b/openbsd.pkr.hcl @@ -12,11 +12,6 @@ variable "version" { } } -variable "admin_user" { - type = string - description = "Username of the admin user on the VM" -} - variable "ssh_public_key" { type = string description = "Public SSH key to associate with the admin user for login" @@ -29,24 +24,16 @@ variable "ssh_private_key_file" { variable "arch" { type = string - default = "arm64" validation { - condition = contains(["arm64"], var.arch) - error_message = "The arch must be one of: arm64." + condition = contains(["amd64", "arm64"], var.arch) + error_message = "The arch must be one of: amd64, arm64." } } -variable "accelerator" { +variable "admin_user" { type = string - default = "hvf" - description = <<-EOT - The accelerator type to use when running the VM. See the following for more information: - https://developer.hashicorp.com/packer/integrations/hashicorp/qemu/latest/components/builder/qemu#optional - EOT - validation { - condition = contains(["none", "kvm", "tcg", "hax", "hvf", "whpx", "xen"], var.accelerator) - error_message = "Must be one of: 'none', 'kvm', 'tcg', 'hax', 'hvf', 'whpx', 'xen'." - } + description = "Username of the admin user on the VM" + default = "admin" } variable "mirror" { @@ -82,7 +69,50 @@ locals { root_password = "temp" } -source "qemu" "openbsd" { +source "qemu" "openbsd-amd64" { + vm_name = "openbsd-${var.version}-amd64.qcow2" + iso_url = "${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/install${local.version_short}.iso" + iso_checksum = "file:${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/SHA256" + output_directory = "build" + qemu_binary = "qemu-system-x86_64" + machine_type = "q35" + cpu_model = "max" + accelerator = "tcg" + memory = var.memory + disk_interface = "virtio" + disk_size = "${var.disk_size}G" + disk_compression = true + format = "qcow2" + ssh_username = "root" + ssh_password = local.root_password + ssh_timeout = "30m" + + http_content = { + "/install.conf" = templatefile("${path.root}/templates/install.conf.pkrtpl.hcl", { + hostname = var.hostname + user = var.admin_user + ssh_key = var.ssh_public_key + root_password = local.root_password + mirror = var.mirror + version = var.version + version_short = local.version_short + arch = var.arch + }) + } + + boot_command = [ + "<wait>S<enter><wait>", + "set tty com0<enter><wait>", + "autoinstall<enter><wait>", + "http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.conf<enter>", + ] + boot_wait = "20s" + shutdown_command = "shutdown -p now" + headless = false + qemuargs = [["-display", "cocoa"]] +} + +source "qemu" "openbsd-arm64" { vm_name = "openbsd-${var.version}-aarch64.qcow2" iso_url = "${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/install${local.version_short}.iso" iso_checksum = "file:${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/SHA256" @@ -90,7 +120,7 @@ source "qemu" "openbsd" { qemu_binary = "qemu-system-aarch64" machine_type = "virt" cpu_model = "host" - accelerator = "hvf" + accelerator = "hvf" memory = var.memory disk_interface = "virtio" disk_size = "${var.disk_size}G" @@ -134,7 +164,7 @@ source "qemu" "openbsd" { } build { - sources = ["source.qemu.openbsd"] + sources = ["source.qemu.openbsd-amd64", "source.qemu.openbsd-arm64"] provisioner "file" { source = "configs/doas.conf" |