-
Notifications
You must be signed in to change notification settings - Fork 0
/
alpine-3.19.pkr.hcl
77 lines (70 loc) · 2.05 KB
/
alpine-3.19.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
source "qemu" "alpine319" {
iso_url = "https://mirrors.edge.kernel.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.4-x86_64.iso"
iso_checksum = "file:https://mirrors.edge.kernel.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.4-x86_64.iso.sha256"
vga = "virtio"
cpus = 2
memory = 4096
headless = var.headless
shutdown_command = "/sbin/poweroff"
qmp_enable = true
disk_discard = "unmap"
http_content = {
"/alpine-answer.sh" = templatefile("${path.root}/alpine-answer.sh", { path = path, hostname = "alpine319" })
"/vagrant.pub" = file("${path.root}/keys/vagrant.pub")
}
ssh_handshake_attempts = 1000
ssh_timeout = "10m"
ssh_username = "root"
ssh_private_key_file = "${path.root}/keys/vagrant"
boot_wait = "1m"
boot_keygroup_interval = "1s"
boot_command = [
"<enter><wait10>",
"root<enter><wait10>",
"setup-interfaces -a -r && ",
"setup-sshd -k 'http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.pub' openssh<enter>",
]
}
build {
sources = [
"source.qemu.alpine319"
]
provisioner "shell" {
inline = [
"setup-alpine -e -f 'http://${build.PackerHTTPAddr}/alpine-answer.sh'",
]
env = {
"ERASE_DISKS" = "/dev/vda"
}
}
provisioner "shell" {
inline = ["reboot"]
expect_disconnect = true
pause_after = "1m"
}
provisioner "shell" {
start_retry_timeout = "10m"
inline = [
"setup-xorg-base",
"setup-desktop gnome",
"apk add qemu-guest-agent spice-vdagent spice-webdavd rsync",
"rc-update add qemu-guest-agent",
"rc-update add spice-vdagentd",
"rc-update add spice-webdavd",
"usermod -p '${bcrypt("vagrant")}' vagrant",
"usermod -p '${bcrypt("vagrant")}' root",
"echo 'permit nopass :vagrant' >/etc/doas.d/vagrant.conf",
"rm -rf /var/cache/apk/*",
]
}
post-processors {
post-processor "vagrant" {
keep_input_artifact = true
vagrantfile_template = "Vagrantfile"
}
post-processor "vagrant-registry" {
box_tag = "gnome-shell-box/alpine319"
version = var.version
}
}
}