Packer Community Templates for Windows environments to test/showcase many of the Windows-specific Builders and Provisioners.
-
Install Packer and Packer Community
-
Clone this repo:
git clone git@github.com:mefellows/packer-windows-templates.git && cd packer-community-templates
-
Run Packer
Common practice is to create intermediate boxes in machine image pipelines, such as a 'Base' and 'Application' images. The examples below follow this pattern.
Run the ISO builder to produce a simple Base box with VirtualBox guest additions and optionally Windows updates (Uncomment the relevant lines in the Autounattend.xml files to enable this):
packer build -only=virtualbox-windows-iso 2012r2-virtualbox.json
Run the OVF builder to produce a simple base box with rsync and Seek DSC resources installed:
packer build -only=virtualbox-windows-ovf 2012r2-virtualbox.json
packer build --var base_ami=ami-ac3a1cc4 --var subnet_id=subnet-1234abcd--var vpc_id=vpc-4567defg ./amazon-sysprep.json
Use the /answer_files/2012_r2/updates/Autounattend.xml
file as a replacement in the floppy_files
configuration item.
An example unattended sysprep file is automatically uploaded to c:/Windows/Temp/Autounattend_sysprep.xml
which can be used in a provisioner to sysprep the machine. For example, you may replace the default shutdown_command
in the OVF builder with the following:
"shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:c:/Windows/Temp/Autounattend_sysprep.xml",
"shutdown_timeout": "15m"
NOTE: This currently impacts the rsync (SSH) capability due to SIDs and such.
Thanks to Joe's joefitzgerald/packer-windows templates for the inspiration and basis for much of this work.