packer-proxmox/rocky-9/server.pkr.hcl
Renovator Bot 5cdafb5336
All checks were successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
chore(deps): update dependency hashicorp/packer-plugin-proxmox to v1.1.7 (#5)
Reviewed-on: #5
Co-authored-by: Renovator Bot <renovator@rknet.org>
Co-committed-by: Renovator Bot <renovator@rknet.org>
2024-01-26 14:26:19 +01:00

94 lines
2.7 KiB
HCL

packer {
required_version = ">= 1.8.3"
required_plugins {
proxmox = {
version = "1.1.7"
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", {
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")
})
}
data_source_command = "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg"
}
source "proxmox-iso" "rocky-linux-9" {
// Proxmox Settings
proxmox_url = "${var.proxmox_url}"
node = "${var.proxmox_node}"
username = "${var.proxmox_username}"
token = "${var.proxmox_token}"
// 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}"
cloud_init = "${var.vm_cloud_init}"
cloud_init_storage_pool = "${var.vm_cloud_init_storage_pool}"
qemu_agent = "${var.vm_qemu_agent}"
network_adapters {
bridge = "${var.vm_network_adapter_bridge}"
model = "${var.vm_network_adapter_model}"
vlan_tag = "${var.vm_network_adapter_vlan_tag}"
}
disks {
disk_size = "${var.vm_disk_size}"
format = "${var.proxmox_storage_format}"
storage_pool = "${var.proxmox_storage_pool}"
type = "scsi"
io_thread = false
discard = true
}
scsi_controller = "virtio-scsi-pci"
// Removable Media Settings
iso_file = "${var.proxmox_iso_pool}/${var.proxmox_iso_file}"
http_content = "${local.data_source_content}"
http_interface = "${var.http_interface}"
// Boot and Provisioning Settings
boot_wait = "10s"
boot_command = [
"up",
"<tab><wait>",
" ${local.data_source_command}<wait><enter>"
]
// Communicator Settings and Credentials
communicator = "ssh"
ssh_username = "root"
ssh_password = "${var.build_password}"
ssh_timeout = "${var.communicator_timeout}"
template_description = "${var.proxmox_template_description} on ${local.buildtime}"
template_name = "${var.proxmox_template_name}"
unmount_iso = true
}
build {
sources = ["source.proxmox-iso.rocky-linux-9"]
provisioner "shell" {
scripts = formatlist("${path.cwd}/%s", var.build_scripts)
remote_folder = "/root"
}
}