Unattended Installation for Windows
Unattended Windows installation is done via "Answer Files", or "Unattend files".
These files are generally named "autounattend.xml". They are not Packer-specific tools, though we do make use of them.
If, after following this guide, you're still having issues getting an answer file working, We recommend you read the official documentation on answer files.
The guide here is hopefully enough to get you started, but isn't a replacement for the official documentation.
If you are installing the Windows Operating System from a mounted iso as part of your Packer build, you will need to use an Answer file. For example, you're building an image from scratch using the vmware-iso, virtualbox-iso, or hyperv-iso builders.
If you are not installing the operating system, you won't need to provide an answer file. If you are using a pre-built image in a cloud, you don't need to worry about Answer files.
You can either start from an example answer file from a known repo (take a look at the examples links below), or you can generate one using an answer file wizard by selecting New File > New Answer file on a Windows machine. A comprehensive list of all the options you can set in an answer file can be found here
Windows will automatically look for an autounattend.xml file on mounted drives.
Many users use the
floppy_files option or a secondary mounted iso for
providing the answer file to their iso builders.
You can also specify an unattend file to use by using the /unattend: option when
running Windows Setup (setup.exe) in your
Packer needs the Answer File to handle any questions that would normally be answered interactively during a Windows installation.
If you want to be able to use provisioners, the Answer file must also contain a script that sets up SSH or WinRM so that Packer can connect to the instance.
Finally, your Packer build will be much smoother if the Answer File handles or disables Windows updates rather than you trying to run them using a Packer provisioner. This is because the winrm communicator does not handle the disconnects caused by automatic reboots in Windows updates well, and the disconnections can fail a build.
The chef-maintained bento boxes are a great example of a Windows build that sets up openssh as part of the unattended installation so that Packer can connect using the SSH communicator. The functioning answer files for every modern Windows version can be found here.
Stefan Scherer's packer-windows repo
is a great example of Windows builds that set up WinRM as part of the unattended
installation so that Packer can connect using the
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c Packer_Provisioning_Shutdown",
"floppy_files": ["./scripts/Autounattend.xml", "./scripts/openssh.ps1"],