A Packer build to make a pretty vanilla Windows 10 x64 box for use with VMWare Desktop or Virtualbox.
This project is just a clone of my other Windows Packer project with some very minor changes. Eventually the two projects will merge and form like Voltron.
In essence, the build does the following:
- Use an existing, vanilla, Windows 10 x64 Enterprise trial ISO
- Enable WinRM (in a slightly scary, Unauthenticated mode, for Packer/Vagrant to use)
- Create a
vagrant
user (as is the style) - Grab all the Windows updates is can
- Install VM guest additions
- Turn off Hibernation
- Turn on RDP
- Set the network type for the virtual adapter to 'Home' and not bug you about it
- Turns autologin off because I like simulating end user environments, ok?
- A copy of the Windows 10 x64 Enterprise Trial
- Packer / Vagrant - Duh. Tested with Packer 1.2.5 and Vagrant 2.1.2.
- VMWare Workstation or Fusion with The Vagrant VMWare Provider, Virtualbox, Parallels or HyperV (support for HyperV and Parallels added by gildas)
- An RDP client (built in on Windows, available here for Mac
- Git
This project works great with Virtualbox, so don't bother shelling out for VMWare Fusion without trying VirtualBox first.
This guide will assume you zero knowledge of any or all of these systems.
- Install Vagrant.
- Install Packer - these instructions help.
- Download and install Virtualbox or VMWare Fusion/Workstation (with the Vagrant Plugin).
- Ensure you have an RDP client (you do if you're running Windows) - for Mac, install this
- Download the Windows 10 x64 Enterprise Trial, save the ISO someplace you'll remember.
- Make a working directory somewhere (OSX suggestion
mkdir ~/Packer_Projects/
) andcd
to that directory (e.g.cd ~/Packer_Projects/
). - Clone this repo to your working directory:
git clone https://github.com/luciusbono/Packer-Windows10
(if you don't havegit
installed: here are instructions. - Determine the MD5 hash of your iso:
md5 [path to iso]
in OSXFCIV -md5 [path to iso]
in Windows (download it here) -- Linux people are smarter than me and likely can just calculate the md5 hash through ether-magic. - To actually build your VM, build against the hypervisor target you're interested in:
- For Virtualbox run
packer build -only=virtualbox-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json
- For VMWare Fusion/Workstation run
packer build -only=vmware-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json
. - For Parallels run
packer build -only=parallels-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json
- for HyperV run
packer build -only=hyperv-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json
optionally, if you want to specify a different HyperV virtual switch other than "Default Switch" you can specify it in theswitch_name
var.
- You will see build pause on
Waiting for WinRM to become available
- this is normal! If you actually access the console session on your VM you will see that it is getting updates from Microsoft's servers. This can easily take 30 minutes, so be patient. After the updates are all installed, Windows will turn it's WinRM service back on and Packer will continue with the build. - Run
vagrant box add --name [vagrant box name] [name of .box file]
. The name can be anything you want. For example, this command is valid for Virtualbox:vagrant box add --name windows10 virtualbox-iso_windows-10.box
- Make a working directory for your Vagrant VM (OSX suggestion
mkdir ~/Vagrant_Projects/windows10
) andcd
to that directory (e.g.cd ~/Vagrant_Projects/windows10
) - Type
vagrant init [vagrant box name]
- for examplevagrant init windows10
- Type
vagrant up
and once the box has been launched typevagrant rdp
- Continue through any certificate errors and login with the username:
vagrant
and the password:vagrant
- Feel free to delete the
.box
file that packer created. You may also delete your.iso
you downloaded if you wish. - Stop the box by typing
vagrant halt
. Destroy the box by typingvagrant destroy
The packer.json
file requires two variables to validate. You can confirm these with a packer inspect packer.json
$ packer inspect packer.json
iso_md5 =
iso_path =
switch_name = Default Switch
Builders:
hyperv-iso
parallels-iso
virtualbox-iso
vmware-iso
Provisioners:
powershell
windows-restart
Since there are two Builders, you also likely want to specify one or the other.
Valid options are virtualbox-iso
or vmware-iso
.
The other two variables, iso_md5
and iso_path
, are the path and the MD5 hash of the Windows 10 Enterprise trial ISO.
The update grabbing script is a bit of a grey-box, as I basically just hijacked it (as well as lots of other code) from this awesome project - which I think is the defacto standard for Windows / Packer relations - but I wanted a leaner build. This project started as a frankenstein build, but is turning more into a ground-up rewrite of a lot of other projects' scripts and code. With the exception of the update-windows.ps1
script, which I only modified very slightly, I will slowly go through all the code in this project and make sure I kill all the cruft.
If, for some reason, you have multiple hypervisors, but want to run this project in Virtualbox, for example, you need to specify the provider in your vagrant up
statement like so: vagrant up --provider=virtualbox
Almost nobody will fall into the camp, but it's worth mentioning. Have fun!
The vagrantfile template disables the SharedFoldersEnableSymlinksCreate
option. I'd rather default to an untrusted guest since most of my workflows do not require symlinks. To change this, just add config.vm.synced_folder ".", "/vagrant", SharedFoldersEnableSymlinksCreate: true
to your vagrantfile and do a vagrant reload
.
I ran into this issue on a Windows 10 host with this project. I submitted an issue. The resolution is to choose Use another account
and login with .\vagrant
as the login and vagrant
as the password. Unforuntately, it appears that one must log in with these credentials in this manner each time you vagrant rdp
(unless that issue says otherwise...).
vagrant rdp -- /public
will also force mstsc into "public mode" which will clear the credentials dialogs each time.