Skip to content

Instantly share code, notes, and snippets.

@akrabat akrabat/Vagrantfile
Last active Nov 14, 2019

Embed
What would you like to do?
Example Vagrantfile for Windows
# rerun the Boxstarter setup file. Open a PowerShell window and type: C:\vagrant\re-run.ps1
cp C:\vagrant\setup.ps1 $env:TEMP
$credential = New-Object System.Management.Automation.PSCredential("vagrant", (ConvertTo-SecureString "vagrant" -AsPlainText -Force))
Install-BoxstarterPackage $env:TEMP\setup.ps1 -Credential $credential
# Boxstarter setup script
# Notes:
# - This file has to be idempotent. it will be run several times if the
# computer needs to be restarted. When that happens, Boxstarter schedules
# this script to run again with an auto-logon. Fortunately choco install
# handles trying to install the same package more than once.
# - Pass -y to choco install to avoid interactive prompts
# Fix Windows Explorer
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
# Useful apps
choco install -y googlechrome
choco install -y firefox
choco install -y 7zip
choco install -y notepadplusplus
choco install git -y -params '"/GitAndUnixToolsOnPath /NoAutoCrlf"'
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Mozilla Firefox\firefox.exe"
# SQL Server
choco install -y sql-server-2017 --params='/SAPWD="Indigo12!" /SECURITYMODE=sql'
choco install -y sql-server-management-studio
# IIS
choco install -y IIS-WebServerRole -source windowsfeatures
choco install -y IIS-WebServer -source windowsfeatures
choco install -y IIS-CommonHttpFeatures -source windowsfeatures
choco install -y IIS-StaticContent -source windowsfeatures
choco install -y IIS-DefaultDocument -source windowsfeatures
choco install -y IIS-DirectoryBrowsing -source windowsfeatures
choco install -y IIS-HttpErrors -source windowsfeatures
choco install -y IIS-ApplicationDevelopment -source windowsfeatures
choco install -y IIS-CGI -source windowsfeatures
choco install -y IIS-HealthAndDiagnostics -source windowsfeatures
choco install -y IIS-HttpLogging -source windowsfeatures
choco install -y IIS-LoggingLibraries -source windowsfeatures
choco install -y IIS-RequestMonitor -source windowsfeatures
choco install -y IIS-Security -source windowsfeatures
choco install -y IIS-RequestFiltering -source windowsfeatures
choco install -y IIS-HttpCompressionStatic -source windowsfeatures
choco install -y IIS-WebServerManagementTools -source windowsfeatures
choco install -y IIS-ManagementConsole -source windowsfeatures
choco install -y IIS-ManagementScriptingTools -source windowsfeatures
choco install -y WAS-WindowsActivationService -source windowsfeatures
choco install -y WAS-ProcessModel -source windowsfeatures
choco install -y urlrewrite
# PHP
choco install -y php --package-parameters="/InstallDir:C:\PHP"
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Base box: https://github.com/akrabat/packer-templates
Vagrant.configure("2") do |config|
config.vm.box = "19ft/windows2016"
config.vm.guest = :windows
config.vm.boot_timeout = 600
config.vm.hostname = "WinDev"
config.vm.network "private_network", ip: "192.168.99.201"
config.vm.communicator = "winrm"
config.vm.provider "VirtualBox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "2048"
vb.cpus = 2
end
config.vm.provision "shell", privileged: "true", inline: <<-'POWERSHELL'
Set-TimeZone "Coordinated Universal Time"
# Install Boxstarter
. { iwr -useb https://boxstarter.org/bootstrapper.ps1 } | iex; Get-Boxstarter -Force
# Copy setup.ps1 to the Temp directory and then run boxstarter with our setup.ps1 script
$env:PSModulePath = "$([System.Environment]::GetEnvironmentVariable('PSModulePath', 'User'));$([System.Environment]::GetEnvironmentVariable('PSModulePath', 'Machine'))"
cp C:\vagrant\setup.ps1 $env:TEMP
Import-Module Boxstarter.Chocolatey
$credential = New-Object System.Management.Automation.PSCredential("vagrant", (ConvertTo-SecureString "vagrant" -AsPlainText -Force))
Install-BoxstarterPackage $env:TEMP\setup.ps1 -Credential $credential
POWERSHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.