Commit 318aabcf authored by Stefan Scherer's avatar Stefan Scherer

Automate vagrant installation

parent 48b93376
......@@ -90,9 +90,8 @@ Doing so will give you hours back in your day, which is a good thing.
These boxes use WinRM. There is no OpenSSH installed.
### (Experimental) Hyper-V Support
If you are running Windows 10 Insider Preview, then you can also use these packerfiles to build a Hyper-V virtual machine:
### Hyper-V Support
If you are running Windows 10, then you can also use these packerfiles to build a Hyper-V virtual machine:
This requires @taliesens [fork of Packer](https://github.com/mitchellh/packer/pull/2576) with Hyper-V support. The linked PR also has binaries available ex: https://dl.bintray.com/taliesins/Packer/Packer.1.0.0.104-HyperV.nupkg
......@@ -100,10 +99,11 @@ Then run Packer:
```
packer build -var 'hyperv_switchname=Wifi' .\windows_2016.json
```
Be sure to set hyperv_switchname to an external Hyper-V switch
Be sure to set hyperv_switchname to an external Hyper-V switch.
You then can use this box with Vagrant to spin up a Hyper-V VM. Vagrant currently
needs some patches as well, see the script [install-vagrant.ps1](hyperv/scripts/install-vagrant.ps1)
how to patch Vagrant 1.8.4 to fix these issues.
### Using .box Files With Vagrant
......
......@@ -2,12 +2,12 @@
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.
Tested with VMware Fusion 8 and VMware Workstation 12.
## On your OSX host
## On your OSX/Windows host
### Build the Windows 10 VMware base box
Build the Windows 10 base box for VMware Fusion with 100GByte disk size.
Build the Windows 10 base box for VMware Fusion/Workstation with 100GByte disk size.
```bash
cd ..
......@@ -27,16 +27,18 @@ 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
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
```
### Run the Hyper-V VM in Windows 10
You probably have to copy the C:\vagrant folder into the VM as packer would work
on a shared folder of the host.
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
### Run the Hyper-V VM in Windows 10
```powershell
vagrant box add windows_2016_tp5_docker windows_2016_docker_hyperv.box
......
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
cd $env:TEMP
wget -outfile Packer.zip -uri https://dl.bintray.com/taliesins/Packer/Packer.1.0.0.104-HyperV.nupkg -UseBasicParsing
Expand-Archive packer.zip
copy packer\packer.exe $env:ChocolateyInstall\bin\packer.exe
choco install -y vagrant
# TODO patch Vagrant 1.8.4 as described in https://github.com/PatrickLang/packer-windows/issues/1#issuecomment-230151622
if (Test-Path c:\hashicorp\vagrant\embedded\gems\specifications\vagrant-1.8.4.gemspec) {
Write-Host "Patching vagrant to use latest winrm-fs gem"
(Get-Content c:\hashicorp\vagrant\embedded\gems\specifications\vagrant-1.8.4.gemspec) -replace '%q<winrm-fs>, \["~> 0.3.0"\]', '%q<winrm-fs>, ["> 0.3.0"]' | Set-Content c:\hashicorp\vagrant\embedded\gems\specifications\vagrant-1.8.4.gemspec
$env:PATH += ";c:\hashicorp\vagrant\bin"
vagrant plugin install winrm-fs
}
if (Test-Path C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.8.4\plugins\providers\hyperv\scripts\get_vm_status.ps1) {
Write-Host "Patching vagrant hyperv get_vm_status.ps1 script"
wget -uri https://raw.githubusercontent.com/codekaizen/vagrant/d3859a33aa37aa238fd4022a3ad4e7546f149570/plugins/providers/hyperv/scripts/get_vm_status.ps1 -outfile C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.8.4\plugins\providers\hyperv\scripts\get_vm_status.ps1
}
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