aboutsummaryrefslogtreecommitdiffstats
path: root/openbsd-image/openbsd-amd64.pkr.hcl
blob: 2fef98b95fb56c82e04e5dc23e333516802e0f6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
source "qemu" "openbsd-amd64" {
  vm_name              = "openbsd-${var.version}-amd64.raw"
  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"
  cpus                 = var.cpus
  memory               = var.memory
  disk_interface       = "virtio"
  disk_size            = "${var.disk_size}G"
  disk_compression     = true
  format               = "raw"
  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_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>",
    "autoinstall<enter><wait>",
    "http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.conf<enter>",
  ]
  boot_wait           = "20s"
  shutdown_command    = "shutdown -p now"
  headless            = false
  qemuargs            = [["-display", "cocoa"]]
}