diff --git a/README.md b/README.md index 5d00b46c..15b9c33d 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,26 @@ This repository contains Windows templates that can be used to create boxes for This repo began by borrowing bits from the VeeWee Windows templates (https://github.com/jedi4ever/veewee/tree/master/templates). Modifications were made to work with Packer and the VMware Fusion provider for Packer and Vagrant. +### Windows Updates + +The scripts in this repo will install all Windows updates – by default – during Windows Setup. This is a _very_ time consuming process, depending on the age of the OS and the quantity of updates released since the last service pack. You might want to do yourself a favor during development and disable this functionality, by commenting out this First Logon Command: + +``` + + cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1 + Install Windows Updates + 100 + true + +``` + +Doing so will give you hours back in your day, which is a good thing. + ### Getting Started This repository assumes that you have access to [MSDN](http://msdn.microsoft.com) and can download the ISO images Microsoft makes available there. -Currently, this repo expects you to do a little heavy lifting to get the Windows ISO required to build boxes. +Currently, this repo leverages trial versions of Windows 2008 R2 / 2012 / 2012 R2. If you would like to leverage RTM (non-trial) versions, you should update the relevent `.json` file, setting `iso_url` to `"./iso/.iso"` and `iso_checksum` to `` after following these instructions: 1. Download the Windows Server 2008 R2 with Service Pack 1 (x64) - DVD (English) ISO (`en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso`) 2. Verify that `en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso` has an MD5 hash of `8dcde01d0da526100869e2457aafb7ca` (Microsoft lists a SHA1 hash of `d3fd7bf85ee1d5bdd72de5b2c69a7b470733cd0a`, which is equivalent) @@ -21,4 +36,4 @@ Currently, this repo expects you to do a little heavy lifting to get the Windows ### Contributing -Pull requests welcomed. I plan to include other variants of Windows 2008 R2 and Windows 2012 next. +Pull requests welcomed. Please ensure you create your edits in a branch off of the `develop` branch, not the `master` branch. diff --git a/answer_files/2008_r2/Autounattend.xml b/answer_files/2008_r2/Autounattend.xml index 19aa5cb5..7624b48d 100644 --- a/answer_files/2008_r2/Autounattend.xml +++ b/answer_files/2008_r2/Autounattend.xml @@ -223,16 +223,8 @@ 21 Disable Hibernation Mode - - - - cmd.exe /c a:\openssh.bat + cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 Install OpenSSH 99 true diff --git a/answer_files/2012/Autounattend.xml b/answer_files/2012/Autounattend.xml index 64829669..3e7f1907 100644 --- a/answer_files/2012/Autounattend.xml +++ b/answer_files/2012/Autounattend.xml @@ -36,7 +36,7 @@ XC9B7-NBPP2-83J2H-RHMBY-92BT4 Never - + @@ -94,6 +94,11 @@ true true Home + 1 + true + true + true + true @@ -224,16 +229,8 @@ 21 Disable Hibernation Mode - - - - cmd.exe /c a:\openssh.bat + cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 Install OpenSSH 99 true diff --git a/answer_files/2012_r2/Autounattend.xml b/answer_files/2012_r2/Autounattend.xml new file mode 100644 index 00000000..561d8bca --- /dev/null +++ b/answer_files/2012_r2/Autounattend.xml @@ -0,0 +1,274 @@ + + + + + + + + + + 1 + Primary + 60000 + + + + + false + NTFS + C + 1 + 1 + + + + 0 + true + + OnError + + + true + Vagrant Administrator + Vagrant Inc. + + + W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9 + Never + + + + + + 0 + 1 + + OnError + false + + + /IMAGE/NAME + Windows Server 2012 R2 SERVERDATACENTER + + + + + + + + en-US + + en-US + en-US + en-US + en-US + en-US + + + + + false + + + + + + + vagrant + true</PlainText> + </AdministratorPassword> + <LocalAccounts> + <LocalAccount wcm:action="add"> + <Password> + <Value>vagrant</Value> + <PlainText>true</PlainText> + </Password> + <Description>Vagrant User</Description> + <DisplayName>vagrant</DisplayName> + <Group>administrators</Group> + <Name>vagrant</Name> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + <OOBE> + <HideEULAPage>true</HideEULAPage> + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> + <NetworkLocation>Home</NetworkLocation> + <ProtectYourPC>1</ProtectYourPC> + <HideOnlineAccountScreens>true</HideOnlineAccountScreens> + <HideLocalAccountScreen>true</HideLocalAccountScreen> + <SkipUserOOBE>true</SkipUserOOBE> + <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> + </OOBE> + <AutoLogon> + <Password> + <Value>vagrant</Value> + <PlainText>true</PlainText> + </Password> + <Username>vagrant</Username> + <Enabled>true</Enabled> + </AutoLogon> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> + <Description>Set Execution Policy 64 Bit</Description> + <Order>1</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> + <Description>Set Execution Policy 32 Bit</Description> + <Order>2</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine> + <Description>winrm quickconfig -q</Description> + <Order>3</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine> + <Description>winrm quickconfig -transport:http</Description> + <Order>4</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine> + <Description>Win RM MaxTimoutms</Description> + <Order>5</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}</CommandLine> + <Description>Win RM MaxMemoryPerShellMB</Description> + <Order>6</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine> + <Description>Win RM AllowUnencrypted</Description> + <Order>7</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine> + <Description>Win RM auth Basic</Description> + <Order>8</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}</CommandLine> + <Description>Win RM client auth Basic</Description> + <Order>9</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine> + <Description>Win RM listener Address/Port</Description> + <Order>10</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine> + <Description>Win RM adv firewall enable</Description> + <Order>11</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" </CommandLine> + <Description>Win RM port open</Description> + <Order>12</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c net stop winrm </CommandLine> + <Description>Stop Win RM Service </Description> + <Order>13</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c sc config winrm start=auto</CommandLine> + <Description>Win RM Autostart</Description> + <Order>14</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c net start winrm</CommandLine> + <Description>Start Win RM Service</Description> + <Order>15</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine> + <Order>16</Order> + <Description>Show file extensions in Explorer</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine> + <Order>17</Order> + <Description>Enable QuickEdit mode</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine> + <Order>18</Order> + <Description>Show Run command in Start Menu</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine> + <Order>19</Order> + <Description>Show Administrative Tools in Start Menu</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine> + <Order>20</Order> + <Description>Zero Hibernation File</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine> + <Order>21</Order> + <Description>Disable Hibernation Mode</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1</CommandLine> + <Description>Install OpenSSH</Description> + <Order>99</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1</CommandLine> + <Description>Install Windows Updates</Description> + <Order>100</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + </FirstLogonCommands> + <ShowWindowsLive>false</ShowWindowsLive> + </component> + </settings> + <settings pass="specialize"> + <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> + <OEMInformation> + <HelpCustomized>false</HelpCustomized> + </OEMInformation> + <!-- Rename computer here. --> + <ComputerName>vagrant-2012</ComputerName> + <TimeZone>Pacific Standard Time</TimeZone> + <RegisteredOwner/> + </component> + <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> + <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon> + </component> + <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> + <!-- Disable IE ESC. --> + <IEHardenAdmin>false</IEHardenAdmin> + <IEHardenUser>false</IEHardenUser> + </component> + <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> + <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon> + </component> + <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> + <SkipAutoActivation>true</SkipAutoActivation> + </component> + </settings> + <cpi:offlineImage xmlns:cpi="urn:schemas-microsoft-com:cpi" cpi:source="catalog:d:/sources/install_windows server 2008 r2 serverdatacenter.clg"/> +</unattend> diff --git a/scripts/chocolatey.bat b/scripts/chocolatey.bat index 238302a5..5baf357b 100644 --- a/scripts/chocolatey.bat +++ b/scripts/chocolatey.bat @@ -4,4 +4,3 @@ powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object n <nul set /p ".=;C:\Chocolatey\bin" >> C:\Windows\Temp\PATH set /p PATH=<C:\Windows\Temp\PATH setx PATH "%PATH%" /m -setx ChocolateyInstall "C:\Chocolatey" /m diff --git a/scripts/chocopacks.bat b/scripts/chocopacks.bat new file mode 100644 index 00000000..4597ff94 --- /dev/null +++ b/scripts/chocopacks.bat @@ -0,0 +1,6 @@ +:: Ensure C:\Chocolatey\bin is on the path +set /p PATH=<C:\Windows\Temp\PATH + +:: Install all the things; for example: +cmd /c choco install 7zip +cmd /c choco install notepadplusplus diff --git a/scripts/openssh.bat b/scripts/openssh.bat deleted file mode 100644 index a167b7da..00000000 --- a/scripts/openssh.bat +++ /dev/null @@ -1,34 +0,0 @@ - -:: setup openssh -powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.mls-software.com/files/setupssh-6.3p1-1(x64).exe', 'C:\Windows\Temp\openssh.exe')" -cmd /c C:\Windows\temp\openssh.exe /S /port=22 /privsep=1 /password=D@rj33l1ng - -:: ensure vagrant can log in -mkdir "C:\Users\vagrant\.ssh" -cmd /c C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant vagrant:(OI)(CI)F -cmd /c C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant vagrant:(OI)RX -cmd /c C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant vagrant:(OI)RX -powershell -Command "(Get-Content 'C:\Program Files\OpenSSH\etc\passwd') | Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } | Set-Content 'C:\Program Files\OpenSSH\etc\passwd'" - -:: fix opensshd to not be strict -powershell -Command "(Get-Content 'C:\Program Files\OpenSSH\etc\sshd_config') -replace 'StrictModes yes', 'StrictModes no' | Set-Content 'C:\Program Files\OpenSSH\etc\sshd_config'" -powershell -Command "(Get-Content 'C:\Program Files\OpenSSH\etc\sshd_config') -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes' | Set-Content 'C:\Program Files\OpenSSH\etc\sshd_config'" -powershell -Command "(Get-Content 'C:\Program Files\OpenSSH\etc\sshd_config') -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes' | Set-Content 'C:\Program Files\OpenSSH\etc\sshd_config'" - -:: use Windows\Temp as /tmp location -rd /S /Q "C:\Program Files\OpenSSH\tmp" -cmd /c ""C:\Program Files\OpenSSH\bin\junction.exe" /accepteula "C:\Program Files\OpenSSH\tmp" C:\Windows\Temp" -cmd /c C:\Windows\System32\icacls.exe "C:\Windows\Temp" /grant vagrant:(OI)(CI)F -powershell -Command "Add-Content C:\Users\vagrant\.ssh\environment "TEMP=C:\Windows\Temp"" - -:: record the path for use by provisioners -<nul set /p ".=%PATH%" > C:\Windows\Temp\PATH - -if "%1" neq "START" ( - cmd /c net stop opensshd -) - -:: configure firewall -netsh advfirewall firewall add rule name="SSHD" dir=in action=allow service=OpenSSHd enable=yes -netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="C:\Program Files\OpenSSH\usr\sbin\sshd.exe" enable=yes -netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22 diff --git a/scripts/openssh.ps1 b/scripts/openssh.ps1 new file mode 100644 index 00000000..b7dc47e8 --- /dev/null +++ b/scripts/openssh.ps1 @@ -0,0 +1,76 @@ +param ( + [switch]$AutoStart = $false +) + +$is_64bit = [IntPtr]::size -eq 8 + +# setup openssh +$ssh_download_url = "http://www.mls-software.com/files/setupssh-6.4p1-1.exe" +if ($is_64bit) { + Write-Host "64 bit OS found" + $ssh_download_url = "http://www.mls-software.com/files/setupssh-6.4p1-1(x64).exe" +} + +if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) { + Write-Host "Downloading $ssh_download_url" + (New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe") + Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=22 /privsep=1 /password=D@rj33l1ng" -NoNewWindow -Wait +} + +Stop-Service "OpenSSHd" -Force + +# ensure vagrant can log in +Write-Host "Setting vagrant user file permissions" +New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh" +C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F" +C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX" +C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX" + +Write-Host "Setting SSH home directories" +(Get-Content "C:\Program Files\OpenSSH\etc\passwd") | + Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } | + Set-Content 'C:\Program Files\OpenSSH\etc\passwd' + +# fix opensshd to not be strict +Write-Host "Setting OpenSSH to be non-strict" +$sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config" +$sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no' +$sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes' +$sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes' +# disable the use of DNS to speed up the time it takes to establish a connection +$sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no' +# disable the login banner +$sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/banner.txt' +Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config + +# use c:\Windows\Temp as /tmp location +Write-Host "Setting temp directory location" +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\tmp" +C:\Program` Files\OpenSSH\bin\junction.exe /accepteula "C:\Program Files\OpenSSH\tmp" "C:\Windows\Temp" +C:\Windows\System32\icacls.exe "C:\Windows\Temp" /grant "vagrant:(OI)(CI)F" + +# add 64 bit environment variables missing from SSH +Write-Host "Setting SSH environment" +$sshenv = "TEMP=C:\Windows\Temp" +if ($is_64bit) { + $env_vars = "ProgramFiles(x86)=C:\Program Files (x86)", ` + "ProgramW6432=C:\Program Files", ` + "CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files", ` + "CommonProgramW6432=C:\Program Files\Common Files" + $sshenv = $sshenv + "`r`n" + ($env_vars -join "`r`n") +} +Set-Content C:\Users\vagrant\.ssh\environment $sshenv + +# record the path for provisioners (without the newline) +Write-Host "Recording PATH for provisioners" +Set-Content C:\Windows\Temp\PATH ([byte[]][char[]] $env:PATH) -Encoding Byte + +# configure firewall +Write-Host "Configuring firewall" +netsh advfirewall firewall add rule name="SSHD" dir=in action=allow service=OpenSSHd enable=yes +netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="C:\Program Files\OpenSSH\usr\sbin\sshd.exe" enable=yes +netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22 + +if ($AutoStart -eq $true) { + Start-Service "OpenSSHd" +} diff --git a/vagrantfile-windows_2012_r2.template b/vagrantfile-windows_2012_r2.template new file mode 100644 index 00000000..dd373252 --- /dev/null +++ b/vagrantfile-windows_2012_r2.template @@ -0,0 +1,48 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.define "vagrant-windows-2012-r2" + config.vm.box = "windows_2012_r2" + config.vm.base_mac = "{{ .BaseMacAddress }}" + + # You should be using the vagrant-windows Vagrant Plugin! + # Admin user name and password + config.winrm.username = "vagrant" + config.winrm.password = "vagrant" + + config.vm.guest = :windows + config.windows.halt_timeout = 15 + + # Port forward WinRM and RDP + config.vm.network :forwarded_port, guest: 3389, host: 3389 + config.vm.network :forwarded_port, guest: 5985, host: 5985 + + # Berkshelf + # config.berkshelf.enabled = true + + # Shell - Hello World + # config.vm.provision :shell, :inline => "C:\\vagrant\\scripts\\HelloWorld.bat" + + config.vm.provider :virtualbox do |v, override| + #v.gui = true + v.customize ["modifyvm", :id, "--memory", 2048] + v.customize ["modifyvm", :id, "--cpus", 2] + end + + config.vm.provider :vmware_fusion do |v, override| + #v.gui = true + v.vmx["memsize"] = "2048" + v.vmx["ethernet0.virtualDev"] = "vmxnet3" + v.vmx["RemoteDisplay.vnc.enabled"] = "false" + v.vmx["RemoteDisplay.vnc.port"] = "5900" + end + + config.vm.provider :vmware_workstation do |v, override| + #v.gui = true + v.vmx["memsize"] = "2048" + v.vmx["ethernet0.virtualDev"] = "vmxnet3" + v.vmx["RemoteDisplay.vnc.enabled"] = "false" + v.vmx["RemoteDisplay.vnc.port"] = "5900" + end +end diff --git a/windows_2008_r2.json b/windows_2008_r2.json index d7f525c7..795f6c61 100644 --- a/windows_2008_r2.json +++ b/windows_2008_r2.json @@ -1,9 +1,9 @@ { "builders": [{ "type": "vmware", - "iso_url": "./iso/en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso", + "iso_url": "http://care.dlservice.microsoft.com//dl/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso", "iso_checksum_type": "md5", - "iso_checksum": "8dcde01d0da526100869e2457aafb7ca", + "iso_checksum": "4263be2cf3c59177c45085c0a7bc6ca5", "headless": true, "boot_wait": "5m", "ssh_username": "vagrant", @@ -17,7 +17,7 @@ "floppy_files": [ "./answer_files/2008_r2/Autounattend.xml", "./scripts/win-updates.ps1", - "./scripts/openssh.bat" + "./scripts/openssh.ps1" ], "vmx_data": { "RemoteDisplay.vnc.enabled": "false", @@ -27,9 +27,9 @@ } }, { "type": "virtualbox", - "iso_url": "./iso/en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso", + "iso_url": "http://care.dlservice.microsoft.com//dl/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso", "iso_checksum_type": "md5", - "iso_checksum": "8dcde01d0da526100869e2457aafb7ca", + "iso_checksum": "4263be2cf3c59177c45085c0a7bc6ca5", "headless": true, "boot_wait": "5m", "ssh_username": "vagrant", @@ -41,7 +41,7 @@ "floppy_files": [ "./answer_files/2008_r2/Autounattend.xml", "./scripts/win-updates.ps1", - "./scripts/openssh.bat", + "./scripts/openssh.ps1", "./scripts/oracle-cert.cer" ], "vboxmanage": [ diff --git a/windows_2012.json b/windows_2012.json index c97becc0..da955348 100644 --- a/windows_2012.json +++ b/windows_2012.json @@ -1,9 +1,9 @@ { "builders": [{ "type": "vmware", - "iso_url": "./iso/en_windows_server_2012_x64_dvd_915478.iso", + "iso_url": "http://care.dlservice.microsoft.com//dl/download/6/D/A/6DAB58BA-F939-451D-9101-7DE07DC09C03/9200.16384.WIN8_RTM.120725-1247_X64FRE_SERVER_EVAL_EN-US-HRM_SSS_X64FREE_EN-US_DV5.ISO", "iso_checksum_type": "md5", - "iso_checksum": "da91135483e24689bfdaf05d40301506", + "iso_checksum": "8503997171f731d9bd1cb0b0edc31f3d", "headless": true, "boot_wait": "5m", "ssh_username": "vagrant", @@ -17,7 +17,7 @@ "floppy_files": [ "./answer_files/2012/Autounattend.xml", "./scripts/win-updates.ps1", - "./scripts/openssh.bat" + "./scripts/openssh.ps1" ], "vmx_data": { "RemoteDisplay.vnc.enabled": "false", @@ -27,9 +27,9 @@ } }, { "type": "virtualbox", - "iso_url": "./iso/en_windows_server_2012_x64_dvd_915478.iso", + "iso_url": "http://care.dlservice.microsoft.com//dl/download/6/D/A/6DAB58BA-F939-451D-9101-7DE07DC09C03/9200.16384.WIN8_RTM.120725-1247_X64FRE_SERVER_EVAL_EN-US-HRM_SSS_X64FREE_EN-US_DV5.ISO", "iso_checksum_type": "md5", - "iso_checksum": "da91135483e24689bfdaf05d40301506", + "iso_checksum": "8503997171f731d9bd1cb0b0edc31f3d", "headless": true, "boot_wait": "5m", "ssh_username": "vagrant", @@ -41,7 +41,7 @@ "floppy_files": [ "./answer_files/2012/Autounattend.xml", "./scripts/win-updates.ps1", - "./scripts/openssh.bat", + "./scripts/openssh.ps1", "./scripts/oracle-cert.cer" ], "vboxmanage": [ diff --git a/windows_2012_r2.json b/windows_2012_r2.json new file mode 100644 index 00000000..72c94403 --- /dev/null +++ b/windows_2012_r2.json @@ -0,0 +1,70 @@ +{ + "builders": [{ + "type": "vmware", + "iso_url": "http://care.dlservice.microsoft.com/dl/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO", + "iso_checksum_type": "md5", + "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a", + "headless": true, + "boot_wait": "5m", + "ssh_username": "vagrant", + "ssh_password": "vagrant", + "ssh_wait_timeout": "2h", + "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", + "guest_os_type": "windows8srv-64", + "disk_size": 61440, + "vnc_port_min": 5900, + "vnc_port_max": 5980, + "floppy_files": [ + "./answer_files/2012_r2/Autounattend.xml", + "./scripts/win-updates.ps1", + "./scripts/openssh.ps1" + ], + "vmx_data": { + "RemoteDisplay.vnc.enabled": "false", + "RemoteDisplay.vnc.port": "5900", + "memsize": "2048", + "numvcpus": "2" + } + }, { + "type": "virtualbox", + "iso_url": "http://care.dlservice.microsoft.com/dl/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO", + "iso_checksum_type": "md5", + "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a", + "headless": true, + "boot_wait": "5m", + "ssh_username": "vagrant", + "ssh_password": "vagrant", + "ssh_wait_timeout": "2h", + "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", + "guest_os_type": "Windows2012_64", + "disk_size": 61440, + "floppy_files": [ + "./answer_files/2012_r2/Autounattend.xml", + "./scripts/win-updates.ps1", + "./scripts/openssh.ps1", + "./scripts/oracle-cert.cer" + ], + "vboxmanage": [ + ["modifyvm", "{{.Name}}", "--memory", "2048"], + ["modifyvm", "{{.Name}}", "--cpus", "2"] + ] + }], + "provisioners": [{ + "type": "shell", + "remote_path": "/tmp/script.bat", + "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", + "scripts": [ + "./scripts/vm-guest-tools.bat", + "./scripts/chef.bat", + "./scripts/vagrant-ssh.bat" + ] + }, { + "type": "shell", "inline": ["rm -rf /tmp/*"] + }], + "post-processors": [{ + "type": "vagrant", + "keep_input_artifact": false, + "output": "windows_2012_r2_{{.Provider}}.box", + "vagrantfile_template": "vagrantfile-windows_2012_r2.template" + }] +}