packer-templates

June 16, 2026 · View on GitHub

Packer HCL templates for building Windows and Ubuntu QEMU/KVM virtual machine images.

Used by osw-builder to automate OS image creation.

Supported OS

TemplateVarfileNotes
windows.pkr.hclwin10.pkrvars.hclWindows 10
windows.pkr.hclwin11.pkrvars.hclWindows 11
windows.pkr.hclwin8.pkrvars.hclWindows 8
windows.pkr.hclwin7.pkrvars.hclWindows 7
windows.pkr.hclwinxp.pkrvars.hclWindows XP
ubuntu.pkr.hclubuntu.pkrvars.hclUbuntu (configurable version)

Prerequisites

  • Packer >= 1.8
  • QEMU/KVM (qemu-system-x86_64, libvirt)
  • Docker (for the containerized build approach)
  • KVM-capable host (/dev/kvm available)

Providing your own ISO

The varfiles include iso_url and iso_checksum fields that you must fill in with your own ISO sources:

iso_url      = "/path/to/your/windows.iso"
iso_checksum = "sha1:your_checksum_here"

Where to get ISOs legally:

Build

Direct Packer build

packer build -var-file=win10.pkrvars.hcl windows.pkr.hcl
packer build -var-file=ubuntu.pkrvars.hcl ubuntu.pkr.hcl

The repo ships a Dockerfile that packages Packer + QEMU in a container, avoiding local dependency management.

Build the image:

docker build -t packer-templates .

Run a build (example: Windows 10):

docker run -ti --rm \
  -v $HOME/.cache/packer:/cache \
  -v $PWD:/output_parent \
  --device /dev/kvm \
  --network none \
  --user "$(id -u):$(id -g)" \
  --group-add kvm \
  -v $PWD/win10.pkrvars.hcl:/packer/win10.pkrvars.hcl \
  -v $PWD/answer_files/10/Autounattend.xml:/packer/answer_files/10/Autounattend.xml \
  packer-templates

Expose VNC on port 5900 to monitor the installation:

docker run ... -p 5900:5900 packer-templates

Answer files

Unattended installation answer files are in answer_files/:

answer_files/
├── 7/          # Windows 7 Autounattend.xml
├── 8/          # Windows 8 Autounattend.xml
├── 10/         # Windows 10 Autounattend.xml
├── 11/         # Windows 11 Autounattend.xml
├── ubuntu/     # Ubuntu preseed.cfg
└── xp/         # Windows XP WINNT.SIF

License

Apache 2.0 — see LICENSE.