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
| Template | Varfile | Notes |
|---|---|---|
windows.pkr.hcl | win10.pkrvars.hcl | Windows 10 |
windows.pkr.hcl | win11.pkrvars.hcl | Windows 11 |
windows.pkr.hcl | win8.pkrvars.hcl | Windows 8 |
windows.pkr.hcl | win7.pkrvars.hcl | Windows 7 |
windows.pkr.hcl | winxp.pkrvars.hcl | Windows XP |
ubuntu.pkr.hcl | ubuntu.pkrvars.hcl | Ubuntu (configurable version) |
Prerequisites
- Packer >= 1.8
- QEMU/KVM (
qemu-system-x86_64,libvirt) - Docker (for the containerized build approach)
- KVM-capable host (
/dev/kvmavailable)
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:
- Windows 10/11: Microsoft Evaluation Center
- Windows 7/8: Internet Archive
- Ubuntu: ubuntu.com/download
Build
Direct Packer build
packer build -var-file=win10.pkrvars.hcl windows.pkr.hcl
packer build -var-file=ubuntu.pkrvars.hcl ubuntu.pkr.hcl
Docker build (recommended)
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.