-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvm.rocky.x86_64.pkr.hcl
65 lines (57 loc) · 1.52 KB
/
vm.rocky.x86_64.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
# rocky-linux-packer.pkr.hcl
# Required Packer version
packer {
required_version = ">= 1.7.0"
required_plugins {
qemu = {
version = ">= 1.0.0"
source = "github.com/hashicorp/qemu"
}
}
}
variable "display" {
type = string
default = "none"
}
variable "output_directory" {
type = string
default = "./output/image-x86_64"
}
# Define the source image builder - for QEMU
source "qemu" "rocky_linux" {
iso_url = "https://download.rockylinux.org/pub/rocky/9.5/isos/x86_64/Rocky-9.5-x86_64-minimal.iso"
iso_checksum = "sha256:eedbdc2875c32c7f00e70fc861edef48587c7cbfd106885af80bdf434543820b"
qemu_binary = "qemu-system-x86_64"
output_directory = var.output_directory
http_directory = "."
disk_size = "40960"
memory = "2048"
cores = 8
cpu_model = "host" # if no KVM use "Haswell-v1"
ssh_port = 22
boot_wait = "1s"
ssh_password = "rocky"
ssh_username = "root"
ssh_timeout = "30m" # without KVM can be 10x slower
headless = false
shutdown_command = "/sbin/halt -h -p"
qemuargs = [
["-display", var.display], # "gtk" or "none"
["-machine", "type=pc,accel=kvm"], # "type=q35" if no KVM
]
boot_command = [
"<tab><bs><bs><bs><bs><bs>inst.text",
" inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/http/ks.cfg",
"<enter><wait>"
]
}
# Provision with an external shell script
build {
sources = ["source.qemu.rocky_linux"]
provisioner "shell" {
script = "install.sh"
}
provisioner "shell" {
script = "preset.sh"
}
}