This repository contains HashiCorp Packer configurations for building VM templates on Proxmox VE. It supports multiple Linux distributions with both BIOS and EFI boot configurations.
This Packer setup automates the creation of VM templates in Proxmox for various Linux distributions including:
- AlmaLinux (8, 9, 10)
- Rocky Linux (8, 9, 10)
- Red Hat Enterprise Linux (RHEL) (9, 10)
- Ubuntu (24.04)
- Debian (11, 12, 13)
Each distribution can be built with either BIOS or EFI boot configurations.
- HashiCorp Packer installed (version 1.7.0 or later)
- Proxmox VE cluster or single node
- Proxmox API token with appropriate permissions
- ISO files uploaded to Proxmox storage pool
- Network access to Proxmox API endpoint
The Proxmox plugin for Packer is required. It will be automatically installed when you run Packer for the first time:
proxmox = {
version = ">= 1.2.1"
source = "github.com/hashicorp/proxmox"
}Create a proxmox.pkrvars.hcl file (or copy from the example) with your Proxmox API credentials:
proxmox_api_url = "your-proxmox-host:8006"
proxmox_api_token_id = "user@pam!token_name"
proxmox_api_token_secret = "your-token-secret" # pragma: allowlist secret
proxmox_node = "proxmox01"
storage_pool = "your-storage-pool"Important: Do not commit proxmox.pkrvars.hcl to version control as it contains sensitive credentials. Add it to .gitignore.
ISO files must be uploaded to your Proxmox storage pool in the iso directory. The ISO naming convention follows:
{os_flavour}-{os_major}.{os_minor}-{os_arch}-{iso_type}
For example: AlmaLinux-10.1-x86_64-minimal.iso
Alternatively, you can specify a custom ISO name using the iso_name variable in the distribution-specific variable files.
To build a template, use Packer with the main configuration file and a distribution-specific variable file:
packer build -var-file=proxmox.pkrvars.hcl -var-file=Alma10-bios.pkrvars.hcl proxmox.pkr.hclAlmaLinux 10 BIOS:
packer build -var-file=proxmox.pkrvars.hcl -var-file=Alma10-bios.pkrvars.hcl proxmox.pkr.hclAlmaLinux 10 EFI:
packer build -var-file=proxmox.pkrvars.hcl -var-file=Alma10-efi.pkrvars.hcl proxmox.pkr.hclUbuntu 24.04 BIOS:
packer build -var-file=proxmox.pkrvars.hcl -var-file=ubuntu24-bios.pkrvars.hcl proxmox.pkr.hclRHEL 10 BIOS:
packer build -var-file=proxmox.pkrvars.hcl -var-file=rhel10-bios.pkrvars.hcl proxmox.pkr.hcl- AlmaLinux 8.10 (BIOS/EFI)
- AlmaLinux 9.6 (BIOS/EFI)
- AlmaLinux 9.7 (BIOS/EFI)
- AlmaLinux 10 (BIOS/EFI)
- Rocky Linux 8.10 (BIOS/EFI)
- Rocky Linux 9.6 (BIOS/EFI)
- Rocky Linux 9.7 (BIOS/EFI)
- Rocky Linux 10 (BIOS/EFI)
- RHEL 10 (BIOS/EFI)
- Ubuntu 24.04 (BIOS/EFI)
- Debian 11 (BIOS)
- Debian 12 (BIOS)
- Debian 13 (BIOS)
proxmox_packer/
├── proxmox.pkr.hcl # Main Packer configuration
├── proxmox.pkrvars.hcl # Proxmox API credentials (not in git)
├── variables.pkrvars.hcl # Common variable definitions
├── {Distribution}-{BootType}.pkrvars.hcl # Distribution-specific variables
└── http/ # Kickstart and preseed files
├── EL9-ks.cfg # RHEL 9 family kickstart (AlmaLinux 9, Rocky 9)
├── EL10-ks.cfg # RHEL 10 family kickstart (AlmaLinux 10, Rocky 10, RHEL 10)
├── 8-bios-ks.cfg # RHEL 8 BIOS kickstart
├── 8-efi-ks.cfg # RHEL 8 EFI kickstart
├── 9-bios-ks.cfg # RHEL 9 BIOS kickstart
├── 9-efi-ks.cfg # RHEL 9 EFI kickstart
├── RHEL10-bios-ks.cfg # RHEL 10 BIOS kickstart
├── RHEL10-efi-ks.cfg # RHEL 10 EFI kickstart
├── alma10-bios-ks.cfg # AlmaLinux 10 BIOS kickstart
├── alma10-efi-ks.cfg # AlmaLinux 10 EFI kickstart
├── debian-preseed.cfg # Debian preseed configuration
├── ubuntu24-preseed.cfg # Ubuntu 24.04 preseed configuration
├── ubuntu_bios/ # Ubuntu BIOS cloud-init files
│ ├── meta-data
│ └── user-data
├── ubuntu_efi/ # Ubuntu EFI cloud-init files
│ ├── meta-data
│ └── user-data
└── user-data # Cloud-init user data
proxmox_api_url: Proxmox API endpoint (host:port)proxmox_api_token_id: API token IDproxmox_api_token_secret: API token secretvm_id: Unique VM ID for the template- Format OS - Release Boot type
- e.g. OS NUMBER
- ALMA = 1
- DEBIAN = 3
- RHEL = 7
- Rocky=8
- Ubuntu=9
- OS Release Major
- Bootype
- 1 Bios
- 2 EFI
- e.g. OS NUMBER
- e.g. 7101 - RHEL = 7 OSMAJ = 10 BOOT = BIOS (1)
- Format OS - Release Boot type
os_flavour: Operating system name (e.g., "AlmaLinux", "Ubuntu")os_major: Major version numberos_minor: Minor version numberboot_type: Boot loader type ("seabios" for BIOS, "ovmf" for EFI)iso_type: ISO type (e.g., "minimal.iso", "dvd.iso")storage_pool: Proxmox storage pool namevm_pool: Resource pool for the VMmemory: VM memory in MBcpu_sockets: Number of CPU socketscpu_cores: Number of CPU cores per socketboot_disk_size: Boot disk size (e.g., "25G")
use_cloud_init: Enable cloud-init support (boolean)cloud_init_storage_pool: Storage pool for cloud-init files
The http/ directory contains automated installation configuration files:
- Kickstart files (
.cfg): For Red Hat-based distributions (AlmaLinux, Rocky, RHEL)EL9-ks.cfg: Used for RHEL 9 family distributions (AlmaLinux 9, Rocky 9)EL10-ks.cfg: Used for RHEL 10 family distributions (AlmaLinux 10, Rocky 10, RHEL 10)- Distribution-specific kickstart files are also available
- Preseed files (
.cfg): For Debian-based distributions (Debian, Ubuntu)debian-preseed.cfg: General Debian preseed configurationubuntu24-preseed.cfg: Ubuntu 24.04 preseed configuration
- Cloud-init files: For Ubuntu automated installation
ubuntu_bios/andubuntu_efi/directories containmeta-dataanduser-datafiles
These files are served via HTTP during the build process to automate the OS installation.
Templates are automatically named using the pattern:
{os_flavour}-{os_major}.{os_minor}-{bootloader_type}-TEMPLATE
Example: AlmaLinux-10.1-BIOS-TEMPLATE
- CPU Type: host
- Disk Format: qcow2
- Disk Type: scsi (configurable)
- Network: vmbr0 bridge with firewall enabled
- QEMU Agent: Enabled
- SSH User: vagrant (default)
- SSH Password: vagrant (default)
Edit the distribution-specific .pkrvars.hcl file to adjust:
- Memory allocation
- CPU cores and sockets
- Disk size
- Network configuration
Modify the boot_cmd variable in the distribution variable file to customize the boot process. The boot command uses Packer template variables:
{{ .HTTPIP }}: IP address of the HTTP server{{ .HTTPPort }}: Port of the HTTP server
Modify the files in the http/ directory to customize the automated installation process. Update the boot_cmd variable to reference your custom file.
- ISO not found: Verify the ISO file exists in the storage pool's
isodirectory with the correct naming convention - API authentication errors: Verify your API token has sufficient permissions
- SSH connection timeout: Increase
ssh_timeoutinproxmox.pkr.hclor check network connectivity - Boot command issues: Verify the boot command matches your ISO's boot menu structure
- VM ID conflicts: Ensure
vm_idis unique for each template - Storage pool errors: Verify the storage pool name and available space
- Network issues: Ensure the Proxmox node can reach the HTTP server during build
Tidy up pkrvars work logic into bios vs efi Add Ubuntu cloudinit config (ub22)
- Never commit
proxmox.pkrvars.hclcontaining API credentials - Use environment variables or a secrets management system for production
- Regularly rotate API tokens
- Review and customize kickstart/preseed files for your security requirements
MIT License
This project is provided as-is for building Proxmox VM templates.