windows-iac-vm-tooling/docs/03-packer/configuration.md
root e4f03427b7
Some checks are pending
Build and Release / build-sign-package (push) Waiting to run
feat: Add professional hierarchical documentation
- Created comprehensive README.md with Mermaid diagrams, badges, and TOC
- Added docs/ directory with 7 sections and 14 markdown files
- Included architecture diagrams, flowcharts, and sequence diagrams
- All documentation is fully interlinked with cross-references
- Added ISO storage location on Proxmox development server
- Included troubleshooting guide and evaluation management docs
- All config files (Packer, Terraform, Ansible, Forgejo) documented
- Added icons and visual elements throughout documentation
2026-02-06 14:47:15 +00:00

5.5 KiB

📦 Packer Configuration

Packer Proxmox

Overview

Packer is used to create a reproducible Windows golden image template. This document details the Packer configuration in packer/windows.pkr.hcl.


Configuration Structure

graph TD
    subgraph PackerConfig["Packer Configuration"]
        direction TB
        Block1[packer { required_plugins }] --> Block2[source "proxmox-iso" "windows-11"]
        Block2 --> Block3[build { sources } + provisioners]
    end
    
    subgraph Plugins["Plugins"]
        Plugin[proxmox >= 1.1.0]
    end
    
    subgraph Sources["Source Settings"]
        VM[VM Settings] --> HW[Hardware] --> Storage[Storage] --> Comm[Communicator]
    end
    
    PackerConfig --> Plugins
    PackerConfig --> Sources

Full Configuration

packer {
  required_plugins {
    proxmox = {
      version = ">= 1.1.0"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

source "proxmox-iso" "windows-11" {
  # === Connection ===
  proxmox_url = "https://proxmox-host:8006/api2/json"
  username    = "root@pam"
  password    = "secret"
  node        = "la-vmh-07"

  # === VM Settings ===
  vm_name      = "win11-ltsc-template"
  template_description = "Built with Packer on ${timestamp()}"
  iso_file     = "local:iso/CLIENT_LTSC_EVAL_x64FRE_en-us.iso"

  # === Hardware (Win11 Compliant) ===
  qemu_agent   = true
  cores        = 4
  memory       = 8192
  machine      = "q35"
  bios         = "ovmf"
  
  # UEFI + TPM 2.0
  efi_config {
    efi_storage_pool = "local-lvm"
    pre_enrolled_keys = true
  }
  tpm_config {
    version = "2.0"
    tpm_storage_pool = "local-lvm"
  }

  # === Storage ===
  scsi_controller = "virtio-scsi-pci"
  disks {
    disk_size    = "60G"
    storage_pool = "local-lvm"
    type         = "virtio"
    format       = "raw"
    cache_mode   = "writeback"
  }

  # === Additional ISOs ===
  additional_iso_files {
    device   = "sata1"
    iso_file = "local:iso/virtio-win.iso"
  }

  # === Communicator (WinRM) ===
  communicator = "winrm"
  winrm_username = "Administrator"
  winrm_password = "PackerPassword123!"
  winrm_insecure = true
  winrm_use_ssl  = true

  # === Boot Command ===
  boot_command = [
    "<wait><wait><wait>", "<enter><wait>", "<enter><wait>",
    "<enter><wait>", "<enter>"
  ]
  boot_wait    = "10s"
}

build {
  sources = ["source.proxmox-iso.windows-11"]

  # === Provisioners ===
  provisioner "powershell" {
    inline = [
      # Install VirtIO storage driver
      "pnputil /add-driver 'E:\\viostor\\w11\\amd64\\*.inf' /install",
      # Install VirtIO network driver
      "pnputil /add-driver 'E:\\NetKVM\\w11\\amd64\\*.inf' /install",
      # Install VirtIO guest tools
      "& 'E:\\virtio-win-guest-tools.exe' /install /passive /norestart"
    ]
  }
}

Section Details

Connection Settings

Setting Value Description
proxmox_url https://proxmox-host:8006/api2/json Proxmox API endpoint
username root@pam Authentication user
password secret Authentication password
node la-vmh-07 Target Proxmox node

Hardware Configuration

Setting Value Notes
cores 4 Windows 11 minimum
memory 8192 8 GB RAM
machine q35 Modern chipset
bios ovmf UEFI firmware

Storage Configuration

Setting Value Notes
disk_size 60G 60 GB disk
storage_pool local-lvm LVM storage
format raw Raw disk format

Boot Command

boot_command = [
  "<wait><wait><wait>",  # Wait 30 seconds
  "<enter><wait>",       # Press Enter (handle "Press any key")
  "<enter><wait>",       # Confirm boot
  "<enter><wait>",       # Continue installation
  "<enter>"              # Final confirmation
]
boot_wait = "10s"       # Initial wait before sending commands

Provisioners

PowerShell Provisioner

The PowerShell provisioner installs VirtIO drivers:

# Install VirtIO storage driver
pnputil /add-driver 'E:\viostor\w11\amd64\*.inf' /install

# Install VirtIO network driver  
pnputil /add-driver 'E:\NetKVM\w11\amd64\*.inf' /install

# Install VirtIO guest tools (silent)
& 'E:\virtio-win-guest-tools.exe' /install /passive /norestart

Build Process

flowchart LR
    subgraph BuildSteps["Packer Build Process"]
        direction TB
        Start[Start Build] --> Create[Create VM] --> MountISO[Mount ISO] --> Install[Windows Install] --> InstallDrivers[Install Drivers] --> Shutdown[Shutdown] --> Template[Convert to Template]
    end
    
    subgraph InstallActions["Windows Setup"]
        Boot[Boot from ISO] --> WinSetup[Windows Setup] --> OOBE[OOBE - Autounattend.xml] --> Desktop[Desktop - WinRM Ready]
    end
    
    style BuildSteps fill:#e3f2fd
    style InstallActions fill:#e8f5e9

Next Steps

Goal Next Document
Configure Autounattend.xml Autounattend.xml Guide
Build the template Run packer build windows.pkr.hcl
View Terraform OpenTofu Resources

← Documentation Index | → Autounattend.xml | ← ISO Requirements