Unverified Commit 19ebc7b6 authored by Stefan Scherer's avatar Stefan Scherer Committed by GitHub

Merge pull request #59 from StefanScherer/add-nested-builder

Add two nested builder vm's
parents 3ff7bee3 95c50cfc
# 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 8 and VMware Workstation 12.
## On your OSX/Windows host
### Build the Windows 10 VMware base box
Build the Windows 10 base box for VMware Fusion/Workstation 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 Hyper-V base box
Now inside the Windows 10 VM create a Hyper-V external switch and then run
packer with this command
```powershell
cd C:\vagrant
packer build --only=hyperv-iso -var 'hyperv_switchname=Wifi' windows_2016_docker.iso
```
You probably have to copy the C:\vagrant folder into the VM as packer would work
on a shared folder of the host.
### Run the Hyper-V VM in Windows 10
```powershell
vagrant box add windows_2016_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
```
Write-Host Installing Docker client
choco install -y docker
choco install -y vagrant -version 1.9.1
# nested
With this Vagrant environment you can build for other hypervisors in a nested
VMware VM. Or you can have a look at the provision scripts how to install
all tools needed on bare metal.
## Preparation
On your host with VMware.
### Build the Windows 10 VMware base box
Build the Windows 10 base box for VMware Fusion/Workstation 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
```
## Hyper-V
Now build the Vagrant environment with Hyper-V and packer in a Windows 10 VM.
```bash
cd nested
vagrant up hyperv
```
### Build a Hyper-V Vagrant box
In the nested Windows 10 VM with Hyper-V first create an external virtual
switch in Hyper-V Manager. Then you can run Packer builds.
```powershell
cd C:\Users\vagrant\packer-windows
packer build --only=hyperv-iso --var hyperv_switchname=ext windows_2016_docker.iso
```
You can copy the boxes produced back to C:\vagrant folder
that is a shared folder of the host.
### Run the Hyper-V VM in Windows 10
```powershell
vagrant box add windows_2016_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
```
## VirtualBox
Now build the Vagrant environment with VirtualBox and packer in a Windows 10 VM.
```bash
cd nested
vagrant up virtualbox
```
### Build a VirtualBox Vagrant box
In the nested Windows 10 VM with VirtualBox installed you can run Packer builds.
```powershell
cd C:\Users\vagrant\packer-windows
packer build --only=virtualbox-iso windows_2016_docker.iso
```
You can copy the boxes produced back to C:\vagrant folder
that is a shared folder of the host.
### Run the VirtualBox VM in Windows 10
```powershell
vagrant box add windows_2016_docker windows_2016_docker_virtualbox.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
config.vm.provision "shell", path: "scripts/install-docker.ps1", privileged: false
config.vm.provision "shell", path: "scripts/install-docker-machine.ps1", privileged: false
["vmware_fusion", "vmware_workstation"].each do |provider|
config.vm.provider provider do |v, override|
v.gui = true
v.enable_vmrun_ip_lookup = false
v.vmx["memsize"] = "6048"
v.vmx["numvcpus"] = "2"
v.vmx["vhv.enable"] = "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"
end
end
# -*- 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.define "hyperv" do |cfg|
config.vm.provision "shell", path: "scripts/install-hyperv.ps1", privileged: false
config.vm.provision "reload"
config.vm.provision "shell", path: "scripts/copy-templates.ps1", privileged: false
config.vm.provision "shell", path: "scripts/install-tools.ps1", privileged: false
end
config.vm.define "virtualbox" do |cfg|
config.vm.provision "shell", path: "scripts/copy-templates.ps1", privileged: false
config.vm.provision "shell", path: "scripts/install-tools.ps1", privileged: false
config.vm.provision "shell", path: "scripts/install-virtualbox.ps1", privileged: false
config.vm.provision "reload"
end
["vmware_fusion", "vmware_workstation"].each do |provider|
config.vm.provider provider do |v, override|
v.gui = true
v.enable_vmrun_ip_lookup = false
v.vmx["memsize"] = "6048"
v.vmx["numvcpus"] = "2"
v.vmx["vhv.enable"] = "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"
end
end
mkdir $env:USERPROFILE\packer-windows
cd $env:USERPROFILE\packer-windows
copy \vagrant\*.json .
copy \vagrant\vag* .
copy -re \vagrant\answer_files\ answer_files
copy -re \vagrant\floppy\ floppy
copy -re \vagrant\scripts\ scripts
if (Test-Path \vagrant\packer_cache\) {
copy -re \vagrant\packer_cache\ packer_cache
}
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
Install-WindowsFeature Hyper-V-Tools
Install-WindowsFeature Hyper-V-PowerShell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
$username = $env:USERNAME
net localgroup "Hyper-V Administrators" $username /add
# install chocolatey
iex (wget 'https://chocolatey.org/install.ps1' -UseBasicParsing)
choco install -y packer
choco install -y vagrant
choco install -y docker
choco install -y docker-machine
choco install -y virtualbox
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