This blog post is the first in a series on building a home lab. Transitioning from an ESXi background and exploring available resources, I found a lack of comprehensive guides for building a Windows 10 template with Packer. This initial post details the steps to build a Windows 10 Pro VM template using Packer on a Proxmox server with proxmox-iso artifact builder. The process automates the Windows installation and configuration to streamline the creation of VM templates. The repository can be found on github.
Requirements
- Packer: Version 1.11.0 or higher
- Proxmox: Proxmox VE with API access
- Proxmox Plugins:
proxmox
(version >=1.1.8) andwindows-update
(version >=0.16.7) - Oscdim: Or xorriso/mkisofts/hdiutil supported by packer required for mounting the files
Files Overview
Here's a brief overview of the key files involved in this build:
autounattend.xml
: This file contains the automated Windows installation configuration.WinRM-Config.ps1
: PowerShell script to enable WinRM.Install-Agent.ps1
: PowerShell script to install qemu-guest-agent, needed for connection. Similar to VMware tools for vSphere.win10x64.pkr.hcl
: The main Packer configuration file for building the Windows 10 VM.win10x64.pkrvars.hcl
: Contains variables specific to the Windows 10 VM build.proxmox.pkrvars.hcl
: Contains variables for connecting to the Proxmox server.
Setup
Follow these steps to set up and run the build:
Step 1: Update Variables
Modify the win10x64.pkrvars.hcl
and proxmox.pkrvars.hcl
files with your specific settings.
win10x64.pkrvars.hcl
vm_name = "Win10Pro-Template"
template_name = "Win10Pro-Template"
os = "win10"
cores = 2
sockets = 2
memory = 4112
cpu_type = "kvm64"
vm_cdrom_type = "sata"
disk_size = "40G"
disk_format = "raw"
disk_storage_pool = "local-lvm"
iso_storage_pool = "storage"
vm_network = "vmbr0"
firewall = "true"
bridge = "vmbr0"
iso_file = "local:iso/Windows-64.iso"
proxmox.pkrvars.hcl
proxmox_host = "192.168.1.1:8006"
proxmox_node = "dev"
proxmox_api_user = "root@pam"
proxmox_api_password = "YourPassword"
proxmox_storage = "storage"
Step 2: Install Packer Plugins
Ensure the required Packer plugins are installed by running the following command:
packer init .
Step 3: Build the Template
Run the Packer build command with your variable files:
packer build --var-file=win10x64.pkrvars.hcl --var-file=../proxmox.pkrvars.hcl win10x64.pkr.hcl
The build on an SSD ~4m and with windows updates plugin on ~35m.
Debugging:
- could not find a supported CD ISO creation command
For Linux/macOS make sure xorriso or mkisofts/hdiutil is present. While using Windows, Install the Deployments Tools and make sure oscdimg is present in the path
You can find the tool in the following path. C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\x86\Oscdimg