feat: Add Packer build automation scripts
Some checks are pending
Build and Release / build-sign-package (push) Waiting to run

- Added packer/variables.pkr.hcl with configurable variables
- Added build-template.sh with interactive build script
- Added .env.example for environment configuration
- Updated windows.pkr.hcl to use variables
- Supports environment variables and command line arguments
This commit is contained in:
root 2026-02-06 16:01:52 +00:00
parent e4f03427b7
commit 61ae0d0a07
4 changed files with 315 additions and 17 deletions

79
packer/variables.pkr.hcl Normal file
View file

@ -0,0 +1,79 @@
variable "proxmox_url" {
type = string
default = "https://la-vmh-07:8006/api2/json"
description = "Proxmox API URL"
}
variable "proxmox_username" {
type = string
default = "root@pam"
description = "Proxmox authentication user"
}
variable "proxmox_password" {
type = string
default = ""
description = "Proxmox password (set via PKR_VAR_proxmox_password env var)"
sensitive = true
}
variable "proxmox_node" {
type = string
default = "la-vmh-07"
description = "Proxmox node name"
}
variable "vm_name" {
type = string
default = "win11-ltsc-template"
description = "Name of the template VM"
}
variable "vm_memory" {
type = number
default = 8192
description = "VM memory in MB"
}
variable "vm_cores" {
type = number
default = 4
description = "Number of CPU cores"
}
variable "vm_disk_size" {
type = string
default = "60G"
description = "Disk size"
}
variable "iso_storage" {
type = string
default = "local"
description = "Proxmox storage for ISOs"
}
variable "windows_iso" {
type = string
default = "CLIENT_LTSC_EVAL_x64FRE_en-us.iso"
description = "Windows ISO filename"
}
variable "disk_storage" {
type = string
default = "local-lvm"
description = "Proxmox storage for disks"
}
variable "virtio_iso" {
type = string
default = "local:iso/virtio-win.iso"
description = "Path to VirtIO ISO"
}
variable "winrm_password" {
type = string
default = "PackerPassword123!"
description = "Windows Administrator password for WinRM"
sensitive = true
}

View file

@ -8,51 +8,52 @@ packer {
}
source "proxmox-iso" "windows-11" {
proxmox_url = "https://proxmox-host:8006/api2/json"
username = "root@pam"
password = "secret"
node = "la-vmh-07"
proxmox_url = "${var.proxmox_url}"
username = "${var.proxmox_username}"
password = "${var.proxmox_password}"
node = "${var.proxmox_node}"
vm_name = "win11-ltsc-template"
vm_name = "${var.vm_name}"
template_description = "Built with Packer on ${timestamp()}"
iso_file = "local:iso/CLIENT_LTSC_EVAL_x64FRE_en-us.iso"
iso_file = "${var.iso_storage}:iso/${var.windows_iso}"
qemu_agent = true
cores = 4
memory = 8192
cores = "${var.vm_cores}"
memory = "${var.vm_memory}"
machine = "q35"
bios = "ovmf"
efi_config {
efi_storage_pool = "local-lvm"
efi_storage_pool = "${var.disk_storage}"
pre_enrolled_keys = true
}
tpm_config {
version = "2.0"
tpm_storage_pool = "local-lvm"
tpm_storage_pool = "${var.disk_storage}"
}
scsi_controller = "virtio-scsi-pci"
disks {
disk_size = "60G"
storage_pool = "local-lvm"
disk_size = "${var.vm_disk_size}"
storage_pool = "${var.disk_storage}"
type = "virtio"
format = "raw"
cache_mode = "writeback"
}
additional_iso_files {
device = "sata1"
iso_file = "local:iso/virtio-win.iso"
device = "sata1"
iso_file = "${var.virtio_iso}"
}
communicator = "winrm"
winrm_username = "Administrator"
winrm_password = "PackerPassword123!"
winrm_password = "${var.winrm_password}"
winrm_insecure = true
winrm_use_ssl = true
boot_command = [
"<wait><wait><wait>","<enter><wait>","<enter><wait>",
"<enter><wait>","<enter>"
"<wait><wait><wait>", "<enter><wait>", "<enter><wait>",
"<enter><wait>", "<enter>"
]
boot_wait = "10s"
}