Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonTheNiceGuy/7d182356760f88d550c3 to your computer and use it in GitHub Desktop.
Save JonTheNiceGuy/7d182356760f88d550c3 to your computer and use it in GitHub Desktop.
There are lots of instructions about setting up an auto-provisioning Linux host in Vagrant, but not a lot about doing the same for Windows. This should help!

Copy all of these into a single directory, make sure you've got a recent version of Vagrant and Virtualbox installed, then just... vagrant up

Vagrant will start a "simple" Windows 2012r2 box, created (presumably) by the fine folks at OpenTable and then it runs the provisioning sequence:

  • This will first run the ChocoBootstrap.cmd file to load Chocolatey onto the box (via InstallChocolatey.ps1)
  • It then uses chocolatey to install BoxStarter using the InstallBoxStarter.bat script
  • Lastly, it copies the BoxStarterOperations.txt file to %temp% and then executes it via RunBoxstarter.bat

This was all made a lot easier due to these blog posts

I should note that unless you're using something later than a Windows 7 SP1 Desktop VM, or Windows 2012 Server, you'll also need to upgrade Powershell before you can do any of this provisioning :(

Enable-RemoteDesktop
chocolatey feature enable -n=allowGlobalConfirmation
choco install googlechrome
choco install firefox
choco install notepadplusplus.install
choco install putty.install
choco install libreoffice
choco install wireshark
choco install winscp
choco install jdk7
choco install jdk8
choco install nmap
choco install github
choco install xming
choco install dotnet4.6.1
choco install dotnet3.5sp1
choco install mssqlserver2012expresswithreporting
choco install sqlserver2012express-managementstudio
chocolatey feature disable -n=allowGlobalConfirmation
@powershell -NoProfile -ExecutionPolicy Bypass -File "%systemdrive%\vagrant\InstallChocolatey.ps1"
chocolatey feature enable -n=allowGlobalConfirmation
choco install BoxStarter
chocolatey feature disable -n=allowGlobalConfirmation
$ChocoInstallPath = "$env:SystemDrive\ProgramData\Chocolatey\bin"
if (!(Test-Path $ChocoInstallPath)) {
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
}
copy "%systemdrive%\vagrant\BoxStarterOperations.txt" "%temp%\BoxStarterOperations.txt"
@powershell -NoProfile -ExecutionPolicy Bypass -Command "Import-Module Boxstarter.Chocolatey; Install-BoxStarterPackage -PackageName %temp%\\BoxStarterOperations.txt"
Vagrant.configure(2) do |config|
config.vm.box = "opentable/win-2012r2-standard-amd64-nocm"
config.vm.hostname = "server"
# Change the following and the routing line below to match your requirements!
config.vm.network "public_network", ip: "192.0.2.100", bridge: "eth0"
config.vm.provider "virtualbox" do |vb|
vb.name = "Build-Server"
vb.customize ["modifyvm", :id, "--groups", '"/VagrantHosts/Build-Hosts"']
vb.memory = "2048"
end
# This ensures you're using *your* selected NIC rather than the one defined by Vagrant's NAT interface
config.vm.provision :shell,
run: "always",
inline: "route delete 0.0.0.0"
config.vm.provision :shell,
run: "always",
inline: "route add 0.0.0.0 mask 0.0.0.0 192.0.2.1"
config.vm.boot_timeout = 0
config.vm.provision :shell, path: "ChocoBootstrap.cmd"
config.vm.provision :shell, path: "InstallBoxStarter.bat"
config.vm.provision :shell, path: "RunBoxstarter.bat"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment