Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bootstrap Vagrant + Packer for Windows Development and Automation
try {
Write-Host -ForegroundColor green "Bootstrapping machine ${remoteHost}"
Write-Host "Setting up package management and installing required packages for Dev."
# Install Choco (if not already installed) + required packages
if ( (Get-Command "choco" -errorAction SilentlyContinue) ) {
Write-Host "Chocolatey already installed. Skipping."
} else {
Write-Host "Installing Chocolatey"
$wc=new-object net.webclient; $wp=[system.net.WebProxy]::GetDefaultProxy(); $wp.UseDefaultCredentials=$true; $wc.Proxy=$wp; iex ($wc.DownloadString('https://chocolatey.org/install.ps1'))
}
Write-Host "Installing required packages."
choco install cyg-get
If ( -not ($env:path | Select-String -SimpleMatch "c:\tools\cygwin\bin") ) {
Write-Host "Adding cygwin to path"
$userPath = [Environment]::GetEnvironmentVariable("PATH","User")
$userPath += ";c:\tools\cygwin\bin"
$env:PATH += ";c:\tools\cygwin\bin" # For this session..
[Environment]::SetEnvironmentVariable("PATH", $userPath, "User") # Permanently
}
Write-Host "Packages installed"
Write-Host "Configuring Cygwin for use with Vagrant"
# Setup SSH / Rsync for use with Vagrant
C:\tools\cygwin\cygwinsetup.exe --site http://mirror.internode.on.net/pub/cygwin/ --quiet-mode --packages rsync,openssh
Write-Host "Cygwin configuration complete."
Write-Host "Installing Vagrant and friends... This will take a little bit of time"
if ( -not (Get-Command 'vagrant' -ErrorAction SilentlyContinue)) {
choco install vagrant
$env:PATH +=";C:\HashiCorp\Vagrant\bin"
} else {
Write-Host "Vagrant already installed"
}
if ( -not (Test-Path 'C:\Program Files\Oracle\VirtualBox\VBoxManage.exe' -ErrorAction SilentlyContinue)) {
choco install virtualbox
choco install virtualbox.extensionpack
} else {
Write-Host "Virtualbox already installed"
}
RefreshEnv
Write-Host "Vagrant and friends installed, Installing required Vagrant plugins..."
vagrant plugin install vagrant-proxyconf vagrant-multi-hostsupdater vagrant-windows-domain vagrant-dsc
# Installing Packer
choco install packer-windows-plugins -Pre
Write-Host "Vagrant plugins installed"
} finally {
}
@jerkovicl

This comment has been minimized.

Copy link

@jerkovicl jerkovicl commented Sep 11, 2015

@mefellows when i run this i get error :
C:\tools\cygwin\cygwinsetup.exe : The term 'C:\tools\cygwin\cygwinsetup.exe' is not recognized as the name of
a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was include d, verify that the path is correct and try again.
At C:\Users\xx\Documents\GitHub\Vagrant\bootstrap.ps1:28 char:3

  • C:\tools\cygwin\cygwinsetup.exe --site http://mirror.internode.on.net/pub/cygw ...
  • CategoryInfo : ObjectNotFound: (C:\tools\cygwin\cygwinsetup.exe:String) [], CommandNotFoundExc
    eption
  • FullyQualifiedErrorId : CommandNotFoundException
@jpeckham

This comment has been minimized.

Copy link

@jpeckham jpeckham commented Apr 6, 2018

hyper v?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment