-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-qemu.archlinux.pkr.hcl
85 lines (76 loc) · 2.09 KB
/
build-qemu.archlinux.pkr.hcl
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
locals {
image_full_name = "${var.image_name}-${formatdate("YYMMDD", timestamp())}.qcow2"
}
variable "image_name" {
type = string
default = "archlinux"
}
variable "cpus" {
type = number
default = 2
}
variable "memory" {
type = number
default = 1024
}
variable "disk_size" {
type = string
default = "32G"
}
variable "headless" {
type = bool
default = true
}
variable "iso_checksum" {
type = string
}
variable "iso_url" {
type = string
}
source "qemu" "archlinux" {
boot_command = [
"<wait10><enter>",
"<wait10><wait10><wait10><wait10><wait10><wait10>",
"<enter><wait>",
"curl -sfSLO http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter><wait>",
"curl -sfSLO http://{{ .HTTPIP }}:{{ .HTTPPort }}/partition.sh<enter><wait>",
"curl -sfSLO http://{{ .HTTPIP }}:{{ .HTTPPort }}/install-chroot.sh<enter><wait>",
"curl -sfSLO http://{{ .HTTPIP }}:{{ .HTTPPort }}/packer.sh<enter><wait>",
"chmod +x *.sh<enter>",
"./install.sh<enter>"
]
boot_wait = "10s"
cpus = "${var.cpus}"
memory = "${var.memory}"
disk_size = "${var.disk_size}"
headless = "${var.headless}"
http_directory = "./http"
iso_checksum = "${var.iso_checksum}"
iso_url = "${var.iso_url}"
output_directory = "./packer_builds"
shutdown_command = "sudo systemctl poweroff"
ssh_port = 22
ssh_timeout = "3600s"
ssh_username = "root"
ssh_password = "secret"
vm_name = "${local.image_full_name}"
accelerator = "kvm"
format = "qcow2"
efi_boot = true
efi_firmware_code = "/usr/share/OVMF/x64/OVMF_CODE.fd"
efi_firmware_vars = "/usr/share/OVMF/x64/OVMF_VARS.fd"
}
build {
sources = ["source.qemu.archlinux"]
post-processor "checksum" {
checksum_types = [
"sha256"
]
keep_input_artifact = false
output = "./packer_builds/${local.image_full_name}.sha256"
}
post-processor "compress" {
compression_level = 9
output = "./packer_builds/${local.image_full_name}.tar.gz"
}
}