Build a Windows lab with VirtualBox, Packer and Vagrant, adding sysprep (part 2)

In my former article I elaborated on how to create a lab with Windows servers quickly using Vagrant, Packer and Virtualbox. What I did not realize at that time is that the box I created had 2 issues:

  • The box is not sysprepped. The sysprep is mandatory if you want to create a Domain Controller and are adding boxes to the domain. You’ll end up with 2 boxes with the same SID.
  • The MAC address is cloned for every Vagrant machine that is based on the box. This becomes a problem if you want to place the hosts in a bridged network.

Sysprep

Then I went and Googled (after trying in vain myself) and found this repository: https://github.com/mefellows/packer-community-templates. Someone has already done it.

Step 1:
Here is a link to the json file: https://gist.github.com/jacqinthebox/cd3dcbf4b220c70de956.
Copy this file to the packer-windows folder and save it as ‘windows_2012_r2_sysprep.json’

Step 2
Make sure you copy the Autounattend_sysprep.xml file from \packer-community-templates\answer_files\2012_r2 to the \packer-windows\answer_files\2012_r2 folder.

Now you can run packer build -only virtualbox-iso windows_2012_r2_sysprep.json. And grab a coffee.

MAC address

The MAC address can be set in the Vagrant file for each machine. First you need to know what the name is of the network interface for the bridge.

2015-09-17_22-02-19

Then you can insert the name of the nic in the Vagrantfile like this (see the marked lines):

So there it is.