2022-08-06 20:17:14 +00:00
|
|
|
packer {
|
|
|
|
required_version = ">= 1.8.3"
|
|
|
|
required_plugins {
|
|
|
|
proxmox = {
|
2024-05-15 06:28:46 +00:00
|
|
|
version = "1.1.8"
|
2022-08-06 20:17:14 +00:00
|
|
|
source = "github.com/hashicorp/proxmox"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
locals {
|
|
|
|
buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp())
|
|
|
|
data_source_content = {
|
|
|
|
"/ks.cfg" = templatefile("${abspath(path.root)}/data/init.ks.pkrtpl.hcl", {
|
2022-09-09 08:29:00 +00:00
|
|
|
build_password_encrypted = var.build_password_encrypted
|
|
|
|
vm_guest_os_language = var.vm_guest_os_language
|
|
|
|
vm_guest_os_keyboard = var.vm_guest_os_keyboard
|
|
|
|
vm_guest_os_timezone = var.vm_guest_os_timezone
|
|
|
|
files_proxmox_default_init = file("${abspath(path.root)}/data/files/90-proxmox.cfg")
|
|
|
|
files_proxmox_init = file("${abspath(path.root)}/data/files/93-proxmox.cfg")
|
2022-08-06 20:17:14 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
data_source_command = "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg"
|
|
|
|
}
|
|
|
|
|
2022-09-09 08:29:00 +00:00
|
|
|
source "proxmox-iso" "rocky-linux-9" {
|
2022-08-06 20:17:14 +00:00
|
|
|
// Proxmox Settings
|
|
|
|
proxmox_url = "${var.proxmox_url}"
|
|
|
|
node = "${var.proxmox_node}"
|
2022-09-09 08:29:00 +00:00
|
|
|
username = "${var.proxmox_username}"
|
2022-09-08 19:12:44 +00:00
|
|
|
token = "${var.proxmox_token}"
|
2022-08-06 20:17:14 +00:00
|
|
|
|
|
|
|
// Virtual Machine Settings
|
|
|
|
vm_id = "${var.vm_id}"
|
|
|
|
cores = "${var.vm_cpu_cores}"
|
|
|
|
sockets = "${var.vm_cpu_sockets}"
|
|
|
|
cpu_type = "${var.vm_cpu_type}"
|
|
|
|
memory = "${var.vm_mem_size}"
|
|
|
|
os = "${var.vm_os_type}"
|
2022-08-10 14:01:24 +00:00
|
|
|
|
|
|
|
cloud_init = "${var.vm_cloud_init}"
|
|
|
|
cloud_init_storage_pool = "${var.vm_cloud_init_storage_pool}"
|
|
|
|
qemu_agent = "${var.vm_qemu_agent}"
|
|
|
|
|
2022-08-06 20:17:14 +00:00
|
|
|
network_adapters {
|
|
|
|
bridge = "${var.vm_network_adapter_bridge}"
|
|
|
|
model = "${var.vm_network_adapter_model}"
|
|
|
|
vlan_tag = "${var.vm_network_adapter_vlan_tag}"
|
|
|
|
}
|
2022-08-10 14:01:24 +00:00
|
|
|
|
2022-08-06 20:17:14 +00:00
|
|
|
disks {
|
2024-01-14 19:58:18 +00:00
|
|
|
disk_size = "${var.vm_disk_size}"
|
|
|
|
format = "${var.proxmox_storage_format}"
|
|
|
|
storage_pool = "${var.proxmox_storage_pool}"
|
|
|
|
type = "scsi"
|
2024-01-17 19:46:30 +00:00
|
|
|
io_thread = false
|
|
|
|
discard = true
|
2022-08-06 20:17:14 +00:00
|
|
|
}
|
2022-08-10 14:01:24 +00:00
|
|
|
|
2022-08-06 20:17:14 +00:00
|
|
|
scsi_controller = "virtio-scsi-pci"
|
|
|
|
|
|
|
|
// Removable Media Settings
|
2024-01-14 19:58:18 +00:00
|
|
|
iso_file = "${var.proxmox_iso_pool}/${var.proxmox_iso_file}"
|
|
|
|
http_content = "${local.data_source_content}"
|
|
|
|
http_interface = "${var.http_interface}"
|
2022-08-06 20:17:14 +00:00
|
|
|
|
|
|
|
// Boot and Provisioning Settings
|
|
|
|
boot_wait = "10s"
|
|
|
|
boot_command = [
|
|
|
|
"up",
|
|
|
|
"<tab><wait>",
|
|
|
|
" ${local.data_source_command}<wait><enter>"
|
|
|
|
]
|
|
|
|
|
|
|
|
// Communicator Settings and Credentials
|
|
|
|
communicator = "ssh"
|
2022-09-09 08:29:00 +00:00
|
|
|
ssh_username = "root"
|
2022-08-06 20:17:14 +00:00
|
|
|
ssh_password = "${var.build_password}"
|
|
|
|
ssh_timeout = "${var.communicator_timeout}"
|
|
|
|
|
2022-09-09 08:29:00 +00:00
|
|
|
template_description = "${var.proxmox_template_description} on ${local.buildtime}"
|
|
|
|
template_name = "${var.proxmox_template_name}"
|
|
|
|
unmount_iso = true
|
2022-08-06 20:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
2022-09-09 08:29:00 +00:00
|
|
|
sources = ["source.proxmox-iso.rocky-linux-9"]
|
2022-08-06 20:17:14 +00:00
|
|
|
|
|
|
|
provisioner "shell" {
|
2022-09-09 08:29:00 +00:00
|
|
|
scripts = formatlist("${path.cwd}/%s", var.build_scripts)
|
|
|
|
remote_folder = "/root"
|
2022-08-06 20:17:14 +00:00
|
|
|
}
|
|
|
|
}
|