-
Notifications
You must be signed in to change notification settings - Fork 5
/
libvirt.pkr.hcl
77 lines (65 loc) · 1.96 KB
/
libvirt.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
variable "box_tag" {
type = string
default = "${env("REPOSITORY")}"
}
variable "cloud_token" {
type = string
default = "${env("VAGRANT_CLOUD_TOKEN")}"
}
variable "name" {
type = string
default = "${env("BOX_NAME")}"
}
variable "version" {
type = string
default = "${env("VERSION")}"
}
source "qemu" "libvirt" {
accelerator = "kvm"
boot_wait = "20s"
cpus = 2
disk_detect_zeroes = "unmap"
disk_discard = "unmap"
disk_image = true
disk_interface = "virtio-scsi"
disk_size = 5120
format = "qcow2"
headless = false
iso_checksum = "none"
iso_url = "media/clear-${var.version}-libvirt-factory.img"
memory = 2048
net_device = "virtio-net"
output_directory = "boxes/tmp"
qemuargs = [["-bios", "/usr/share/qemu/OVMF.fd"]]
shutdown_command = "sudo fstrim -a -v && sudo sync && sudo shutdown -P now"
ssh_password = "V@grant!"
ssh_port = 22
ssh_timeout = "5m"
ssh_username = "clear"
use_default_display = true
vm_name = "${var.name}"
}
build {
sources = ["source.qemu.libvirt"]
provisioner "shell" {
inline = ["sudo timedatectl set-ntp true"]
}
provisioner "shell" {
expect_disconnect = true
inline = ["echo 'rebooting...'", "sudo systemctl reboot"]
}
provisioner "shell" {
start_retry_timeout = "600s"
inline = ["uname -a; swupd info"]
}
post-processor "vagrant" {
compression_level = 9
include = ["info.json"]
output = "boxes/{{ .Provider }}/${var.name}-${var.version}.{{ .Provider }}.box"
vagrantfile_template = "Vagrantfile.template.rb"
}
post-processor "checksum" {
checksum_types = ["sha1", "sha256"]
output = "boxes/{{ .BuildName }}/${var.name}-${var.version}.{{.BuildName}}.box.{{.ChecksumType}}.checksum"
}
}