Commit 40ad7d8d authored by Stefan Scherer's avatar Stefan Scherer

Add hyperv build environment when working on OSX

parent 149e036d
# hyperv
This Vagrant environment can be used to spin up a Windows 10 VM to create the 2016 Hyper-V Vagrant boxes.
The VM needs about 6GByte RAM and 100 GByte disk.
Tested with VMware Fusion.
## On your OSX host
### Build the Windows 10 VMware base box
Build the Windows 10 base box for VMware Fusion with 100GByte disk size.
```bash
cd ..
packer build --only=vmware-iso -var disk_size=102400 windows_10.json
vagrant box add windows_10 windows_10_vmware.box
```
### Build the Windows 10 Hyper-V environment
Now build the Vagrant environment with Hyper-V and packer in a Windows 10 VM.
```bash
cd hyperv
vagrant up --provider vmware_fusion
```
## In the Windows 10 VM
### Build the Windows Server 2016 TP5 Hyper-V base box
Now inside the Windows 10 VM run packer with this command
```powershell
cd C:\vagrant
packer build --only=hyperv-iso -var 'hyperv_switchname=Wifi' windows_2016_docker.iso
```
### Run the Hyper-V VM in Windows 10
If using Vagrant 1.8.4 make sure you have patched it to make it work with Hyper-V as described in https://github.com/PatrickLang/packer-windows/issues/1#issuecomment-230151622
```powershell
vagrant box add windows_2016_tp5_docker windows_2016_docker_hyperv.box
cd C:\Users\vagrant
git clone https://github.com/StefanScherer/docker-windows-box
cd docker-windows-box
vagrant up
```
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "windows_10"
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
config.vm.communicator = "winrm"
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.vm.guest = :windows
config.windows.halt_timeout = 15
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "..", "/vagrant"
config.vm.provision "shell", path: "scripts/install-chocolatey.ps1", privileged: false
config.vm.provision "shell", path: "scripts/install-hyperv.ps1", privileged: false
config.vm.provision "reload"
config.vm.provision "shell", path: "scripts/install-packer.ps1", privileged: false
config.vm.provision "shell", path: "scripts/install-vagrant.ps1", privileged: false
["vmware_fusion", "vmware_workstation"].each do |provider|
config.vm.provider provider do |v, override|
v.gui = true
end
end
config.vm.provider "vmware_fusion" do |v|
v.vmx["gui.fitguestusingnativedisplayresolution"] = "TRUE"
v.vmx["mks.enable3d"] = "TRUE"
v.vmx["mks.forceDiscreteGPU"] = "TRUE"
v.vmx["gui.fullscreenatpoweron"] = "TRUE"
v.vmx["gui.viewmodeatpoweron"] = "fullscreen"
v.vmx["gui.lastPoweredViewMode"] = "fullscreen"
v.vmx["sound.startconnected"] = "TRUE"
v.vmx["sound.present"] = "TRUE"
v.vmx["sound.autodetect"] = "TRUE"
v.enable_vmrun_ip_lookup = false
v.vmx["memsize"] = "6048"
v.vmx["numvcpus"] = "2"
v.vmx["vhv.enable"] = "TRUE"
end
end
# install chocolatey
iex (wget 'https://chocolatey.org/install.ps1' -UseBasicParsing)
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
wget -outfile $env:TEMP\Packer.zip -uri https://dl.bintray.com/taliesins/Packer/Packer.1.0.0.104-HyperV.nupkg -UseBasicParsing
Expand-Archive $env:TEMP\packer.zip
choco install -y vagrant
# TODO patch Vagrant 1.8.4 as described in https://github.com/PatrickLang/packer-windows/issues/1#issuecomment-230151622
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment