-
Notifications
You must be signed in to change notification settings - Fork 0
/
sources.pkr.hcl
52 lines (45 loc) · 1.54 KB
/
sources.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
source "null" "post" {
communicator = "none"
}
source "qemu" "kvm" {
use_backing_file = false
headless = true
disk_image = true
ssh_timeout = "120s"
disk_compression = true
output_directory = "output/${var.target}"
ssh_private_key_file = "/tmp/packer/id_${var.target}"
vm_name = "packer-kvm.img"
# when building in parallel, a global lock is used to prevent race conditions when downloading
iso_url = var.image_repository[var.image.base].url
iso_checksum = var.image_repository[var.image.base].digest
ssh_username = var.image.user
ssh_password = null
shutdown_command = var.image.shutdown_command
# local VM resources
disk_size = var.local_vm_settings.virtual_disk_size
disk_cache = var.local_vm_settings.cache
format = var.local_vm_settings.output_format
memory = var.local_vm_settings.memory
net_device = var.local_vm_settings.net_device
disk_interface = var.local_vm_settings.disk_interface
# to my knowledge, this cloud-init config is distro agnostic
http_content = {
"/user-data" = join("\n", ["#cloud-config", yamlencode({
"users" = [
{
"name" : var.image.user
"ssh_authorized_keys" : [
file("/tmp/packer/id_${var.target}.pub")
]
}
]
})])
"/meta-data" = yamlencode({
instance-id = uuidv5("url", var.image_repository[var.image.base].url)
})
}
qemuargs = [
["-smbios", "type=1,serial=ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"]
]
}