├── .gitattributes ├── scripts ├── .gitignore ├── docker │ ├── 10 │ │ └── install-containers-feature.ps1 │ ├── 2016 │ │ └── install-containers-feature.ps1 │ ├── set-winrm-automatic.ps1 │ ├── set-winrm-delayed-automatic.ps1 │ ├── disable-windows-defender.ps1 │ ├── add-docker-group.ps1 │ ├── open-docker-insecure-port.ps1 │ ├── remove-docker-key-json.ps1 │ ├── enable-winrm.ps1 │ ├── docker-pull.ps1 │ ├── open-docker-swarm-ports.ps1 │ ├── install-docker.ps1 │ └── chocolatey-and-tools.ps1 ├── set-winrm-automatic.bat ├── uac-enable.bat ├── disable-auto-logon.bat ├── enable-uac.bat ├── enable-winrm.bat ├── disable-tasks.bat ├── disable-screensaver.ps1 ├── chocolatey.bat ├── enable-rdp.bat ├── chocopacks.bat ├── pin-powershell.bat ├── chef.bat ├── sysprep.bat ├── installnet4.bat ├── vagrant-ssh.bat ├── install-winget.ps1 ├── disable-winrm.ps1 ├── wait-for-tiworker.ps1 ├── wait-for-desktop-file.ps1 ├── puppet.bat ├── salt.bat ├── puppet-enterprise.bat ├── microsoft-updates.bat ├── set-powerplan.ps1 ├── compile-dotnet-assemblies.bat ├── win-7-update-net48.ps1 ├── enable-winrm.ps1 ├── hotfix-KB2842230.bat ├── enable-remote-desktop.bat ├── dis-updates.bat ├── rsync.bat ├── win-7-update-2019-09-sha2.ps1 ├── win-7-update-2019-07-update-rollup.ps1 ├── win-7-update-2019-10-update-rollup.ps1 ├── win-7-update-2019-03-servicing-stack.ps1 ├── win-7-update-2019-09-servicing-stack.ps1 ├── dis-updates.ps1 ├── hotfix-KB2552055.bat ├── fixnetwork.ps1 ├── debloat-windows.ps1 ├── install-cumulative-update.ps1 ├── create-domain.ps1 ├── win-7-update-2016-convenience-rollup.ps1 ├── win-7-update-sp1.ps1 ├── compact.bat ├── win-7-update-powershell-5.1.ps1 ├── unattend.xml ├── vm-guest-tools.bat └── openssh.ps1 ├── nested ├── .gitignore ├── terraform │ ├── .gitignore │ ├── FirstLogonCommands.xml │ ├── init.tf │ ├── variables.tf │ ├── README.md │ ├── provision.ps1 │ └── windows.tf ├── scripts │ ├── install-virtualbox.ps1 │ ├── install-hyperv.ps1 │ ├── copy-templates.ps1 │ └── install-tools.ps1 ├── Vagrantfile └── README.md ├── floppy ├── PinTo10.exe ├── WindowsPowershell.lnk └── ReadMe.txt ├── validate.sh ├── .gitmodules ├── test ├── spec_helper.rb ├── windows_vmware.rb ├── windows_virtualbox.rb └── windows_vcloud.rb ├── ansible ├── windows_update_security_updates.yml └── windows_update.yml ├── PSScriptAnalyzerSettings.psd1 ├── fix.sh ├── .gitignore ├── README-dockerfile.md ├── Dockerfile ├── README-ami.md ├── test.ps1 ├── README-shutdown_command.md ├── LICENSE ├── appveyor.yml ├── bin ├── build.bat ├── test-box-virtualbox.bat ├── upload-vcloud.bat ├── test-box-vmware.bat └── test-box-vcloud.bat ├── iso └── README.md ├── vagrantfile-windows_81.template ├── vagrantfile-windows_2012.template ├── vagrantfile-windows_2008_r2.template ├── vagrantfile-windows_2012_r2.template ├── vagrantfile-windows_2016_core.template ├── vagrantfile-windows_2019_core.template ├── windows_2016_docker_azure.json ├── README-rsync.md ├── windows_2008_r2_core.json ├── windows_2012.json ├── windows_2008_r2.json ├── windows_2016_core_ami.json ├── vagrantfile-windows_7.template ├── windows_2012_r2_hyperv.json ├── windows_2016_ami.json ├── windows_2019_core_ami.json ├── windows_81.json ├── vagrantfile-windows_2016.template ├── vagrantfile-windows_10.template ├── upload-vhd.ps1 ├── windows_2019_docker_azure.json ├── windows_2012_r2_core.json ├── windows_2012_r2.json ├── windows_2016_hyperv.json ├── CHANGELOG.md ├── windows_2016_core.json ├── windows_server_insider.json ├── windows_11_insider.json ├── windows_10_insider.json └── windows_2016.json /.gitattributes: -------------------------------------------------------------------------------- 1 | *.lnk -diff 2 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.msi 3 | *.msu -------------------------------------------------------------------------------- /nested/.gitignore: -------------------------------------------------------------------------------- 1 | resources/ 2 | .vagrant/ 3 | -------------------------------------------------------------------------------- /nested/terraform/.gitignore: -------------------------------------------------------------------------------- 1 | terraform.tf* 2 | .terraform/ 3 | -------------------------------------------------------------------------------- /nested/scripts/install-virtualbox.ps1: -------------------------------------------------------------------------------- 1 | choco install -y virtualbox 2 | -------------------------------------------------------------------------------- /scripts/docker/set-winrm-automatic.ps1: -------------------------------------------------------------------------------- 1 | . sc.exe config winrm start= auto 2 | -------------------------------------------------------------------------------- /scripts/docker/set-winrm-delayed-automatic.ps1: -------------------------------------------------------------------------------- 1 | . sc.exe config winrm start= delayed-auto 2 | -------------------------------------------------------------------------------- /floppy/PinTo10.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StefanScherer/packer-windows/HEAD/floppy/PinTo10.exe -------------------------------------------------------------------------------- /scripts/set-winrm-automatic.bat: -------------------------------------------------------------------------------- 1 | echo Set WinRM start type to auto 2 | sc config winrm start= auto 3 | -------------------------------------------------------------------------------- /floppy/WindowsPowershell.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StefanScherer/packer-windows/HEAD/floppy/WindowsPowershell.lnk -------------------------------------------------------------------------------- /scripts/uac-enable.bat: -------------------------------------------------------------------------------- 1 | reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /f /v EnableLUA /t REG_DWORD /d 1 2 | -------------------------------------------------------------------------------- /scripts/disable-auto-logon.bat: -------------------------------------------------------------------------------- 1 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /d 0 /f -------------------------------------------------------------------------------- /scripts/enable-uac.bat: -------------------------------------------------------------------------------- 1 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 1 /f 2 | -------------------------------------------------------------------------------- /validate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for template in $(ls -1 *.json); do 4 | echo $template 5 | packer validate --only=vmware-iso --only=virtualbox-iso $template 6 | done 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/Debloat-Windows-10"] 2 | path = submodules/Debloat-Windows-10 3 | url = https://github.com/JunielKatarn/Debloat-Windows-10.git 4 | branch = win11-2025 5 | -------------------------------------------------------------------------------- /scripts/docker/disable-windows-defender.ps1: -------------------------------------------------------------------------------- 1 | $DefenderInstalled = Get-Command -Module Defender 2 | if($null -ne $DefenderInstalled) { 3 | Set-MpPreference -DisableRealtimeMonitoring $true 4 | } 5 | -------------------------------------------------------------------------------- /scripts/enable-winrm.bat: -------------------------------------------------------------------------------- 1 | rem Enable-NetFirewallRule for WinRM 2 | netsh advfirewall firewall add rule name="Port 5985" dir=in action=allow protocol=TCP localport=5985 3 | sc.exe config winrm start= auto 4 | -------------------------------------------------------------------------------- /test/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | require 'pathname' 3 | require 'net/ssh' 4 | 5 | include SpecInfra::Helper::Ssh 6 | # include Serverspec::Helper::Cmd 7 | include Serverspec::Helper::Windows 8 | -------------------------------------------------------------------------------- /ansible/windows_update_security_updates.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | tasks: 3 | - name: Install security updates 4 | win_updates: 5 | category_names: 6 | - SecurityUpdates 7 | use_scheduled_task: yes -------------------------------------------------------------------------------- /nested/scripts/install-hyperv.ps1: -------------------------------------------------------------------------------- 1 | Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart 2 | 3 | $username = $env:USERNAME 4 | net localgroup "Hyper-V Administrators" $username /add 5 | -------------------------------------------------------------------------------- /scripts/docker/add-docker-group.ps1: -------------------------------------------------------------------------------- 1 | Write-Output Creating group docker 2 | net localgroup docker /add 3 | $username = $env:USERNAME 4 | Write-Output Adding user $username to group docker 5 | net localgroup docker $username /add 6 | -------------------------------------------------------------------------------- /scripts/disable-tasks.bat: -------------------------------------------------------------------------------- 1 | schtasks /End /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" 2 | schtasks /Change /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /DISABLE 3 | -------------------------------------------------------------------------------- /PSScriptAnalyzerSettings.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | Severity = @('Error', 'Warning') 3 | ExcludeRules = @('PSAvoidUsingConvertToSecureStringWithPlainText', 'PSUseShouldProcessForStateChangingFunctions', 'PSAvoidGlobalVars', 'PSUseApprovedVerbs') 4 | } 5 | -------------------------------------------------------------------------------- /scripts/disable-screensaver.ps1: -------------------------------------------------------------------------------- 1 | Write-Output "Disabling Screensaver" 2 | Set-ItemProperty "HKCU:\Control Panel\Desktop" -Name ScreenSaveActive -Value 0 -Type DWord 3 | & powercfg -x -monitor-timeout-ac 0 4 | & powercfg -x -monitor-timeout-dc 0 5 | -------------------------------------------------------------------------------- /scripts/chocolatey.bat: -------------------------------------------------------------------------------- 1 | powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" 2 | -------------------------------------------------------------------------------- /scripts/enable-rdp.bat: -------------------------------------------------------------------------------- 1 | netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389 2 | reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f 3 | -------------------------------------------------------------------------------- /fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for template in $(ls -1 *.json); do 4 | echo $template 5 | packer fix $template >/tmp/$$.json 6 | if [ $? -ne 0 ]; then 7 | cat /tmp/$$.json 8 | exit 1 9 | fi 10 | mv /tmp/$$.json $template 11 | done 12 | -------------------------------------------------------------------------------- /scripts/chocopacks.bat: -------------------------------------------------------------------------------- 1 | :: Ensure C:\Chocolatey\bin is on the path 2 | set /p PATH=%PATH%;C:\ProgramData\chocolatey\ 3 | echo %PATH% 4 | 5 | :: Install all the things; for example: 6 | choco install /y 7zip 7 | choco install /y notepadplusplus 8 | choco install /y boxstarter.winconfig -------------------------------------------------------------------------------- /ansible/windows_update.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | tasks: 3 | - name: Install security updates, critical updates and update rollups 4 | win_updates: 5 | category_names: 6 | - SecurityUpdates 7 | - CriticalUpdates 8 | - UpdateRollups 9 | use_scheduled_task: yes -------------------------------------------------------------------------------- /scripts/pin-powershell.bat: -------------------------------------------------------------------------------- 1 | rem https://connect.microsoft.com/PowerShell/feedback/details/1609288/pin-to-taskbar-no-longer-working-in-windows-10 2 | copy "A:\WindowsPowerShell.lnk" "%TEMP%\Windows PowerShell.lnk" 3 | A:\PinTo10.exe /PTFOL01:'%TEMP%' /PTFILE01:'Windows PowerShell.lnk' 4 | exit /b 0 5 | -------------------------------------------------------------------------------- /scripts/chef.bat: -------------------------------------------------------------------------------- 1 | if not exist "C:\Windows\Temp\chef.msi" ( 2 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.getchef.com/chef/install.msi', 'C:\Windows\Temp\chef.msi')" > C:\Windows\Temp\PATH 9 | set /p PATH= /minion-name= 8 | 9 | > C:\Windows\Temp\PATH 10 | set /p PATH= 2 | 3 | cmd /c "copy C:\AzureData\CustomData.bin C:\provision.ps1"CopyScript 5 | 11 6 | 7 | 8 | powershell.exe -sta -ExecutionPolicy Unrestricted -file C:\provision.ps1RunScript 10 | 12 11 | 12 | 13 | -------------------------------------------------------------------------------- /scripts/puppet-enterprise.bat: -------------------------------------------------------------------------------- 1 | if not exist "C:\Windows\Temp\puppet.msi" ( 2 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://pm.puppetlabs.com/puppet-enterprise/3.0.1/puppet-enterprise-3.0.1.msi', 'C:\Windows\Temp\puppet.msi')" > C:\Windows\Temp\PATH 9 | set /p PATH= A:\temp.vbs 8 | echo Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"") >> A:\temp.vbs 9 | 10 | cscript A:\temp.vbs 11 | 12 | net start wuauserv 13 | -------------------------------------------------------------------------------- /scripts/set-powerplan.ps1: -------------------------------------------------------------------------------- 1 | Try { 2 | Write-Output "Set power plan to high performance" 3 | 4 | $HighPerf = powercfg -l | ForEach-Object { if ($_.contains("High performance")) { $_.split()[3] } } 5 | 6 | # $HighPerf cannot be $null, we try activate this power profile with powercfg 7 | if ($null -eq $HighPerf) { 8 | throw "Error: HighPerf is null" 9 | } 10 | 11 | $CurrPlan = $(powercfg -getactivescheme).split()[3] 12 | 13 | if ($CurrPlan -ne $HighPerf) { powercfg -setactive $HighPerf } 14 | 15 | } 16 | Catch { 17 | Write-Warning -Message "Unable to set power plan to high performance" 18 | Write-Warning $Error[0] 19 | } 20 | -------------------------------------------------------------------------------- /nested/terraform/variables.tf: -------------------------------------------------------------------------------- 1 | # Settings 2 | 3 | variable "account" { 4 | default = "pckr" 5 | } 6 | 7 | variable "dns_prefix" { 8 | default = "pckr" 9 | } 10 | 11 | variable "location" { 12 | default = "westeurope" 13 | } 14 | 15 | variable "azure_dns_suffix" { 16 | description = "Azure DNS suffix for the Public IP" 17 | default = "cloudapp.azure.com" 18 | } 19 | 20 | variable "admin_username" { 21 | default = "vagrant" 22 | } 23 | 24 | variable "admin_password" { 25 | default = "Password1234!" 26 | } 27 | 28 | variable "count" { 29 | default = 1 30 | } 31 | 32 | variable "vm_size" { 33 | default = "Standard_E2s_v3" 34 | } 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows:1809 AS makeiso 2 | WORKDIR C:/source 3 | COPY . . 4 | RUN powershell -NoProfile -ExecutionPolicy unrestricted -file make_unattend_iso.ps1 5 | 6 | FROM mcr.microsoft.com/windows/servercore:ltsc2019 7 | ENV chocolateyUseWindowsCompression false 8 | 9 | RUN powershell -NoProfile -ExecutionPolicy unrestricted -Command \ 10 | iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')); \ 11 | choco feature disable --name showDownloadProgress 12 | RUN choco install -y packer 13 | RUN powershell -Command Install-WindowsFeature Hyper-V-PowerShell 14 | COPY --from=makeiso C:/source C:/source 15 | WORKDIR C:/source 16 | RUN powershell -File test.ps1 17 | -------------------------------------------------------------------------------- /README-ami.md: -------------------------------------------------------------------------------- 1 | ## Windows - Amazon Import AMIs 2 | 3 | VirtualBox Hypervisor is used to build a local vm and then imported as an AMI using 4 | the amazon import service https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html. 5 | 6 | ## Requirements 7 | 8 | * Set your aws credentials on the default location `~/.aws/credentials`. https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html 9 | * Packer 1.2.3+. https://www.packer.io/downloads.html 10 | * S3 Bucket with the necessary permissions. Set the `AWS_S3_BUCKET` environment variable. 11 | * If you use SAML authentication make sure you set `profile` in the amazon-import post-processor. 12 | * `vm-guest-tools` provisioner is removed. 13 | -------------------------------------------------------------------------------- /test.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop' 2 | 3 | "dummy" | Out-File path-to.vmx 4 | $env:PACKER_AZURE_AD_TENANT_ID = "dummy" 5 | $env:PACKER_AZURE_SUBSCRIPTION_ID = "dummy" 6 | $env:PACKER_AZURE_OBJECT_ID = "dummy" 7 | $env:PACKER_AZURE_APP_ID = "dummy" 8 | $env:PACKER_AZURE_CLIENT_SECRET = "dummy" 9 | $env:PACKER_AZURE_RESOURCE_GROUP = "dummy" 10 | $env:PACKER_AZURE_STORAGE_ACCOUNT = "dummy" 11 | $env:AWS_S3_BUCKET = "dummy" 12 | 13 | $files = @(Get-ChildItem *.json | Where-Object -FilterScript { $_.Name -ne "windows_7.json" }) 14 | 15 | foreach ($file in $files) { 16 | Write-Output "`n`nValidate $file" 17 | packer.exe validate -except=qemu $file 18 | if (-not $?) { 19 | throw "Packer validate found errors in $file!" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /scripts/compile-dotnet-assemblies.bat: -------------------------------------------------------------------------------- 1 | ::http://support.microsoft.com/kb/2570538 2 | ::http://robrelyea.wordpress.com/2007/07/13/may-be-helpful-ngen-exe-executequeueditems/ 3 | 4 | if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT 5 | 6 | %windir%\microsoft.net\framework\v4.0.30319\ngen.exe update /force /queue > NUL 7 | %windir%\microsoft.net\framework\v4.0.30319\ngen.exe executequeueditems > NUL 8 | 9 | exit 0 10 | 11 | :64BIT 12 | %windir%\microsoft.net\framework\v4.0.30319\ngen.exe update /force /queue > NUL 13 | %windir%\microsoft.net\framework64\v4.0.30319\ngen.exe update /force /queue > NUL 14 | %windir%\microsoft.net\framework\v4.0.30319\ngen.exe executequeueditems > NUL 15 | %windir%\microsoft.net\framework64\v4.0.30319\ngen.exe executequeueditems > NUL 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /scripts/win-7-update-net48.ps1: -------------------------------------------------------------------------------- 1 | New-Item -Path "C:\" -Name "Updates" -ItemType Directory 2 | 3 | Write-Output "$(Get-Date -Format G): Downloading .NET Framework 4.8" 4 | (New-Object Net.WebClient).DownloadFile("https://download.visualstudio.microsoft.com/download/pr/014120d7-d689-4305-befd-3cb711108212/0fd66638cde16859462a6243a4629a50/ndp48-x86-x64-allos-enu.exe", "C:\Updates\ndp48-x86-x64-allos-enu.exe") 5 | 6 | Write-Output "$(Get-Date -Format G): Installing .NET Framework 4.8" 7 | Start-Process -FilePath "C:\Updates\ndp48-x86-x64-allos-enu.exe" -ArgumentList "/quiet /norestart" -Wait 8 | 9 | Remove-Item -LiteralPath "C:\Updates" -Force -Recurse 10 | Write-Output "$(Get-Date -Format G): Finished installing .NET Framework 4.8. The VM will now reboot and continue the installation process." 11 | -------------------------------------------------------------------------------- /scripts/enable-winrm.ps1: -------------------------------------------------------------------------------- 1 | Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private 2 | 3 | Enable-PSRemoting -Force 4 | winrm quickconfig -q 5 | winrm quickconfig -transport:http 6 | winrm set winrm/config '@{MaxTimeoutms="1800000"}' 7 | winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}' 8 | winrm set winrm/config/service '@{AllowUnencrypted="true"}' 9 | winrm set winrm/config/service/auth '@{Basic="true"}' 10 | winrm set winrm/config/client/auth '@{Basic="true"}' 11 | winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}' 12 | netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes 13 | netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow remoteip=any 14 | Set-Service winrm -startuptype "auto" 15 | Restart-Service winrm 16 | -------------------------------------------------------------------------------- /scripts/hotfix-KB2842230.bat: -------------------------------------------------------------------------------- 1 | :: Windows 8 / Windows 2012 require KB2842230 hotfix 2 | :: The Windows Remote Management (WinRM) service does not use the customized value of the MaxMemoryPerShellMB quota. 3 | :: Instead, the WinRM service uses the default value, which is 150 MB. 4 | :: http://hotfixv4.microsoft.com/Windows%208%20RTM/nosp/Fix452763/9200/free/463941_intl_x64_zip.exe 5 | 6 | @echo off 7 | set hotfix="C:\Windows\Temp\Windows8-RT-KB2842230-x64.msu" 8 | if not exist %hotfix% goto :eof 9 | 10 | :: get windows version 11 | for /f "tokens=2 delims=[]" %%G in ('ver') do (set _version=%%G) 12 | for /f "tokens=2,3,4 delims=. " %%G in ('echo %_version%') do (set _major=%%G& set _minor=%%H& set _build=%%I) 13 | 14 | :: 6.2 or 6.3 15 | if %_major% neq 6 goto :eof 16 | if %_minor% lss 2 goto :eof 17 | if %_minor% gtr 3 goto :eof 18 | 19 | @echo on 20 | start /wait wusa "%hotfix%" /quiet /norestart -------------------------------------------------------------------------------- /scripts/docker/enable-winrm.ps1: -------------------------------------------------------------------------------- 1 | Enable-PSRemoting -Force 2 | winrm quickconfig -q 3 | winrm quickconfig -transport:http 4 | winrm set winrm/config '@{MaxTimeoutms="1800000"}' 5 | winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}' 6 | winrm set winrm/config/service '@{AllowUnencrypted="true"}' 7 | winrm set winrm/config/service/auth '@{Basic="true"}' 8 | winrm set winrm/config/client/auth '@{Basic="true"}' 9 | winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}' 10 | 11 | if (Test-Path A:\install-containers-feature.ps1) { 12 | . A:\install-containers-feature.ps1 13 | } 14 | 15 | Stop-Service winrm 16 | . sc.exe config winrm start= delayed-auto 17 | 18 | netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes 19 | netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow 20 | 21 | Restart-Computer 22 | -------------------------------------------------------------------------------- /scripts/enable-remote-desktop.bat: -------------------------------------------------------------------------------- 1 | rem from http://networkerslog.blogspot.de/2013/09/how-to-enable-remote-desktop-remotely.html 2 | 3 | rem 1) Enable Remote Desktop 4 | rem set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0 5 | reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v "fDenyTSConnections" /t REG_DWORD /d 0 /f 6 | 7 | rem 2) Allow incoming RDP on firewall 8 | rem Enable-NetFirewallRule -DisplayGroup "Remote Desktop" 9 | netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes 10 | 11 | rem 3) Enable secure RDP authentication 12 | rem set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0 13 | reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "UserAuthentication" /t REG_DWORD /d 0 /f 14 | 15 | -------------------------------------------------------------------------------- /scripts/dis-updates.bat: -------------------------------------------------------------------------------- 1 | rem http://www.windows-commandline.com/disable-automatic-updates-command-line/ 2 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f 3 | 4 | rem remove optional WSUS server settings 5 | reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /f 6 | 7 | rem even harder, disable windows update service 8 | rem sc config wuauserv start= disabled 9 | rem net stop wuauserv 10 | set logfile=C:\Windows\Temp\win-updates.log 11 | 12 | if exist %logfile% ( 13 | echo Show Windows Updates log file %logfile% 14 | dir %logfile% 15 | type %logfile% 16 | rem output of type command is not fully shown in packer/ssh session, so try PowerShell 17 | rem but it will hang if log file is about 22 KByte 18 | rem powershell -command "Get-Content %logfile%" 19 | echo End of Windows Updates log file %logfile% 20 | ) 21 | -------------------------------------------------------------------------------- /scripts/rsync.bat: -------------------------------------------------------------------------------- 1 | rem install rsync 2 | if not exist "C:\Windows\Temp\7z1900-x64.msi" ( 3 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z1900-x64.msi', 'C:\Windows\Temp\7z1900-x64.msi')" 8 | None 9 | .EXAMPLE 10 | ./Disable-WindowsUpdates.ps1 11 | #> 12 | $RunningAsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") 13 | if ($RunningAsAdmin) { 14 | 15 | $Updates = (New-Object -ComObject "Microsoft.Update.AutoUpdate").Settings 16 | 17 | if ($Updates.ReadOnly -eq $True) { Write-Error "Cannot update Windows Update settings due to GPO restrictions." } 18 | 19 | else { 20 | $Updates.NotificationLevel = 1 #Disabled 21 | $Updates.Save() 22 | $Updates.Refresh() 23 | Write-Output "Automatic Windows Updates disabled." 24 | } 25 | } 26 | 27 | else { 28 | Write-Warning "Must be executed in Administrator level shell." 29 | Write-Warning "Script Cancelled!" 30 | } 31 | -------------------------------------------------------------------------------- /README-shutdown_command.md: -------------------------------------------------------------------------------- 1 | # Packer shutdown_command 2 | There is an alternative for the normal Windows shutdown command. 3 | Normally we use something like this to shutdown the VM in packer. 4 | 5 | ```json 6 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 7 | ``` 8 | 9 | Replace it with 10 | 11 | ```json 12 | "shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:a:/unattend.xml", 13 | ``` 14 | 15 | Also make sure to add the `./scripts/unattend.xml` file to the `floppy_files`. 16 | 17 | On the first `vagrant up` the box will boot with an out-of-box-experience (OOBE) 18 | 19 | ## Windows Server 2016 20 | 21 | On newer systems like Windows 10 and Windows Server 2016 this shutdown_command is not enough. 22 | We also have to stop the "tiledatamodelsvc" service to make sysprep work. So we use a small cmd script. 23 | 24 | ```json 25 | "shutdown_command": "a:/sysprep.bat" 26 | ``` 27 | 28 | Also make sure to add the files `./scripts/unattend.xml` and `./scripts/sysprep.bat` to the `floppy_files`. 29 | 30 | On the first `vagrant up` the box will boot with an out-of-box-experience (OOBE) 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2014 Joe Fitzgerald 4 | Copyright (c) 2014 Stefan Scherer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: Visual Studio 2017 3 | 4 | install: 5 | - choco feature disable --name showDownloadProgress 6 | - choco install -y packer 7 | - ps: Install-WindowsFeature Hyper-V-PowerShell 8 | - ps: Install-PackageProvider -Name NuGet -Force 9 | - ps: Install-Module PsScriptAnalyzer -Force 10 | 11 | build_script: 12 | - ps: .\make_unattend_iso.ps1 13 | 14 | test_script: 15 | - ps: .\test.ps1 16 | - ps: | 17 | Add-AppveyorTest -Name "PsScriptAnalyzer" -Outcome Running 18 | $Results = Invoke-ScriptAnalyzer -Path $pwd -Recurse -ErrorAction SilentlyContinue 19 | If ($Results) { 20 | $ResultString = $Results | Out-String 21 | Write-Warning $ResultString 22 | Add-AppveyorMessage -Message "PSScriptAnalyzer output contained one or more result(s) with 'Error' severity.` 23 | Check the 'Tests' tab of this build for more details." -Category Error 24 | Update-AppveyorTest -Name "PsScriptAnalyzer" -Outcome Failed -ErrorMessage $ResultString 25 | Throw "Build failed. PsScriptAnalyzer found issues." 26 | } 27 | Else { 28 | Update-AppveyorTest -Name "PsScriptAnalyzer" -Outcome Passed 29 | } 30 | -------------------------------------------------------------------------------- /scripts/hotfix-KB2552055.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Windows 7 / Windows 2008 R2 require KB2552055 hotfix 3 | :: This fixes a problem with wrong exitcode 0 instead of custom exitcode in PowerShell 2.0 4 | setlocal 5 | if defined ProgramFiles(x86) ( 6 | set link=https://hotfixv4.microsoft.com/Windows%%207/Windows%%20Server2008%%20R2%%20SP1/sp2/Fix373932/7600/free/438167_intl_x64_zip.exe 7 | set msufilename=%TEMP%\Windows6.1-KB2552055-x64.msu 8 | ) else ( 9 | set link=https://hotfixv4.microsoft.com/Windows%%207/Windows%%20Server2008%%20R2%%20SP1/sp2/Fix373932/7600/free/438164_intl_i386_zip.exe 10 | set msufilename=%TEMP%\Windows6.1-KB2552055-x86.msu 11 | ) 12 | set zipfilename=%TEMP%\KB2552055.zip 13 | 14 | echo Downloading Hotfix 2552055 15 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%link%', '%zipfilename%')" = 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-81" 8 | config.vm.box = "windows_81" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | #v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | #v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 38 | v.whitelist_verified = true 39 | v.vmx["hgfs.linkRootShare"] = "FALSE" 40 | end 41 | 42 | config.vm.provider :vmware_workstation do |v, override| 43 | #v.gui = true 44 | v.vmx["memsize"] = "2048" 45 | v.vmx["numvcpus"] = "2" 46 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 47 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 48 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 49 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 50 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 51 | v.whitelist_verified = true 52 | v.vmx["hgfs.linkRootShare"] = "FALSE" 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /vagrantfile-windows_2012.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-2012" 8 | config.vm.box = "windows_2012" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | #v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | #v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 38 | v.whitelist_verified = true 39 | v.vmx["hgfs.linkRootShare"] = "FALSE" 40 | end 41 | 42 | config.vm.provider :vmware_workstation do |v, override| 43 | #v.gui = true 44 | v.vmx["memsize"] = "2048" 45 | v.vmx["numvcpus"] = "2" 46 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 47 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 48 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 49 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 50 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 51 | v.whitelist_verified = true 52 | v.vmx["hgfs.linkRootShare"] = "FALSE" 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /vagrantfile-windows_2008_r2.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-2008-r2" 8 | config.vm.box = "windows_2008_r2" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | #v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | #v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 38 | v.whitelist_verified = true 39 | v.vmx["hgfs.linkRootShare"] = "FALSE" 40 | end 41 | 42 | config.vm.provider :vmware_workstation do |v, override| 43 | #v.gui = true 44 | v.vmx["memsize"] = "2048" 45 | v.vmx["numvcpus"] = "2" 46 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 47 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 48 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 49 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 50 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 51 | v.whitelist_verified = true 52 | v.vmx["hgfs.linkRootShare"] = "FALSE" 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /vagrantfile-windows_2012_r2.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-2012-r2" 8 | config.vm.box = "windows_2012_r2" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | #v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | #v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 38 | v.whitelist_verified = true 39 | v.vmx["hgfs.linkRootShare"] = "FALSE" 40 | end 41 | 42 | config.vm.provider :vmware_workstation do |v, override| 43 | #v.gui = true 44 | v.vmx["memsize"] = "2048" 45 | v.vmx["numvcpus"] = "2" 46 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 47 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 48 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 49 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 50 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 51 | v.whitelist_verified = true 52 | v.vmx["hgfs.linkRootShare"] = "FALSE" 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /floppy/ReadMe.txt: -------------------------------------------------------------------------------- 1 | : Release v1.2 - Stuart Pearson 16th Nov 2015 2 | : 3 | : Command line tool to pin and unpin exe / lnk files to the Windows 10 taskbar and start menu. 4 | : 5 | : PinTo10 is a command line tool to pin and unpin .exe or .lnk files to or from the Windows 10 taskbar and start menu. 6 | : With it you can pin or unpin up to 10 different shortcuts to either the taskbar or start menu in one run of the command. 7 | : It replaces functionality that Microsoft have removed from their Windows 10 scripting interface. 8 | : 9 | : The exe needs to be run with at least one pair of switches specified for each function to Pin / Unpin to Taskbar / Start Menu... 10 | : 11 | : To pin an application or shortcut to the taskbar (replace XX with 01-10)... 12 | : /PTFOLXX: Followed by the folder containing the file you want to pin. 13 | : /PTFILEXX: Followed by the name of the file you want to pin. 14 | : 15 | : To unpin an application or shortcut to the taskbar (replace XX with 01-10)... 16 | : /UTFOLXX: Followed by the folder containing the file you want to unpin. 17 | : /UTFILEXX: Followed by the name of the file you want to unpin. 18 | 19 | : To pin an application or shortcut to the start menu (replace XX with 01-10)... 20 | : /PSFOLXX: Followed by the folder containing the file you want to pin. 21 | : /PSFILEXX: Followed by the name of the file you want to pin. 22 | 23 | : To unpin an application or shortcut to the start menu (replace XX with 01-10)... 24 | : /USFOLXX: Followed by the folder containing the file you want to unpin. 25 | : /USFILEXX: Followed by the name of the file you want to unpin. 26 | 27 | 28 | : Example for pinning two shortcuts to the taskbar... 29 | PinTo10.exe /PTFOL01:'%USERPROFILE:%\Desktop' /PTFILE01:'Word 2016.lnk' /PTFOL02:'%USERPROFILE:%\Desktop' /PTFILE02:'Excel 2016.lnk' 30 | 31 | : Example for unpinning a file to the taskbar... 32 | PinTo10.exe /UTFOL01:'C\Windows' /UTFILE01:'notepad.exe' 33 | 34 | : Example for pinning a file to the start menu... 35 | PinTo10.exe /PSFOL01:'C\Windows' /PSFILE01:'notepad.exe' 36 | 37 | : Example for unpinning a file from the start menu... 38 | PinTo10.exe /USFOL01:'%USERPROFILE:%\Desktop' /USFILE01:'Word 2016.lnk' -------------------------------------------------------------------------------- /nested/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | VAGRANTFILE_API_VERSION = "2" 5 | 6 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 7 | config.vm.box = "windows_10" 8 | config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true 9 | 10 | config.vm.communicator = "winrm" 11 | 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.synced_folder ".", "/vagrant", disabled: true 19 | config.vm.synced_folder "..", "/vagrant" 20 | 21 | config.vm.define "hyperv" do |cfg| 22 | cfg.vm.provision "shell", path: "scripts/install-hyperv.ps1", privileged: false 23 | cfg.vm.provision "reload" 24 | cfg.vm.provision "shell", path: "scripts/copy-templates.ps1", privileged: false 25 | cfg.vm.provision "shell", path: "scripts/install-tools.ps1", privileged: false 26 | end 27 | 28 | config.vm.define "virtualbox" do |cfg| 29 | cfg.vm.provision "shell", path: "scripts/copy-templates.ps1", privileged: false 30 | cfg.vm.provision "shell", path: "scripts/install-tools.ps1", privileged: false 31 | cfg.vm.provision "shell", path: "scripts/install-virtualbox.ps1", privileged: false 32 | cfg.vm.provision "reload" 33 | end 34 | 35 | ["vmware_fusion", "vmware_workstation"].each do |provider| 36 | config.vm.provider provider do |v, override| 37 | v.gui = true 38 | v.enable_vmrun_ip_lookup = false 39 | v.vmx["memsize"] = "6048" 40 | v.vmx["numvcpus"] = "2" 41 | v.vmx["vhv.enable"] = "TRUE" 42 | end 43 | end 44 | 45 | config.vm.provider "vmware_fusion" do |v| 46 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "TRUE" 47 | v.vmx["mks.enable3d"] = "TRUE" 48 | v.vmx["mks.forceDiscreteGPU"] = "TRUE" 49 | v.vmx["gui.fullscreenatpoweron"] = "TRUE" 50 | v.vmx["gui.viewmodeatpoweron"] = "fullscreen" 51 | v.vmx["gui.lastPoweredViewMode"] = "fullscreen" 52 | v.vmx["sound.startconnected"] = "TRUE" 53 | v.vmx["sound.present"] = "TRUE" 54 | v.vmx["sound.autodetect"] = "TRUE" 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /scripts/win-7-update-powershell-5.1.ps1: -------------------------------------------------------------------------------- 1 | function Expand-ZIPFile($file, $destination) { 2 | $shell = new-object -com shell.application 3 | $zip = $shell.NameSpace($file) 4 | foreach ($item in $zip.items()) { 5 | $shell.Namespace($destination).copyhere($item) 6 | } 7 | } 8 | 9 | New-Item -Path "C:\" -Name "Updates" -ItemType Directory 10 | 11 | Write-Output "$(Get-Date -Format G): Downloading Windows Management Framework 5.1" 12 | (New-Object Net.WebClient).DownloadFile("https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip", "C:\Updates\Win7AndW2K8R2-KB3191566-x64.zip") 13 | 14 | Write-Output "$(Get-Date -Format G): Installing Windows Management Framework 5.1" 15 | Expand-ZipFile "C:\Updates\Win7AndW2K8R2-KB3191566-x64.zip" -destination "C:\Updates" 16 | 17 | Write-Output "$(Get-Date -Format G): Extracting $update" 18 | Start-Process -FilePath "wusa.exe" -ArgumentList "C:\Updates\Win7AndW2K8R2-KB3191566-x64.msu /extract:C:\Updates" -Wait 19 | 20 | Write-Output "$(Get-Date -Format G): Installing $update" 21 | Start-Process -FilePath "dism.exe" -ArgumentList "/online /add-package /PackagePath:C:\Updates\Windows6.1-KB2809215-x64.cab /quiet /norestart /LogPath:C:\Windows\Temp\KB2809215-x64.log" -Wait 22 | Start-Process -FilePath "dism.exe" -ArgumentList "/online /add-package /PackagePath:C:\Updates\Windows6.1-KB2872035-x64.cab /quiet /norestart /LogPath:C:\Windows\Temp\KB2872035-x64.log" -Wait 23 | Start-Process -FilePath "dism.exe" -ArgumentList "/online /add-package /PackagePath:C:\Updates\Windows6.1-KB2872047-x64.cab /quiet /norestart /LogPath:C:\Windows\Temp\KB2872047-x64.log" -Wait 24 | Start-Process -FilePath "dism.exe" -ArgumentList "/online /add-package /PackagePath:C:\Updates\Windows6.1-KB3033929-x64.cab /quiet /norestart /LogPath:C:\Windows\Temp\KB3033929-x64.log" -Wait 25 | Start-Process -FilePath "dism.exe" -ArgumentList "/online /add-package /PackagePath:C:\Updates\Windows6.1-KB3191566-x64.cab /quiet /norestart /LogPath:C:\Windows\Temp\KB3191566-x64.log" -Wait 26 | 27 | # Remove-Item -LiteralPath "C:\Updates" -Force -Recurse 28 | 29 | Write-Output "$(Get-Date -Format G): Finished installing Windows Management Framework 5.1. The VM will now reboot and continue the installation process." 30 | -------------------------------------------------------------------------------- /bin/test-box-virtualbox.bat: -------------------------------------------------------------------------------- 1 | rem 2 | rem bin\test-box-virtualbox.bat ubuntu1204_virtualbox.box ubuntu1204 3 | set quick=0 4 | 5 | if "%1x"=="--quickx" ( 6 | shift 7 | set quick=1 8 | ) 9 | set box_path=%1 10 | set box_name=%2 11 | set box_provider=virtualbox 12 | set vagrant_provider=virtualbox 13 | 14 | set result=0 15 | 16 | set tmp_path=boxtest 17 | if exist %tmp_path% rmdir /s /q %tmp_path% 18 | 19 | if %quick%==1 goto :do_test 20 | 21 | rem vagrant plugin install vagrant-serverspec 22 | 23 | vagrant box remove %box_name% --provider=%vagrant_provider% 24 | vagrant box add %box_name% %box_path% 25 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 26 | if ERRORLEVEL 1 goto :done 27 | 28 | if "%VAGRANT_HOME%x"=="x" set VAGRANT_HOME=%USERPROFILE%\.vagrant.d 29 | 30 | :do_test 31 | set result=0 32 | 33 | mkdir %tmp_path% 34 | pushd %tmp_path% 35 | call :create_vagrantfile 36 | echo USERPROFILE = %USERPROFILE% 37 | if exist %USERPROFILE%\.ssh\known_hosts type %USERPROFILE%\.ssh\known_hosts 38 | del /F %USERPROFILE%\.ssh\known_hosts 39 | if exist %USERPROFILE%\.ssh\known_hosts echo known_hosts still here!! 40 | vagrant up --provider=%vagrant_provider% 41 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 42 | 43 | @echo Sleep 10 seconds 44 | @ping 1.1.1.1 -n 1 -w 10000 > nul 45 | 46 | vagrant destroy -f 47 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 48 | popd 49 | 50 | if %quick%==1 goto :done 51 | 52 | vagrant box remove %box_name% --provider=%vagrant_provider% 53 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 54 | 55 | goto :done 56 | 57 | :create_vagrantfile 58 | 59 | rem to test if rsync / shared folder works 60 | if not exist testdir\testfile.txt ( 61 | mkdir testdir 62 | echo Works >testdir\testfile.txt 63 | ) 64 | 65 | echo Vagrant.configure('2') do ^|config^| >Vagrantfile 66 | echo config.vm.define :"tst" do ^|tst^| >>Vagrantfile 67 | echo tst.vm.box = "%box_name%" >>Vagrantfile 68 | echo tst.vm.hostname = "tst" 69 | echo tst.vm.provision :serverspec do ^|spec^| >>Vagrantfile 70 | echo spec.pattern = '../test/*_%box_provider%.rb' >>Vagrantfile 71 | echo end >>Vagrantfile 72 | echo end >>Vagrantfile 73 | echo end >>Vagrantfile 74 | 75 | exit /b 76 | 77 | :done 78 | exit %result% 79 | -------------------------------------------------------------------------------- /vagrantfile-windows_2016_core.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-2016" 8 | config.vm.box = "windows_2016" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | #v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["virtualhw.version"] = "14" 38 | v.enable_vmrun_ip_lookup = false 39 | v.whitelist_verified = true 40 | v.vmx["hgfs.linkRootShare"] = "FALSE" 41 | end 42 | 43 | config.vm.provider :vmware_workstation do |v, override| 44 | #v.gui = true 45 | v.vmx["memsize"] = "2048" 46 | v.vmx["numvcpus"] = "2" 47 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 48 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 49 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 50 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 51 | v.enable_vmrun_ip_lookup = false 52 | v.whitelist_verified = true 53 | v.vmx["hgfs.linkRootShare"] = "FALSE" 54 | end 55 | 56 | config.vm.provider "hyperv" do |v| 57 | v.cpus = 2 58 | v.maxmemory = 2048 59 | v.linked_clone = true 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /scripts/docker/chocolatey-and-tools.ps1: -------------------------------------------------------------------------------- 1 | 2 | Write-Output 'Do not open Server Manager at logon' 3 | New-ItemProperty -Path HKCU:\Software\Microsoft\ServerManager -Name DoNotOpenServerManagerAtLogon -PropertyType DWORD -Value "1" -Force 4 | 5 | Write-Output 'Install bginfo' 6 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 7 | 8 | if (!(Test-Path 'c:\Program Files\sysinternals')) { 9 | New-Item -Path 'c:\Program Files\sysinternals' -type directory -Force -ErrorAction SilentlyContinue 10 | } 11 | if (!(Test-Path 'c:\Program Files\sysinternals\bginfo.exe')) { 12 | (New-Object Net.WebClient).DownloadFile('https://live.sysinternals.com/bginfo.exe', 'c:\Program Files\sysinternals\bginfo.exe') 13 | } 14 | if (!(Test-Path 'c:\Program Files\sysinternals\bginfo.bgi')) { 15 | (New-Object Net.WebClient).DownloadFile('https://github.com/StefanScherer/windows-docker-workshop/raw/master/prepare-vms/azure/packer/bginfo.bgi', 'c:\Program Files\sysinternals\bginfo.bgi') 16 | } 17 | if (!(Test-Path 'c:\Program Files\sysinternals\background.jpg')) { 18 | (New-Object Net.WebClient).DownloadFile('https://github.com/StefanScherer/windows-docker-workshop/raw/master/prepare-vms/azure/packer/background.jpg', 'c:\Program Files\sysinternals\background.jpg') 19 | } 20 | $vbsScript = @' 21 | WScript.Sleep 2000 22 | Dim objShell 23 | Set objShell = WScript.CreateObject( "WScript.Shell" ) 24 | objShell.Run("""c:\Program Files\sysinternals\bginfo.exe"" /accepteula ""c:\Program Files\sysinternals\bginfo.bgi"" /silent /timer:0") 25 | '@ 26 | $vbsScript | Out-File 'c:\Program Files\sysinternals\bginfo.vbs' 27 | Set-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run -Name bginfo -Value 'wscript "c:\Program Files\sysinternals\bginfo.vbs"' 28 | wscript "c:\Program Files\sysinternals\bginfo.vbs" 29 | 30 | Write-Output 'Install Chocolatey' 31 | Invoke-WebRequest 'https://chocolatey.org/install.ps1' -UseBasicParsing -OutFile $env:TEMP\install.ps1 32 | .\$env:TEMP\install.ps1 33 | Remove-Item $env:TEMP\install.ps1 -Force -ErrorAction SilentlyContinue 34 | 35 | Write-Output 'Install editors' 36 | choco install -y visualstudiocode 37 | 38 | Write-Output 'Install Git' 39 | choco install -y git 40 | 41 | Write-Output 'Install browsers' 42 | choco install -y googlechrome 43 | choco install -y firefox 44 | 45 | Write-Output 'Install Docker Compose' 46 | choco install -y docker-compose 47 | -------------------------------------------------------------------------------- /nested/README.md: -------------------------------------------------------------------------------- 1 | # nested 2 | 3 | With this Vagrant environment you can build for other hypervisors in a nested 4 | VMware VM. Or you can have a look at the provision scripts how to install 5 | all tools needed on bare metal. 6 | 7 | ## Preparation 8 | 9 | On your host with VMware. 10 | 11 | ### Build the Windows 10 VMware base box 12 | 13 | Build the Windows 10 base box for VMware Fusion/Workstation with 100GByte disk size. 14 | 15 | ```bash 16 | cd .. 17 | packer build --only=vmware-iso -var disk_size=102400 windows_10.json 18 | vagrant box add windows_10 windows_10_vmware.box 19 | ``` 20 | 21 | ## Hyper-V 22 | 23 | Now build the Vagrant environment with Hyper-V and packer in a Windows 10 VM. 24 | 25 | ```bash 26 | cd nested 27 | vagrant up hyperv 28 | ``` 29 | 30 | ### Build a Hyper-V Vagrant box 31 | 32 | In the nested Windows 10 VM with Hyper-V first create an external virtual 33 | switch in Hyper-V Manager. Then you can run Packer builds. 34 | 35 | ```powershell 36 | cd C:\Users\vagrant\packer-windows 37 | packer build --only=hyperv-iso --var hyperv_switchname=ext windows_2016_docker.iso 38 | ``` 39 | 40 | You can copy the boxes produced back to C:\vagrant folder 41 | that is a shared folder of the host. 42 | 43 | ### Run the Hyper-V VM in Windows 10 44 | 45 | ```powershell 46 | vagrant box add windows_2016_docker windows_2016_docker_hyperv.box 47 | cd C:\Users\vagrant 48 | git clone https://github.com/StefanScherer/docker-windows-box 49 | cd docker-windows-box 50 | vagrant up 51 | ``` 52 | 53 | ## VirtualBox 54 | 55 | Now build the Vagrant environment with VirtualBox and packer in a Windows 10 VM. 56 | 57 | ```bash 58 | cd nested 59 | vagrant up virtualbox 60 | ``` 61 | 62 | ### Build a VirtualBox Vagrant box 63 | 64 | In the nested Windows 10 VM with VirtualBox installed you can run Packer builds. 65 | 66 | ```powershell 67 | cd C:\Users\vagrant\packer-windows 68 | packer build --only=virtualbox-iso windows_2016_docker.iso 69 | ``` 70 | 71 | You can copy the boxes produced back to C:\vagrant folder 72 | that is a shared folder of the host. 73 | 74 | ### Run the VirtualBox VM in Windows 10 75 | 76 | ```powershell 77 | vagrant box add windows_2016_docker windows_2016_docker_virtualbox.box 78 | cd C:\Users\vagrant 79 | git clone https://github.com/StefanScherer/docker-windows-box 80 | cd docker-windows-box 81 | vagrant up 82 | ``` 83 | -------------------------------------------------------------------------------- /vagrantfile-windows_2019_core.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-2019" 8 | config.vm.box = "windows_2019" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | #v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["virtualhw.version"] = "14" 38 | v.enable_vmrun_ip_lookup = false 39 | v.whitelist_verified = true 40 | v.vmx["hgfs.linkRootShare"] = "FALSE" 41 | end 42 | 43 | config.vm.provider :vmware_workstation do |v, override| 44 | #v.gui = true 45 | v.vmx["memsize"] = "2048" 46 | v.vmx["numvcpus"] = "2" 47 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 48 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 49 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 50 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 51 | v.enable_vmrun_ip_lookup = false 52 | v.whitelist_verified = true 53 | v.vmx["hgfs.linkRootShare"] = "FALSE" 54 | end 55 | 56 | config.vm.provider "hyperv" do |v| 57 | v.cpus = 2 58 | v.maxmemory = 2048 59 | v.linked_clone = true 60 | end 61 | 62 | config.vm.provider :libvirt do |libvirt| 63 | libvirt.memory = 2048 64 | libvirt.cpus = 2 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /bin/upload-vcloud.bat: -------------------------------------------------------------------------------- 1 | set BUILD=%1 2 | 3 | if "%BUILD%x"=="uploadx" ( 4 | set BUILD=%2 5 | ) 6 | 7 | @if "%BUILD:~-7%" == "_vcloud" ( 8 | set boxname=%BUILD:~0,-7% 9 | set template=%BUILD% 10 | ) 11 | 12 | @if "%boxname%x"=="x" ( 13 | echo Wrong build parameter! 14 | set result=1 15 | goto :EOF 16 | ) 17 | 18 | @echo. 19 | @echo boxname = %boxname% 20 | @echo template = %template% 21 | @echo. 22 | 23 | set box_filename=%boxname%_vcloud.box 24 | set box_provider=vcloud 25 | 26 | set result=0 27 | 28 | vagrant box remove %boxname% --provider=%box_provider% 29 | if exist %box_filename% ( 30 | echo "Use %box_filename% from current dir" 31 | vagrant box add %boxname% %box_filename% 32 | ) else ( 33 | echo "Use %box_filename% from other jenkins workspace dir" 34 | vagrant box add %boxname% c:\jenkins\workspace\%boxname%_%box_provider%\%box_filename% 35 | ) 36 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 37 | if ERRORLEVEL 1 goto :done 38 | 39 | @set vcloud_hostname=roecloud001 40 | 41 | if "%VAGRANT_HOME%x"=="x" set VAGRANT_HOME=%USERPROFILE%\.vagrant.d 42 | 43 | @set vcloud_hostname=YOUR-VCLOUD 44 | @set vcloud_username=YOUR-UPLOAD-USER 45 | @set vcloud_password=S@perS$cretP1ass 46 | @set vcloud_org=YOUR-GLOBAL-ORG 47 | @set vcloud_catalog=YOUR-GLOBAL-CATALOG 48 | @set vcloud_vdc=YOUR-GLOBAL-VDC 49 | 50 | if exist c:\vagrant\resources\upload-vcloud-credentials.bat call c:\vagrant\resources\upload-vcloud-credentials.bat 51 | 52 | echo Uploading %boxname%.ovf to vCloud %vcloud_hostname% / %vcloud_org% / %vcloud_catalog% / %boxname% 53 | @ovftool --acceptAllEulas --vCloudTemplate --overwrite %VAGRANT_HOME%\boxes\%boxname%\0\%box_provider%\%boxname%.ovf "vcloud://%vcloud_username%:%vcloud_password%@%vcloud_hostname%:443?org=%vcloud_org%&vappTemplate=%boxname%&catalog=%vcloud_catalog%&vdc=%vcloud_vdc%" 54 | if ERRORLEVEL 1 goto :first_upload 55 | goto :uploaded 56 | :first_upload 57 | @ovftool --acceptAllEulas --vCloudTemplate %VAGRANT_HOME%\boxes\%boxname%\0\%box_provider%\%boxname%.ovf "vcloud://%vcloud_username%:%vcloud_password%@%vcloud_hostname%:443?org=%vcloud_org%&vappTemplate=%boxname%&catalog=%vcloud_catalog%&vdc=%vcloud_vdc%" 58 | if ERRORLEVEL 1 goto :error_vcloud_upload 59 | 60 | :uploaded 61 | vagrant box remove %boxname% --provider=%box_provider% 62 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 63 | 64 | :error_vcloud_upload 65 | echo Error Uploading box to vCloud with ovftool! 66 | set result=%ERRORLEVEL% 67 | goto :done 68 | 69 | :done 70 | exit %result% 71 | -------------------------------------------------------------------------------- /test/windows_vmware.rb: -------------------------------------------------------------------------------- 1 | require_relative 'spec_helper' 2 | 3 | describe 'box' do 4 | describe 'windows box' do 5 | it 'should have a vagrant user' do 6 | expect(user 'vagrant').to exist 7 | end 8 | end 9 | 10 | # this tests if rsync (or at least the shared folder) works from bin/test-box-vcloud.bat 11 | describe file('c:/vagrant/testdir/testfile.txt') do 12 | it { should be_file } 13 | it { should contain "Works" } 14 | end 15 | 16 | # check SSH 17 | describe service('OpenSSH Server') do 18 | it { should be_installed } 19 | it { should be_enabled } 20 | it { should be_running } 21 | it { should have_start_mode("Automatic") } 22 | end 23 | describe port(22) do 24 | it { should be_listening } 25 | end 26 | 27 | describe service('VMware Tools') do 28 | it { should be_installed } 29 | it { should be_enabled } 30 | it { should be_running } 31 | it { should have_start_mode("Automatic") } 32 | end 33 | 34 | # check WinRM 35 | describe port(5985) do 36 | it { should be_listening } 37 | end 38 | 39 | # check RDP 40 | describe port(3389) do 41 | it { should be_listening } 42 | end 43 | describe windows_registry_key('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\fDenyTSConnections') do 44 | it { should exist } 45 | it { should have_property('dword value', :type_dword) } 46 | it { should have_value('0') } 47 | end 48 | describe windows_registry_key('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\UserAuthentication') do 49 | it { should exist } 50 | it { should have_property('dword value', :type_dword) } 51 | it { should have_value('0') } 52 | end 53 | 54 | # no Windows Updates, just manual updates, but Windows updates service is running 55 | describe service('Windows Update') do 56 | it { should be_installed } 57 | it { should be_enabled } 58 | it { should be_running } 59 | it { should have_start_mode("Automatic") } 60 | end 61 | describe windows_registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions') do 62 | it { should exist } 63 | it { should have_property('dword value', :type_dword) } 64 | it { should have_value('1') } 65 | end 66 | 67 | # check time zone 68 | describe command('& tzutil /g') do 69 | it { should return_stdout(/W. Europe Standard Time/) } 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /test/windows_virtualbox.rb: -------------------------------------------------------------------------------- 1 | require_relative 'spec_helper' 2 | 3 | describe 'box' do 4 | describe 'windows box' do 5 | it 'should have a vagrant user' do 6 | expect(user 'vagrant').to exist 7 | end 8 | end 9 | 10 | # this tests if rsync (or at least the shared folder) works from bin/test-box-vcloud.bat 11 | describe file('c:/vagrant/testdir/testfile.txt') do 12 | it { should be_file } 13 | it { should contain "Works" } 14 | end 15 | 16 | # check SSH 17 | describe service('OpenSSH Server') do 18 | it { should be_installed } 19 | it { should be_enabled } 20 | it { should be_running } 21 | it { should have_start_mode("Automatic") } 22 | end 23 | describe port(22) do 24 | it { should be_listening } 25 | end 26 | 27 | describe service('VirtualBox Guest Additions Service') do 28 | it { should be_installed } 29 | it { should be_enabled } 30 | it { should be_running } 31 | it { should have_start_mode("Automatic") } 32 | end 33 | 34 | # check WinRM 35 | describe port(5985) do 36 | it { should be_listening } 37 | end 38 | 39 | # check RDP 40 | describe port(3389) do 41 | it { should be_listening } 42 | end 43 | describe windows_registry_key('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\fDenyTSConnections') do 44 | it { should exist } 45 | it { should have_property('dword value', :type_dword) } 46 | it { should have_value('0') } 47 | end 48 | describe windows_registry_key('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\UserAuthentication') do 49 | it { should exist } 50 | it { should have_property('dword value', :type_dword) } 51 | it { should have_value('0') } 52 | end 53 | 54 | # no Windows Updates, just manual updates, but Windows updates service is running 55 | describe service('Windows Update') do 56 | it { should be_installed } 57 | it { should be_enabled } 58 | it { should be_running } 59 | it { should have_start_mode("Automatic") } 60 | end 61 | describe windows_registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions') do 62 | it { should exist } 63 | it { should have_property('dword value', :type_dword) } 64 | it { should have_value('1') } 65 | end 66 | 67 | # check time zone 68 | describe command('& tzutil /g') do 69 | it { should return_stdout(/W. Europe Standard Time/) } 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /bin/test-box-vmware.bat: -------------------------------------------------------------------------------- 1 | rem 2 | rem bin\test-box-vmware.bat ubuntu1204_vmware.box ubuntu1204 3 | set quick=0 4 | 5 | if "%1x"=="--quickx" ( 6 | shift 7 | set quick=1 8 | ) 9 | set box_path=%1 10 | set box_name=%2 11 | set box_suffix=vmware 12 | set box_provider=vmware_desktop 13 | set vagrant_provider=vmware_workstation 14 | set vagrant_plugin=vagrant-vmware-workstation 15 | 16 | set result=0 17 | if "%VAGRANT_HOME%x"=="x" set VAGRANT_HOME=%USERPROFILE%\.vagrant.d 18 | 19 | set tmp_path=boxtest 20 | if exist %tmp_path% rmdir /s /q %tmp_path% 21 | 22 | if %quick%==1 goto :do_test 23 | 24 | rem vagrant plugin install vagrant-serverspec 25 | rem vagrant plugin install %vagrant_plugin% 26 | if exist c:\vagrant\resources\license.lic ( 27 | if not exist %VAGRANT_HOME%\license-%vagrant_plugin%.lic ( 28 | vagrant plugin license %vagrant_plugin% c:\vagrant\resources\license.lic 29 | ) 30 | ) 31 | vagrant box remove %box_name% --provider=%box_provider% 32 | vagrant box add %box_name% %box_path% 33 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 34 | if ERRORLEVEL 1 goto :done 35 | 36 | :do_test 37 | set result=0 38 | 39 | mkdir %tmp_path% 40 | pushd %tmp_path% 41 | call :create_vagrantfile 42 | echo USERPROFILE = %USERPROFILE% 43 | if exist %USERPROFILE%\.ssh\known_hosts type %USERPROFILE%\.ssh\known_hosts 44 | del /F %USERPROFILE%\.ssh\known_hosts 45 | if exist %USERPROFILE%\.ssh\known_hosts echo known_hosts still here!! 46 | vagrant up --provider=%vagrant_provider% 47 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 48 | 49 | @echo Sleep 10 seconds 50 | @ping 1.1.1.1 -n 1 -w 10000 > nul 51 | 52 | vagrant destroy -f 53 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 54 | popd 55 | 56 | if %quick%==1 goto :done 57 | 58 | vagrant box remove %box_name% --provider=%box_provider% 59 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 60 | 61 | goto :done 62 | 63 | :create_vagrantfile 64 | 65 | rem to test if rsync / shared folder works 66 | if not exist testdir\testfile.txt ( 67 | mkdir testdir 68 | echo Works >testdir\testfile.txt 69 | ) 70 | 71 | echo Vagrant.configure('2') do ^|config^| >Vagrantfile 72 | echo config.vm.define :"tst" do ^|tst^| >>Vagrantfile 73 | echo tst.vm.box = "%box_name%" >>Vagrantfile 74 | echo tst.vm.hostname = "tst" 75 | echo tst.vm.provision :serverspec do ^|spec^| >>Vagrantfile 76 | echo spec.pattern = '../test/*_%box_suffix%.rb' >>Vagrantfile 77 | echo end >>Vagrantfile 78 | echo end >>Vagrantfile 79 | echo end >>Vagrantfile 80 | 81 | exit /b 82 | 83 | :done 84 | exit %result% 85 | -------------------------------------------------------------------------------- /windows_2016_docker_azure.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "capture_container_name": "images", 5 | "capture_name_prefix": "WindowsServer2016Docker", 6 | "client_id": "{{user `app_id`}}", 7 | "client_secret": "{{user `client_secret`}}", 8 | "cloud_environment_name": "Public", 9 | "communicator": "winrm", 10 | "image_offer": "WindowsServer", 11 | "image_publisher": "MicrosoftWindowsServer", 12 | "image_sku": "2016-Datacenter", 13 | "image_version": "latest", 14 | "location": "West Europe", 15 | "object_id": "{{user `object_id`}}", 16 | "os_type": "Windows", 17 | "resource_group_name": "{{user `resource_group`}}", 18 | "storage_account": "{{user `storage_account`}}", 19 | "subscription_id": "{{user `azure_subscription_id`}}", 20 | "tenant_id": "{{user `azure_ad_tenant_id`}}", 21 | "type": "azure-arm", 22 | "vm_size": "Standard_D2_v2", 23 | "winrm_insecure": "true", 24 | "winrm_timeout": "3m", 25 | "winrm_use_ssl": "true", 26 | "winrm_username": "packer" 27 | } 28 | ], 29 | "post-processors": [], 30 | "provisioners": [ 31 | { 32 | "scripts": [ 33 | "./scripts/docker/2016/install-containers-feature.ps1" 34 | ], 35 | "type": "powershell" 36 | }, 37 | { 38 | "type": "windows-restart" 39 | }, 40 | { 41 | "environment_vars": [ 42 | "docker_images={{user `docker_images`}}", 43 | "docker_provider={{user `docker_provider`}}", 44 | "docker_version={{user `docker_version`}}" 45 | ], 46 | "scripts": [ 47 | "./scripts/docker/add-docker-group.ps1", 48 | "./scripts/docker/disable-windows-defender.ps1", 49 | "./scripts/docker/install-docker.ps1", 50 | "./scripts/docker/docker-pull.ps1", 51 | "./scripts/docker/remove-docker-key-json.ps1" 52 | ], 53 | "type": "powershell" 54 | } 55 | ], 56 | "variables": { 57 | "app_id": "{{env `PACKER_AZURE_APP_ID`}}", 58 | "azure_ad_tenant_id": "{{env `PACKER_AZURE_AD_TENANT_ID`}}", 59 | "azure_subscription_id": "{{env `PACKER_AZURE_SUBSCRIPTION_ID`}}", 60 | "client_secret": "{{env `PACKER_AZURE_CLIENT_SECRET`}}", 61 | "docker_images": "mcr.microsoft.com/windows/servercore:ltsc2016", 62 | "docker_provider": "DockerProvider", 63 | "docker_version": "stable", 64 | "headless": "false", 65 | "object_id": "{{env `PACKER_AZURE_OBJECT_ID`}}", 66 | "resource_group": "{{env `PACKER_AZURE_RESOURCE_GROUP`}}", 67 | "storage_account": "{{env `PACKER_AZURE_STORAGE_ACCOUNT`}}" 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /scripts/unattend.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0 6 | 7 | 13 | 14 | 15 | 16 | 17 | true 18 | 3 19 | Work 20 | true 21 | true 22 | true 23 | 24 | 25 | 26 | vagrant 27 | true</PlainText> 28 | </Password> 29 | <Enabled>true</Enabled> 30 | <LogonCount>1</LogonCount> 31 | <Username>vagrant</Username> 32 | </AutoLogon> 33 | </component> 34 | </settings> 35 | <settings pass="specialize"> 36 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 37 | <ComputerName>vagrant</ComputerName> 38 | <CopyProfile>false</CopyProfile> 39 | </component> 40 | </settings> 41 | </unattend> 42 | -------------------------------------------------------------------------------- /nested/terraform/README.md: -------------------------------------------------------------------------------- 1 | # Packer Hyper-V builder in Azure 2 | 3 | This is a Terraform template to spin up a VM in Azure that has nested Hyper-V 4 | activated and tools like Git, Packer and Vagrant installed. 5 | 6 | Now you are able to build Vagrant base boxes for Hyper-V in the Cloud with Packer. 7 | 8 | ## Stage 1: Spin up the Azure VM with Terraform 9 | 10 | ### Install Terraform 11 | 12 | ``` 13 | brew install terraform 14 | ``` 15 | 16 | ### Secrets 17 | 18 | Get your Azure ID's and secret with `pass` 19 | 20 | ``` 21 | eval $(pass azure-terraform) 22 | ``` 23 | 24 | You will need these environment variables for terraform 25 | 26 | ``` 27 | export ARM_SUBSCRIPTION_ID="uuid" 28 | export ARM_CLIENT_ID="uuid" 29 | export ARM_CLIENT_SECRET="secret" 30 | export ARM_TENANT_ID="uuid" 31 | ``` 32 | 33 | ### Configure 34 | 35 | Adjust the file `variables.tf` to your needs to choose 36 | 37 | - location / region 38 | - DNS prefix and suffix 39 | - size of the VM's, default is `Standard_E2s_v3` which is needed for nested virtualization 40 | - username and password 41 | 42 | ### Plan 43 | 44 | ```bash 45 | terraform plan 46 | ``` 47 | 48 | ### Create / Apply 49 | 50 | Create the Azure VM with. After 5 minutes the VM should be up and running, and the provision.ps1 script will run inside the VM to install Packer, Vagrant, Hyper-V and then reboots the VM and adds the internal virtual switch 'packer-hyperv-iso' and DHCP server. 51 | 52 | ```bash 53 | terraform apply 54 | ``` 55 | 56 | If you want more than one Packer VM, then use eg. `terraform apply -var count=3`. 57 | 58 | ## Stage 2: Packer build 59 | 60 | Now RDP into the Azure VM `pckr-01.westeurope.cloudapp.azure.com` (the dns_prefix is specified in `variables.tf`). Open a PowerShell terminal and clone my packer-windows repo or any other repo with a Packer template for Hyper-V. 61 | 62 | ``` 63 | git clone https://github.com/StefanScherer/packer-windows 64 | cd packer-windows 65 | packer build --only=hyperv-iso windows_2016_docker.json 66 | ``` 67 | 68 | Packer uses the internal Hyper-V virtual switch with name "packer-hyperv-iso" which was creating during the provisioning of the Azure VM. Packer now downloads the eval ISO file and boots a Hyper-V VM to run the whole packer build configuration. 69 | 70 | ## Stage 3: Vagrant up 71 | 72 | You could also try to run it in this Azure VM with 73 | 74 | ``` 75 | vagrant box add windows_2016_docker windows_2016_docker_hyperv.box 76 | cd .. 77 | git clone https://github.com/StefanScherer/docker-windows-box 78 | cd docker-windows-box 79 | vagrant up 80 | vagrant rdp 81 | ``` 82 | 83 | ### packer push 84 | 85 | Now you can push the Vagrant box to Vagrant Cloud (https://app.vagrantup.com). 86 | -------------------------------------------------------------------------------- /test/windows_vcloud.rb: -------------------------------------------------------------------------------- 1 | require_relative 'spec_helper' 2 | 3 | describe 'box' do 4 | describe 'windows box' do 5 | it 'should have a vagrant user' do 6 | expect(user 'vagrant').to exist 7 | end 8 | end 9 | 10 | # this tests if rsync works from bin/test-box-vcloud.bat 11 | describe file('c:/vagrant/testdir/testfile.txt') do 12 | it { should be_file } 13 | it { should contain "Works" } 14 | end 15 | 16 | describe command('& rsync --version') do 17 | it { should return_stdout(/rsync *version *3.1.0/) } 18 | end 19 | 20 | # check SSH 21 | describe service('OpenSSH Server') do 22 | it { should be_installed } 23 | it { should be_enabled } 24 | it { should be_running } 25 | it { should have_start_mode("Automatic") } 26 | end 27 | describe port(22) do 28 | it { should be_listening } 29 | end 30 | 31 | describe service('VMware Tools') do 32 | it { should be_installed } 33 | it { should be_enabled } 34 | it { should be_running } 35 | it { should have_start_mode("Automatic") } 36 | end 37 | 38 | # check WinRM 39 | describe port(5985) do 40 | it { should be_listening } 41 | end 42 | 43 | # check RDP 44 | describe port(3389) do 45 | it { should be_listening } 46 | end 47 | describe windows_registry_key('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\fDenyTSConnections') do 48 | it { should exist } 49 | it { should have_property('dword value', :type_dword) } 50 | it { should have_value('0') } 51 | end 52 | describe windows_registry_key('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\UserAuthentication') do 53 | it { should exist } 54 | it { should have_property('dword value', :type_dword) } 55 | it { should have_value('0') } 56 | end 57 | 58 | # check for 10 GBit vmxnet3 network adapter 59 | describe command('& "ipconfig" /all') do 60 | it { should return_stdout(/Description(\.| )*: vmxnet3/) } 61 | end 62 | 63 | # no Windows Updates, just manual updates, but Windows updates service is running 64 | describe service('Windows Update') do 65 | it { should be_installed } 66 | it { should be_enabled } 67 | it { should be_running } 68 | it { should have_start_mode("Automatic") } 69 | end 70 | describe windows_registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions') do 71 | it { should exist } 72 | it { should have_property('dword value', :type_dword) } 73 | it { should have_value('1') } 74 | end 75 | 76 | # check time zone 77 | describe command('& tzutil /g') do 78 | it { should return_stdout(/W. Europe Standard Time/) } 79 | end 80 | 81 | end 82 | -------------------------------------------------------------------------------- /README-rsync.md: -------------------------------------------------------------------------------- 1 | # How to enable RSync for Windows Templates 2 | 3 | ## Introduction 4 | 5 | This document explains how to install RSync into the Windows boxes to be able to use Vagrant's synced folder type `rsync`. Read the [Vagrant Docs](https://docs.vagrantup.com/v2/synced-folders/rsync.html) for more details and the additional vagrant commands. 6 | 7 | ## Prerequisites 8 | 9 | ### SSH 10 | 11 | To use `rsync` in the Windows boxes you also will need that SSH is installed and enabled. At the time of writing OpenSSH will always be installed to make the packer build work. This is part of the `Autounattend.xml` answer files. 12 | 13 | In the future SSH might disappear from default installation as packer will be able to communicate through WinRM with the Windows box. For rsync you then have to add the `scripts/openssh.ps1` again to have OpenSSH up and running. 14 | 15 | ## Installation 16 | 17 | To install `rsync` in the Windows boxes you have to add the `./scripts/rsync.bat` script to the packer template's shell provisioner scripts as shown in this example: 18 | 19 | ```json 20 | "provisioners": [ 21 | { 22 | "type": "shell", 23 | "remote_path": "/tmp/script.bat", 24 | "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", 25 | "scripts": [ 26 | "./scripts/vm-guest-tools.bat", 27 | "./scripts/chef.bat", 28 | "./scripts/vagrant-ssh.bat", 29 | "./scripts/compile-dotnet-assemblies.bat", 30 | "./scripts/rsync.bat", 31 | "./scripts/compact.bat" 32 | ] 33 | }, 34 | ``` 35 | 36 | The script also creates a symlink so that the folder `/vagrant` could be used in the Vagrantfile to sync files to `C:\vagrant`. So the example from the Vagrant documentation works without any changes. 37 | 38 | ## Enable RSync in a Vagrantfile 39 | 40 | The following is an example of using RSync to sync a folder into a Windows box. Please notice that we have to forward the SSH port as it will not be forwarded automatically at the moment. 41 | ```ruby 42 | # -*- mode: ruby -*- 43 | # vi: set ft=ruby : 44 | 45 | VAGRANTFILE_API_VERSION = "2" 46 | 47 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 48 | config.vm.box = "windows_2012_r2" 49 | 50 | config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/" 51 | 52 | config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true 53 | 54 | config.vm.provider "virtualbox" do |vb| 55 | vb.gui = true 56 | end 57 | end 58 | ``` 59 | 60 | If you want to sync into another directory of the Windows box, use the Cygwin path prefix `/cygdrive/c` as shown in this example: 61 | 62 | ```ruby 63 | config.vm.synced_folder '.', "/cygdrive/c/vagrant-rsync", 64 | type: "rsync", 65 | rsync__auto: "true", 66 | rsync__exclude: [".git/",".vagrant/"], 67 | id: "vagrant" 68 | ``` 69 | -------------------------------------------------------------------------------- /windows_2008_r2_core.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "cpus": 2, 6 | "disk_adapter_type": "lsisas1068", 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "./answer_files/2008_r2_core/Autounattend.xml", 10 | "./scripts/win-updates.ps1", 11 | "./scripts/openssh.ps1" 12 | ], 13 | "guest_os_type": "windows7srv-64", 14 | "headless": true, 15 | "iso_checksum": "md5:4263be2cf3c59177c45085c0a7bc6ca5", 16 | "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", 17 | "memory": "{{user `memory`}}", 18 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 19 | "ssh_password": "vagrant", 20 | "ssh_timeout": "2h", 21 | "ssh_username": "vagrant", 22 | "tools_upload_flavor": "windows", 23 | "type": "vmware-iso", 24 | "vmx_data": { 25 | "RemoteDisplay.vnc.enabled": "false", 26 | "RemoteDisplay.vnc.port": "5900" 27 | }, 28 | "vmx_remove_ethernet_interfaces": true, 29 | "vnc_port_max": 5980, 30 | "vnc_port_min": 5900 31 | }, 32 | { 33 | "boot_wait": "2m", 34 | "cpus": 2, 35 | "disk_size": "{{user `disk_size`}}", 36 | "floppy_files": [ 37 | "./answer_files/2008_r2_core/Autounattend.xml", 38 | "./scripts/win-updates.ps1", 39 | "./scripts/openssh.ps1" 40 | ], 41 | "guest_os_type": "Windows2008_64", 42 | "headless": true, 43 | "iso_checksum": "md5:4263be2cf3c59177c45085c0a7bc6ca5", 44 | "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", 45 | "memory": "{{user `memory`}}", 46 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 47 | "ssh_password": "vagrant", 48 | "ssh_timeout": "2h", 49 | "ssh_username": "vagrant", 50 | "type": "virtualbox-iso" 51 | } 52 | ], 53 | "post-processors": [ 54 | { 55 | "keep_input_artifact": false, 56 | "output": "windows_2008_r2_core_{{.Provider}}.box", 57 | "type": "vagrant", 58 | "vagrantfile_template": "vagrantfile-windows_2008_r2.template" 59 | } 60 | ], 61 | "provisioners": [ 62 | { 63 | "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", 64 | "remote_path": "/tmp/script.bat", 65 | "scripts": [ 66 | "./scripts/vm-guest-tools.bat", 67 | "./scripts/chef.bat", 68 | "./scripts/vagrant-ssh.bat", 69 | "./scripts/enable-rdp.bat", 70 | "./scripts/disable-auto-logon.bat", 71 | "./scripts/compact.bat" 72 | ], 73 | "type": "shell" 74 | }, 75 | { 76 | "inline": [ 77 | "rm -rf /tmp/*" 78 | ], 79 | "type": "shell" 80 | } 81 | ], 82 | "variables": { 83 | "disk_size": "61440", 84 | "memory": "2048" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /windows_2012.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "cpus": 2, 6 | "disk_adapter_type": "lsisas1068", 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "./answer_files/2012/Autounattend.xml", 10 | "./scripts/microsoft-updates.bat", 11 | "./scripts/win-updates.ps1", 12 | "./scripts/openssh.ps1" 13 | ], 14 | "guest_os_type": "windows8srv-64", 15 | "headless": true, 16 | "iso_checksum": "md5:8503997171f731d9bd1cb0b0edc31f3d", 17 | "iso_url": "https://download.microsoft.com/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", 18 | "memory": "{{user `memory`}}", 19 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 20 | "ssh_password": "vagrant", 21 | "ssh_timeout": "2h", 22 | "ssh_username": "vagrant", 23 | "tools_upload_flavor": "windows", 24 | "type": "vmware-iso", 25 | "vmx_data": { 26 | "RemoteDisplay.vnc.enabled": "false", 27 | "RemoteDisplay.vnc.port": "5900" 28 | }, 29 | "vmx_remove_ethernet_interfaces": true, 30 | "vnc_port_max": 5980, 31 | "vnc_port_min": 5900 32 | }, 33 | { 34 | "boot_wait": "2m", 35 | "cpus": 2, 36 | "disk_size": "{{user `disk_size`}}", 37 | "floppy_files": [ 38 | "./answer_files/2012/Autounattend.xml", 39 | "./scripts/microsoft-updates.bat", 40 | "./scripts/win-updates.ps1", 41 | "./scripts/openssh.ps1" 42 | ], 43 | "guest_os_type": "Windows2012_64", 44 | "headless": true, 45 | "iso_checksum": "md5:8503997171f731d9bd1cb0b0edc31f3d", 46 | "iso_url": "https://download.microsoft.com/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", 47 | "memory": "{{user `memory`}}", 48 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 49 | "ssh_password": "vagrant", 50 | "ssh_timeout": "2h", 51 | "ssh_username": "vagrant", 52 | "type": "virtualbox-iso" 53 | } 54 | ], 55 | "post-processors": [ 56 | { 57 | "keep_input_artifact": false, 58 | "output": "windows_2012_{{.Provider}}.box", 59 | "type": "vagrant", 60 | "vagrantfile_template": "vagrantfile-windows_2012.template" 61 | } 62 | ], 63 | "provisioners": [ 64 | { 65 | "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", 66 | "remote_path": "/tmp/script.bat", 67 | "scripts": [ 68 | "./scripts/vm-guest-tools.bat", 69 | "./scripts/chef.bat", 70 | "./scripts/vagrant-ssh.bat", 71 | "./scripts/disable-auto-logon.bat", 72 | "./scripts/enable-rdp.bat" 73 | ], 74 | "type": "shell" 75 | }, 76 | { 77 | "inline": [ 78 | "rm -rf /tmp/*" 79 | ], 80 | "type": "shell" 81 | } 82 | ], 83 | "variables": { 84 | "disk_size": "61440", 85 | "memory": "2048" 86 | } 87 | } 88 | 89 | -------------------------------------------------------------------------------- /windows_2008_r2.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "cpus": 2, 6 | "disk_adapter_type": "lsisas1068", 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "./answer_files/2008_r2/Autounattend.xml", 10 | "./scripts/dis-updates.ps1", 11 | "./scripts/microsoft-updates.bat", 12 | "./scripts/win-updates.ps1", 13 | "./scripts/openssh.ps1" 14 | ], 15 | "guest_os_type": "windows7srv-64", 16 | "headless": true, 17 | "iso_checksum": "md5:4263be2cf3c59177c45085c0a7bc6ca5", 18 | "iso_url": "https://download.microsoft.com/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso", 19 | "memory": "{{user `memory`}}", 20 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 21 | "ssh_password": "vagrant", 22 | "ssh_timeout": "6h", 23 | "ssh_username": "vagrant", 24 | "tools_upload_flavor": "windows", 25 | "type": "vmware-iso", 26 | "vmx_data": { 27 | "RemoteDisplay.vnc.enabled": "false", 28 | "RemoteDisplay.vnc.port": "5900" 29 | }, 30 | "vmx_remove_ethernet_interfaces": true, 31 | "vnc_port_max": 5980, 32 | "vnc_port_min": 5900 33 | }, 34 | { 35 | "boot_wait": "2m", 36 | "cpus": 2, 37 | "disk_size": "{{user `disk_size`}}", 38 | "floppy_files": [ 39 | "./answer_files/2008_r2/Autounattend.xml", 40 | "./scripts/dis-updates.ps1", 41 | "./scripts/microsoft-updates.bat", 42 | "./scripts/win-updates.ps1", 43 | "./scripts/openssh.ps1" 44 | ], 45 | "guest_os_type": "Windows2008_64", 46 | "headless": false, 47 | "iso_checksum": "md5:4263be2cf3c59177c45085c0a7bc6ca5", 48 | "iso_url": "https://download.microsoft.com/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso", 49 | "memory": "{{user `memory`}}", 50 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 51 | "ssh_password": "vagrant", 52 | "ssh_timeout": "6h", 53 | "ssh_username": "vagrant", 54 | "type": "virtualbox-iso" 55 | } 56 | ], 57 | "post-processors": [ 58 | { 59 | "keep_input_artifact": false, 60 | "output": "windows_2008_r2_{{.Provider}}.box", 61 | "type": "vagrant", 62 | "vagrantfile_template": "vagrantfile-windows_2008_r2.template" 63 | } 64 | ], 65 | "provisioners": [ 66 | { 67 | "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", 68 | "remote_path": "/tmp/script.bat", 69 | "scripts": [ 70 | "./scripts/vm-guest-tools.bat", 71 | "./scripts/chef.bat", 72 | "./scripts/vagrant-ssh.bat", 73 | "./scripts/enable-rdp.bat", 74 | "./scripts/compact.bat" 75 | ], 76 | "type": "shell" 77 | }, 78 | { 79 | "inline": [ 80 | "rm -rf /tmp/*" 81 | ], 82 | "type": "shell" 83 | } 84 | ], 85 | "variables": { 86 | "disk_size": "61440", 87 | "memory": "2048" 88 | } 89 | } 90 | 91 | -------------------------------------------------------------------------------- /windows_2016_core_ami.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "communicator": "winrm", 6 | "cpus": 2, 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "{{user `autounattend`}}", 10 | "./scripts/disable-screensaver.ps1", 11 | "./scripts/disable-winrm.ps1", 12 | "./scripts/enable-winrm.ps1", 13 | "./scripts/microsoft-updates.bat", 14 | "./scripts/win-updates.ps1" 15 | ], 16 | "format": "ova", 17 | "guest_additions_mode": "disable", 18 | "guest_os_type": "Windows2016_64", 19 | "headless": "{{user `headless`}}", 20 | "iso_checksum": "{{user `iso_checksum`}}", 21 | "iso_url": "{{user `iso_url`}}", 22 | "memory": "{{user `memory`}}", 23 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 24 | "type": "virtualbox-iso", 25 | "winrm_password": "vagrant", 26 | "winrm_timeout": "{{user `winrm_timeout`}}", 27 | "winrm_username": "vagrant" 28 | } 29 | ], 30 | "post-processors": [ 31 | { 32 | "keep_input_artifact": false, 33 | "output": "windows_2016_core_{{.Provider}}.box", 34 | "type": "vagrant", 35 | "vagrantfile_template": "vagrantfile-windows_2016_core.template" 36 | }, 37 | { 38 | "access_key": "", 39 | "ami_name": "packer_windows_2016_core", 40 | "keep_input_artifact": false, 41 | "license_type": "BYOL", 42 | "only": [ 43 | "virtualbox-iso" 44 | ], 45 | "region": "", 46 | "s3_bucket_name": "{{user `aws_s3_bucket_name`}}", 47 | "secret_key": "", 48 | "tags": { 49 | "Description": "packer-windows 2016 core amazon-import {{timestamp}}" 50 | }, 51 | "type": "amazon-import" 52 | } 53 | ], 54 | "provisioners": [ 55 | { 56 | "scripts": [ 57 | "./scripts/enable-rdp.bat" 58 | ], 59 | "type": "windows-shell" 60 | }, 61 | { 62 | "scripts": [ 63 | "./scripts/debloat-windows.ps1" 64 | ], 65 | "type": "powershell" 66 | }, 67 | { 68 | "scripts": [ 69 | "./scripts/set-winrm-automatic.bat", 70 | "./scripts/uac-enable.bat", 71 | "./scripts/compile-dotnet-assemblies.bat", 72 | "./scripts/dis-updates.bat", 73 | "./scripts/compact.bat" 74 | ], 75 | "type": "windows-shell" 76 | }, 77 | { 78 | "inline": [ 79 | "C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/InitializeInstance.ps1 -Schedule", 80 | "C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/SysprepInstance.ps1 -NoShutdown" 81 | ], 82 | "type": "powershell" 83 | } 84 | ], 85 | "variables": { 86 | "autounattend": "./answer_files/2016_core/Autounattend.xml", 87 | "aws_s3_bucket_name": "{{env `AWS_S3_BUCKET`}}", 88 | "disk_size": "61440", 89 | "disk_type_id": "1", 90 | "memory": "2048", 91 | "headless": "false", 92 | "iso_checksum": "md5:70721288BBCDFE3239D8F8C0FAE55F1F", 93 | "iso_url": "https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO", 94 | "winrm_timeout": "6h" 95 | } 96 | } 97 | 98 | -------------------------------------------------------------------------------- /vagrantfile-windows_7.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-7" 8 | config.vm.box = "windows_7" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | #v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | #v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 38 | v.whitelist_verified = true 39 | v.vmx["hgfs.linkRootShare"] = "FALSE" 40 | end 41 | 42 | config.vm.provider :vmware_workstation do |v, override| 43 | #v.gui = true 44 | v.vmx["memsize"] = "2048" 45 | v.vmx["numvcpus"] = "2" 46 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 47 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 48 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 49 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 50 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "FALSE" 51 | v.whitelist_verified = true 52 | v.vmx["hgfs.linkRootShare"] = "FALSE" 53 | end 54 | 55 | config.vm.provider :libvirt do |libvirt, override| 56 | libvirt.memory = 2048 57 | libvirt.cpus = 2 58 | 59 | # Use WinRM for the default synced folder; or disable it if 60 | # WinRM is not available. Linux hosts don't support SMB, 61 | # and Windows guests don't support NFS/9P/rsync 62 | # See https://github.com/Cimpress-MCP/vagrant-winrm-syncedfolders 63 | if Vagrant.has_plugin?("vagrant-winrm-syncedfolders") 64 | override.vm.synced_folder ".", "/vagrant", type: "winrm" 65 | else 66 | override.vm.synced_folder ".", "/vagrant", disabled: true 67 | end 68 | 69 | # Enable Hyper-V enlightments, see 70 | # https://blog.wikichoon.com/2014/07/enabling-hyper-v-enlightenments-with-kvm.html 71 | libvirt.hyperv_feature :name => 'stimer', :state => 'on' 72 | libvirt.hyperv_feature :name => 'relaxed', :state => 'on' 73 | libvirt.hyperv_feature :name => 'vapic', :state => 'on' 74 | libvirt.hyperv_feature :name => 'synic', :state => 'on' 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /nested/terraform/provision.ps1: -------------------------------------------------------------------------------- 1 | 2 | Start-Transcript -Path C:\provision.log -Append 3 | 4 | Function SetupPhase1 { 5 | Cscript $env:WinDir\System32\SCregEdit.wsf /AU 1 6 | Net stop wuauserv 7 | Net start wuauserv 8 | 9 | Set-MpPreference -DisableRealtimeMonitoring $true 10 | 11 | New-ItemProperty -Path HKCU:\Software\Microsoft\ServerManager -Name DoNotOpenServerManagerAtLogon -PropertyType DWORD -Value "1" -Force 12 | 13 | Write-Output "Installing Chocolatey" 14 | Invoke-WebRequest 'https://chocolatey.org/install.ps1' -UseBasicParsing -OutFile $env:TEMP\install.ps1 15 | .\$env:TEMP\install.ps1 16 | Remove-Item $env:TEMP\install.ps1 -Force -ErrorAction SilentlyContinue 17 | choco feature disable --name showDownloadProgress 18 | choco install -y git 19 | choco install -y packer 20 | choco install -y vagrant 21 | 22 | Write-Output "Installing Hyper-V" 23 | Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart 24 | Install-WindowsFeature Hyper-V-Tools 25 | Install-WindowsFeature Hyper-V-PowerShell 26 | 27 | #Write-Output Install all Windows Updates 28 | #Get-Content C:\windows\system32\en-us\WUA_SearchDownloadInstall.vbs | ForEach-Object { 29 | # $_ -replace 'confirm = msgbox.*$', 'confirm = vbNo' 30 | #} | Out-File $env:TEMP\WUA_SearchDownloadInstall.vbs 31 | #"a`na" | cscript $env:TEMP\WUA_SearchDownloadInstall.vbs 32 | 33 | Write-Output "Rebooting" 34 | Restart-Computer 35 | } 36 | 37 | Function SetupPhase2 { 38 | 39 | Write-Output "Installing Vagrant plugins" 40 | vagrant plugin install vagrant-reload 41 | 42 | Write-Output "Adding NAT" 43 | New-VMSwitch -SwitchName "packer-hyperv-iso" -SwitchType Internal 44 | New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex (Get-NetAdapter -name "vEthernet (packer-hyperv-iso)").ifIndex 45 | New-NetNat -Name MyNATnetwork -InternalIPInterfaceAddressPrefix 192.168.0.0/24 46 | 47 | Write-Output "Adding DHCP scope" 48 | Install-WindowsFeature DHCP -IncludeManagementTools 49 | Add-DhcpServerv4Scope -Name "Internal" -StartRange 192.168.0.10 -EndRange 192.168.0.250 -SubnetMask 255.255.255.0 -Description "Internal Network" 50 | Set-DhcpServerv4OptionValue -ScopeID 192.168.0 -DNSServer 8.8.8.8 -Router 192.168.0.1 51 | 52 | Write-Output "Allow Packer http server" 53 | New-NetFirewallRule -DisplayName "Allow Packer" -Direction Inbound -Program "C:\ProgramData\chocolatey\lib\packer\tools\packer.exe" -RemoteAddress LocalSubnet -Action Allow 54 | 55 | Write-Output "Disabling autologon" 56 | New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -PropertyType DWORD -Value "0" -Force 57 | 58 | Write-Output "Removing scheduled job" 59 | Unregister-ScheduledJob -Name NewServerSetupResume -Force 60 | } 61 | 62 | if (!(Test-Path c:\ProgramData\chocolatey)) { 63 | $SecureStringPassword = ConvertTo-SecureString -String $Password -AsPlainText -Force 64 | $cred = New-Object System.Management.Automation.PSCredential($Username, $SecureStringPassword) 65 | $AtStartup = New-JobTrigger -AtStartup 66 | Register-ScheduledJob -Name NewServerSetupResume ` 67 | -Credential $cred ` 68 | -Trigger $AtStartup ` 69 | -ScriptBlock { c:\provision.ps1 } 70 | SetupPhase1 71 | } 72 | else { 73 | SetupPhase2 74 | } 75 | -------------------------------------------------------------------------------- /windows_2012_r2_hyperv.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "cpus": 2, 6 | "disk_adapter_type": "lsisas1068", 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "./answer_files/2012_r2_hyperv/Autounattend.xml", 10 | "./scripts/microsoft-updates.bat", 11 | "./scripts/win-updates.ps1", 12 | "./scripts/openssh.ps1" 13 | ], 14 | "guest_os_type": "windows8srv-64", 15 | "headless": true, 16 | "iso_checksum": "md5:9c9e0d82cb6301a4b88fd2f4c35caf80", 17 | "iso_url": "http://care.dlservice.microsoft.com/dl/download/F/7/D/F7DF966B-5C40-4674-9A32-D83D869A3244/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVERHYPERCORE_EN-US-IRM_SHV_X64FRE_EN-US_DV5.ISO", 18 | "memory": "{{user `memory`}}", 19 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 20 | "ssh_password": "vagrant", 21 | "ssh_timeout": "6h", 22 | "ssh_username": "vagrant", 23 | "tools_upload_flavor": "windows", 24 | "type": "vmware-iso", 25 | "vmx_data": { 26 | "RemoteDisplay.vnc.enabled": "false", 27 | "RemoteDisplay.vnc.port": "5900" 28 | }, 29 | "vmx_remove_ethernet_interfaces": true, 30 | "vnc_port_max": 5980, 31 | "vnc_port_min": 5900 32 | }, 33 | { 34 | "boot_wait": "2m", 35 | "cpus": 2, 36 | "disk_size": "{{user `disk_size`}}", 37 | "floppy_files": [ 38 | "./answer_files/2012_r2_hyperv/Autounattend.xml", 39 | "./scripts/microsoft-updates.bat", 40 | "./scripts/win-updates.ps1", 41 | "./scripts/openssh.ps1" 42 | ], 43 | "guest_os_type": "Windows2012_64", 44 | "headless": true, 45 | "iso_checksum": "md5:9c9e0d82cb6301a4b88fd2f4c35caf80", 46 | "iso_url": "http://care.dlservice.microsoft.com/dl/download/F/7/D/F7DF966B-5C40-4674-9A32-D83D869A3244/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVERHYPERCORE_EN-US-IRM_SHV_X64FRE_EN-US_DV5.ISO", 47 | "memory": "{{user `memory`}}", 48 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 49 | "ssh_password": "vagrant", 50 | "ssh_timeout": "6h", 51 | "ssh_username": "vagrant", 52 | "type": "virtualbox-iso" 53 | } 54 | ], 55 | "post-processors": [ 56 | { 57 | "keep_input_artifact": false, 58 | "output": "windows_2012_r2_hyperv_{{.Provider}}.box", 59 | "type": "vagrant", 60 | "vagrantfile_template": "vagrantfile-windows_2012_r2.template" 61 | } 62 | ], 63 | "provisioners": [ 64 | { 65 | "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", 66 | "remote_path": "/tmp/script.bat", 67 | "scripts": [ 68 | "./scripts/vm-guest-tools.bat", 69 | "./scripts/chef.bat", 70 | "./scripts/vagrant-ssh.bat", 71 | "./scripts/enable-rdp.bat", 72 | "./scripts/compile-dotnet-assemblies.bat", 73 | "./scripts/disable-auto-logon.bat", 74 | "./scripts/compact.bat" 75 | ], 76 | "type": "shell" 77 | }, 78 | { 79 | "inline": [ 80 | "rm -rf /tmp/*" 81 | ], 82 | "type": "shell" 83 | } 84 | ], 85 | "variables": { 86 | "disk_size": "61440", 87 | "memory": "2048" 88 | } 89 | } 90 | 91 | -------------------------------------------------------------------------------- /windows_2016_ami.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "communicator": "winrm", 6 | "cpus": 2, 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "{{user `autounattend`}}", 10 | "./scripts/disable-screensaver.ps1", 11 | "./scripts/disable-winrm.ps1", 12 | "./scripts/enable-winrm.ps1", 13 | "./scripts/microsoft-updates.bat", 14 | "./scripts/win-updates.ps1", 15 | "./scripts/unattend.xml", 16 | "./scripts/sysprep.bat" 17 | ], 18 | "format": "ova", 19 | "guest_additions_mode": "disable", 20 | "guest_os_type": "Windows2016_64", 21 | "headless": "{{user `headless`}}", 22 | "iso_checksum": "{{user `iso_checksum`}}", 23 | "iso_url": "{{user `iso_url`}}", 24 | "memory": "{{user `memory`}}", 25 | "shutdown_command": "a:/sysprep.bat", 26 | "type": "virtualbox-iso", 27 | "vm_name": "WindowsServer2016", 28 | "winrm_password": "vagrant", 29 | "winrm_timeout": "{{user `winrm_timeout`}}", 30 | "winrm_username": "vagrant" 31 | } 32 | ], 33 | "post-processors": [ 34 | { 35 | "keep_input_artifact": false, 36 | "output": "windows_2016_{{.Provider}}.box", 37 | "type": "vagrant", 38 | "vagrantfile_template": "vagrantfile-windows_2016.template" 39 | }, 40 | { 41 | "access_key": "", 42 | "ami_name": "packer_windows_2016", 43 | "keep_input_artifact": false, 44 | "license_type": "BYOL", 45 | "only": [ 46 | "virtualbox-iso" 47 | ], 48 | "region": "", 49 | "s3_bucket_name": "{{user `aws_s3_bucket_name`}}", 50 | "secret_key": "", 51 | "tags": { 52 | "Description": "packer-windows 2016 amazon-import {{timestamp}}" 53 | }, 54 | "type": "amazon-import" 55 | } 56 | ], 57 | "provisioners": [ 58 | { 59 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 60 | "scripts": [ 61 | "./scripts/enable-rdp.bat" 62 | ], 63 | "type": "windows-shell" 64 | }, 65 | { 66 | "scripts": [ 67 | "./scripts/debloat-windows.ps1" 68 | ], 69 | "type": "powershell" 70 | }, 71 | { 72 | "restart_timeout": "{{user `restart_timeout`}}", 73 | "type": "windows-restart" 74 | }, 75 | { 76 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 77 | "scripts": [ 78 | "./scripts/pin-powershell.bat", 79 | "./scripts/set-winrm-automatic.bat", 80 | "./scripts/uac-enable.bat", 81 | "./scripts/compile-dotnet-assemblies.bat", 82 | "./scripts/dis-updates.bat", 83 | "./scripts/compact.bat" 84 | ], 85 | "type": "windows-shell" 86 | } 87 | ], 88 | "variables": { 89 | "autounattend": "./answer_files/2016/Autounattend.xml", 90 | "aws_s3_bucket_name": "{{env `AWS_S3_BUCKET`}}", 91 | "disk_size": "61440", 92 | "disk_type_id": "1", 93 | "memory": "2048", 94 | "headless": "false", 95 | "iso_checksum": "md5:70721288BBCDFE3239D8F8C0FAE55F1F", 96 | "iso_url": "https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO", 97 | "restart_timeout": "5m", 98 | "winrm_timeout": "4h" 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /scripts/vm-guest-tools.bat: -------------------------------------------------------------------------------- 1 | if not exist "C:\Windows\Temp\7z1900-x64.msi" ( 2 | powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z1900-x64.msi', 'C:\Windows\Temp\7z1900-x64.msi')" <NUL 3 | ) 4 | if not exist "C:\Windows\Temp\7z1900-x64.msi" ( 5 | powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Start-Sleep 5 ; (New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z1900-x64.msi', 'C:\Windows\Temp\7z1900-x64.msi')" <NUL 6 | ) 7 | msiexec /qb /i C:\Windows\Temp\7z1900-x64.msi 8 | 9 | if "%PACKER_BUILDER_TYPE%" equ "vmware-iso" goto :vmware 10 | if "%PACKER_BUILDER_TYPE%" equ "virtualbox-iso" goto :virtualbox 11 | if "%PACKER_BUILDER_TYPE%" equ "parallels-iso" goto :parallels 12 | if "%PACKER_BUILDER_TYPE%" equ "qemu" goto :qemu 13 | goto :done 14 | 15 | :vmware 16 | 17 | if exist "C:\Users\vagrant\windows.iso" ( 18 | move /Y C:\Users\vagrant\windows.iso C:\Windows\Temp 19 | ) 20 | 21 | if not exist "C:\Windows\Temp\windows.iso" ( 22 | powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://softwareupdate.vmware.com/cds/vmw-desktop/ws/16.1.1/17801498/windows/packages/tools-windows.tar', 'C:\Windows\Temp\vmware-tools.tar')" <NUL 23 | cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\vmware-tools.tar -oC:\Windows\Temp" 24 | FOR /r "C:\Windows\Temp" %%a in (VMware-tools-windows-*.iso) DO REN "%%~a" "windows.iso" 25 | rd /S /Q "C:\Program Files (x86)\VMWare" 26 | ) 27 | 28 | cmd /c ""C:\Program Files\7-Zip\7z.exe" x "C:\Windows\Temp\windows.iso" -oC:\Windows\Temp\VMWare" 29 | cmd /c C:\Windows\Temp\VMWare\setup.exe /S /v"/qn REBOOT=R\" 30 | 31 | del /Q "C:\Windows\Temp\vmware-tools.tar" 32 | del /Q "C:\Windows\Temp\windows.iso" 33 | rd /S /Q "C:\Windows\Temp\VMware" 34 | goto :done 35 | 36 | :virtualbox 37 | 38 | if exist "C:\Users\vagrant\VBoxGuestAdditions.iso" ( 39 | move /Y C:\Users\vagrant\VBoxGuestAdditions.iso C:\Windows\Temp 40 | ) 41 | 42 | if not exist "C:\Windows\Temp\VBoxGuestAdditions.iso" ( 43 | powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://download.virtualbox.org/virtualbox/6.1.18/VBoxGuestAdditions_6.1.18.iso', 'C:\Windows\Temp\VBoxGuestAdditions.iso')" <NUL 44 | ) 45 | 46 | cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox" 47 | cmd /c for %%i in (C:\Windows\Temp\virtualbox\cert\vbox*.cer) do C:\Windows\Temp\virtualbox\cert\VBoxCertUtil add-trusted-publisher %%i --root %%i 48 | cmd /c C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe /S 49 | rd /S /Q "C:\Windows\Temp\virtualbox" 50 | goto :done 51 | 52 | :parallels 53 | if exist "C:\Users\vagrant\prl-tools-win.iso" ( 54 | move /Y C:\Users\vagrant\prl-tools-win.iso C:\Windows\Temp 55 | cmd /C "C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\prl-tools-win.iso -oC:\Windows\Temp\parallels 56 | cmd /C C:\Windows\Temp\parallels\PTAgent.exe /install_silent 57 | rd /S /Q "C:\Windows\Temp\parallels" 58 | ) 59 | goto :done 60 | 61 | :qemu 62 | if exist "E:\guest-agent\" ( 63 | msiexec /qb /x E:\guest-agent\qemu-ga-x86_64.msi 64 | ) 65 | 66 | :done 67 | msiexec /qb /x C:\Windows\Temp\7z1900-x64.msi 68 | -------------------------------------------------------------------------------- /windows_2019_core_ami.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "communicator": "winrm", 6 | "cpus": 2, 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "{{user `autounattend`}}", 10 | "./scripts/disable-screensaver.ps1", 11 | "./scripts/disable-winrm.ps1", 12 | "./scripts/enable-winrm.ps1", 13 | "./scripts/microsoft-updates.bat", 14 | "./scripts/win-updates.ps1" 15 | ], 16 | "format": "ova", 17 | "guest_additions_mode": "disable", 18 | "guest_os_type": "Windows2016_64", 19 | "headless": "{{user `headless`}}", 20 | "iso_checksum": "{{user `iso_checksum`}}", 21 | "iso_url": "{{user `iso_url`}}", 22 | "memory": "{{user `memory`}}", 23 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 24 | "type": "virtualbox-iso", 25 | "winrm_password": "vagrant", 26 | "winrm_timeout": "{{user `winrm_timeout`}}", 27 | "winrm_username": "vagrant" 28 | } 29 | ], 30 | "post-processors": [ 31 | { 32 | "keep_input_artifact": false, 33 | "output": "windows_2019_core_{{.Provider}}.box", 34 | "type": "vagrant", 35 | "vagrantfile_template": "vagrantfile-windows_2019_core.template" 36 | }, 37 | { 38 | "access_key": "", 39 | "ami_name": "packer_windows_2019_core", 40 | "keep_input_artifact": false, 41 | "license_type": "BYOL", 42 | "only": [ 43 | "virtualbox-iso" 44 | ], 45 | "region": "", 46 | "s3_bucket_name": "{{user `aws_s3_bucket_name`}}", 47 | "secret_key": "", 48 | "tags": { 49 | "Description": "packer-windows 2019 core amazon-import {{timestamp}}" 50 | }, 51 | "type": "amazon-import" 52 | } 53 | ], 54 | "provisioners": [ 55 | { 56 | "scripts": [ 57 | "./scripts/enable-rdp.bat" 58 | ], 59 | "type": "windows-shell" 60 | }, 61 | { 62 | "scripts": [ 63 | "./scripts/vm-guest-tools.ps1", 64 | "./scripts/debloat-windows.ps1" 65 | ], 66 | "type": "powershell" 67 | }, 68 | { 69 | "scripts": [ 70 | "./scripts/set-winrm-automatic.bat", 71 | "./scripts/uac-enable.bat", 72 | "./scripts/compile-dotnet-assemblies.bat", 73 | "./scripts/dis-updates.bat", 74 | "./scripts/compact.bat" 75 | ], 76 | "type": "windows-shell" 77 | }, 78 | { 79 | "inline": [ 80 | "C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/InitializeInstance.ps1 -Schedule", 81 | "C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/SysprepInstance.ps1 -NoShutdown" 82 | ], 83 | "type": "powershell" 84 | } 85 | ], 86 | "variables": { 87 | "autounattend": "./answer_files/2019_core/Autounattend.xml", 88 | "aws_s3_bucket_name": "{{env `AWS_S3_BUCKET`}}", 89 | "disk_size": "61440", 90 | "disk_type_id": "1", 91 | "memory": "2048", 92 | "headless": "false", 93 | "iso_checksum": "sha256:6dae072e7f78f4ccab74a45341de0d6e2d45c39be25f1f5920a2ab4f51d7bcbb", 94 | "iso_url": "https://software-static.download.prss.microsoft.com/dbazure/988969d5-f34g-4e03-ac9d-1f9786c66749/17763.3650.221105-1748.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso", 95 | "manually_download_iso_from": "https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2019", 96 | "winrm_timeout": "6h" 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /windows_81.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "2m", 5 | "cpus": 2, 6 | "disk_adapter_type": "lsisas1068", 7 | "disk_size": "{{user `disk_size`}}", 8 | "floppy_files": [ 9 | "./answer_files/81/Autounattend.xml", 10 | "./scripts/microsoft-updates.bat", 11 | "./scripts/win-updates.ps1", 12 | "./scripts/openssh.ps1" 13 | ], 14 | "guest_os_type": "windows8-64", 15 | "headless": true, 16 | "iso_checksum": "md5:5e4ecb86fd8619641f1d58f96e8561ec", 17 | "iso_url": "https://download.microsoft.com/download/B/9/9/B999286E-0A47-406D-8B3D-5B5AD7373A4A/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_ENTERPRISE_EVAL_EN-US-IRM_CENA_X64FREE_EN-US_DV5.ISO", 18 | "memory": "{{user `memory`}}", 19 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 20 | "ssh_password": "vagrant", 21 | "ssh_timeout": "4h", 22 | "ssh_username": "vagrant", 23 | "tools_upload_flavor": "windows", 24 | "type": "vmware-iso", 25 | "vmx_data": { 26 | "RemoteDisplay.vnc.enabled": "false", 27 | "RemoteDisplay.vnc.port": "5900" 28 | }, 29 | "vmx_remove_ethernet_interfaces": true, 30 | "vnc_port_max": 5980, 31 | "vnc_port_min": 5900 32 | }, 33 | { 34 | "boot_wait": "2m", 35 | "cpus": 2, 36 | "disk_size": "{{user `disk_size`}}", 37 | "floppy_files": [ 38 | "./answer_files/81/Autounattend.xml", 39 | "./scripts/microsoft-updates.bat", 40 | "./scripts/win-updates.ps1", 41 | "./scripts/openssh.ps1" 42 | ], 43 | "guest_os_type": "Windows81_64", 44 | "headless": false, 45 | "iso_checksum": "md5:5e4ecb86fd8619641f1d58f96e8561ec", 46 | "iso_url": "https://download.microsoft.com/download/B/9/9/B999286E-0A47-406D-8B3D-5B5AD7373A4A/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_ENTERPRISE_EVAL_EN-US-IRM_CENA_X64FREE_EN-US_DV5.ISO", 47 | "memory": "{{user `memory`}}", 48 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 49 | "ssh_password": "vagrant", 50 | "ssh_timeout": "4h", 51 | "ssh_username": "vagrant", 52 | "type": "virtualbox-iso", 53 | "vboxmanage": [ 54 | [ 55 | "modifyvm", 56 | "{{.Name}}", 57 | "--vrdeaddress", 58 | "127.0.0.1" 59 | ], 60 | [ 61 | "modifyvm", 62 | "{{.Name}}", 63 | "--vrdeport", 64 | "13389" 65 | ] 66 | ] 67 | } 68 | ], 69 | "post-processors": [ 70 | { 71 | "keep_input_artifact": false, 72 | "output": "windows_81_{{.Provider}}.box", 73 | "type": "vagrant", 74 | "vagrantfile_template": "vagrantfile-windows_81.template" 75 | } 76 | ], 77 | "provisioners": [ 78 | { 79 | "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", 80 | "remote_path": "/tmp/script.bat", 81 | "scripts": [ 82 | "./scripts/vm-guest-tools.bat", 83 | "./scripts/chef.bat", 84 | "./scripts/vagrant-ssh.bat", 85 | "./scripts/disable-auto-logon.bat", 86 | "./scripts/enable-rdp.bat", 87 | "./scripts/compile-dotnet-assemblies.bat", 88 | "./scripts/compact.bat" 89 | ], 90 | "type": "shell" 91 | }, 92 | { 93 | "inline": [ 94 | "rm -rf /tmp/*" 95 | ], 96 | "type": "shell" 97 | } 98 | ], 99 | "variables": { 100 | "disk_size": "61440", 101 | "memory": "2048" 102 | } 103 | } 104 | 105 | -------------------------------------------------------------------------------- /vagrantfile-windows_2016.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-2016" 8 | config.vm.box = "windows_2016" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | #v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "TRUE" 38 | v.vmx["mks.enable3d"] = "TRUE" 39 | v.vmx["mks.forceDiscreteGPU"] = "TRUE" 40 | v.vmx["gui.fullscreenatpoweron"] = "TRUE" 41 | v.vmx["gui.viewmodeatpoweron"] = "fullscreen" 42 | v.vmx["gui.lastPoweredViewMode"] = "fullscreen" 43 | v.vmx["sound.startconnected"] = "FALSE" 44 | v.vmx["sound.present"] = "FALSE" 45 | v.vmx["sound.autodetect"] = "TRUE" 46 | v.vmx["virtualhw.version"] = "14" 47 | v.enable_vmrun_ip_lookup = false 48 | v.whitelist_verified = true 49 | v.vmx["hgfs.linkRootShare"] = "FALSE" 50 | end 51 | 52 | config.vm.provider :vmware_workstation do |v, override| 53 | #v.gui = true 54 | v.vmx["memsize"] = "2048" 55 | v.vmx["numvcpus"] = "2" 56 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 57 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 58 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 59 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 60 | v.enable_vmrun_ip_lookup = false 61 | v.whitelist_verified = true 62 | v.vmx["hgfs.linkRootShare"] = "FALSE" 63 | end 64 | 65 | config.vm.provider :libvirt do |libvirt, override| 66 | libvirt.memory = 2048 67 | libvirt.cpus = 2 68 | 69 | # Use WinRM for the default synced folder; or disable it if 70 | # WinRM is not available. Linux hosts don't support SMB, 71 | # and Windows guests don't support NFS/9P/rsync 72 | # See https://github.com/Cimpress-MCP/vagrant-winrm-syncedfolders 73 | if Vagrant.has_plugin?("vagrant-winrm-syncedfolders") 74 | override.vm.synced_folder ".", "/vagrant", type: "winrm" 75 | else 76 | override.vm.synced_folder ".", "/vagrant", disabled: true 77 | end 78 | 79 | # Enable Hyper-V enlightments, see 80 | # https://blog.wikichoon.com/2014/07/enabling-hyper-v-enlightenments-with-kvm.html 81 | libvirt.hyperv_feature :name => 'stimer', :state => 'on' 82 | libvirt.hyperv_feature :name => 'relaxed', :state => 'on' 83 | libvirt.hyperv_feature :name => 'vapic', :state => 'on' 84 | libvirt.hyperv_feature :name => 'synic', :state => 'on' 85 | end 86 | end 87 | -------------------------------------------------------------------------------- /vagrantfile-windows_10.template: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.2" 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.define "vagrant-windows-10-preview" 8 | config.vm.box = "windows_10_preview" 9 | config.vm.communicator = "winrm" 10 | 11 | # Admin user name and password 12 | config.winrm.username = "vagrant" 13 | config.winrm.password = "vagrant" 14 | 15 | config.vm.guest = :windows 16 | config.windows.halt_timeout = 15 17 | 18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true 19 | 20 | config.vm.provider :virtualbox do |v, override| 21 | #v.gui = true 22 | v.customize ["modifyvm", :id, "--memory", 2048] 23 | v.customize ["modifyvm", :id, "--cpus", 2] 24 | v.customize ["modifyvm", :id, "--vram", 128] 25 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 26 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |v, override| 30 | v.gui = true 31 | v.vmx["memsize"] = "2048" 32 | v.vmx["numvcpus"] = "2" 33 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 34 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 35 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 36 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 37 | v.vmx["gui.fitguestusingnativedisplayresolution"] = "TRUE" 38 | v.vmx["mks.enable3d"] = "TRUE" 39 | v.vmx["mks.forceDiscreteGPU"] = "TRUE" 40 | v.vmx["gui.fullscreenatpoweron"] = "TRUE" 41 | v.vmx["gui.viewmodeatpoweron"] = "fullscreen" 42 | v.vmx["gui.lastPoweredViewMode"] = "fullscreen" 43 | v.vmx["sound.startconnected"] = "FALSE" 44 | v.vmx["sound.present"] = "FALSE" 45 | v.vmx["sound.autodetect"] = "TRUE" 46 | v.enable_vmrun_ip_lookup = false 47 | v.whitelist_verified = true 48 | v.vmx["hgfs.linkRootShare"] = "FALSE" 49 | end 50 | 51 | config.vm.provider :vmware_workstation do |v, override| 52 | v.gui = true 53 | v.vmx["memsize"] = "2048" 54 | v.vmx["numvcpus"] = "2" 55 | v.vmx["ethernet0.virtualDev"] = "vmxnet3" 56 | v.vmx["RemoteDisplay.vnc.enabled"] = "false" 57 | v.vmx["RemoteDisplay.vnc.port"] = "5900" 58 | v.vmx["scsi0.virtualDev"] = "lsisas1068" 59 | v.enable_vmrun_ip_lookup = false 60 | v.whitelist_verified = true 61 | v.vmx["hgfs.linkRootShare"] = "FALSE" 62 | end 63 | 64 | config.vm.provider "hyperv" do |v| 65 | v.cpus = 2 66 | v.maxmemory = 2048 67 | v.linked_clone = true 68 | end 69 | 70 | config.vm.provider :libvirt do |libvirt, override| 71 | libvirt.memory = 2048 72 | libvirt.cpus = 2 73 | 74 | # Use WinRM for the default synced folder; or disable it if 75 | # WinRM is not available. Linux hosts don't support SMB, 76 | # and Windows guests don't support NFS/9P/rsync 77 | # See https://github.com/Cimpress-MCP/vagrant-winrm-syncedfolders 78 | if Vagrant.has_plugin?("vagrant-winrm-syncedfolders") 79 | override.vm.synced_folder ".", "/vagrant", type: "winrm" 80 | else 81 | override.vm.synced_folder ".", "/vagrant", disabled: true 82 | end 83 | 84 | # Enable Hyper-V enlightments, see 85 | # https://blog.wikichoon.com/2014/07/enabling-hyper-v-enlightenments-with-kvm.html 86 | libvirt.hyperv_feature :name => 'stimer', :state => 'on' 87 | libvirt.hyperv_feature :name => 'relaxed', :state => 'on' 88 | libvirt.hyperv_feature :name => 'vapic', :state => 'on' 89 | libvirt.hyperv_feature :name => 'synic', :state => 'on' 90 | end 91 | end 92 | -------------------------------------------------------------------------------- /upload-vhd.ps1: -------------------------------------------------------------------------------- 1 | # convert-vhd -Path C:\Users\packer\AppData\Local\Temp\packerhv238285888\WindowsServer2019Docker.vhdx -DestinationPath C:\Users\packer\Desktop\Win2019Docker.vhd -VHDType Fixed 2 | 3 | # Install-Module -Name AzureRM 4 | Import-Module AzureRM 5 | # Connect to Azure with an interactive dialog for sign-in 6 | # Connect-AzureRmAccount 7 | # Select-AzureRmSubscription -Subscription "Microsoft Azure Sponsorship" 8 | 9 | $resourceGroup = 'chocolateyfest-docker-workshop-images' 10 | $location = 'WestUS2' 11 | # New-AzureRmResourceGroup -Name $resourceGroup -Location $location 12 | 13 | $storageaccount = 'chocolateyfestsa' 14 | $storageType = 'Standard_LRS' 15 | $containername = 'vhds' 16 | New-AzureRmStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccount -Location $location ` 17 | -SkuName $storageType -Kind "Storage" 18 | $vhdName = 'windows_2019_docker_azure.vhd' 19 | $urlOfUploadedImageVhd = ('https://' + $storageaccount + '.blob.core.windows.net/' + $containername + '/' + $vhdName) 20 | Add-AzureRmVhd -ResourceGroupName $resourceGroup -Destination $urlOfUploadedImageVhd ` 21 | -LocalFilePath 'D:\work\output-hyperv-iso\Virtual Hard Disks\WindowsServer2019Docker.vhd' 22 | 23 | # $imageName = "windows_2019_docker_17763" 24 | $imageConfig = New-AzureRmImageConfig -Location $location 25 | $imageConfig = Set-AzureRmImageOsDisk -Image $imageConfig -OsType Windows -OsState Generalized ` 26 | -BlobUri $urlOfUploadedImageVhd 27 | # $image = New-AzureRmImage -ImageName $imageName -ResourceGroupName $resourceGroup -Image $imageConfig 28 | 29 | 30 | # $diskSizeGB = '128' 31 | # $subnetName = 'mySubnet' 32 | # $vnetName = 'myVnet' 33 | # $ipName = 'myPip' 34 | # $nicName = 'myNic' 35 | # $nsgName = 'myNsg' 36 | # $ruleName = 'myRdpRule' 37 | # $computerName = 'myComputerName' 38 | # $vmName = 'myVM' 39 | # $vmSize = 'Standard_D4_v3' 40 | # $cred = Get-Credential 41 | # $singleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24 42 | # $vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroup -Location $location ` 43 | # -AddressPrefix 10.0.0.0/16 -Subnet $singleSubnet 44 | # $pip = New-AzureRmPublicIpAddress -Name $ipName -ResourceGroupName $resourceGroup -Location $location ` 45 | # -AllocationMethod Dynamic 46 | # $rdpRule = New-AzureRmNetworkSecurityRuleConfig -Name $ruleName -Description 'Allow RDP' -Access Allow ` 47 | # -Protocol Tcp -Direction Inbound -Priority 110 -SourceAddressPrefix Internet -SourcePortRange * ` 48 | # -DestinationAddressPrefix * -DestinationPortRange 3389 49 | # $nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $resourceGroup -Location $location ` 50 | # -Name $nsgName -SecurityRules $rdpRule 51 | # $nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $resourceGroup -Location $location ` 52 | # -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id 53 | # $vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $resourceGroup -Name $vnetName 54 | # $vm = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize 55 | # Set the VM image as source image for the new VM 56 | # $vm = Set-AzureRmVMSourceImage -VM $vm -Id $image.Id 57 | # Finish the VM configuration and add the NIC. 58 | # $vm = Set-AzureRmVMOSDisk -VM $vm -DiskSizeInGB $diskSizeGB -CreateOption FromImage -Caching ReadWrite 59 | # $vm = Set-AzureRmVMOperatingSystem -VM $vm -Windows -ComputerName $computerName -Credential $cred ` 60 | # -ProvisionVMAgent -EnableAutoUpdate 61 | # $vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id 62 | # Create the VM 63 | # New-AzureRmVM -VM $vm -ResourceGroupName $resourceGroup -Location $location 64 | # $vm = Set-AzureRmVMOperatingSystem -VM $vm -Windows -ComputerName $computerName -Credential $cred ` 65 | # -ProvisionVMAgent -EnableAutoUpdate 66 | # $vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id 67 | # Create the VM 68 | # New-AzureRmVM -VM $vm -ResourceGroupName $resourceGroup -Location $location 69 | -------------------------------------------------------------------------------- /windows_2019_docker_azure.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "0s", 5 | "communicator": "winrm", 6 | "cpus": 2, 7 | "differencing_disk": false, 8 | "disk_size": "{{user `disk_size`}}", 9 | "enable_secure_boot": true, 10 | "enable_virtualization_extensions": true, 11 | "floppy_files": [ 12 | "{{user `autounattend`}}", 13 | "./scripts/disable-screensaver.ps1", 14 | "./scripts/disable-winrm.ps1", 15 | "./scripts/docker/enable-winrm.ps1", 16 | "./scripts/docker/2016/install-containers-feature.ps1", 17 | "./scripts/microsoft-updates.bat", 18 | "./scripts/sysprep.bat", 19 | "./scripts/win-updates.ps1" 20 | ], 21 | "generation": 1, 22 | "guest_additions_mode": "disable", 23 | "iso_checksum": "{{user `iso_checksum`}}", 24 | "iso_url": "{{user `iso_url`}}", 25 | "memory": "{{user `memory`}}", 26 | "shutdown_command": "a:/sysprep.bat", 27 | "skip_compaction": true, 28 | "skip_export": true, 29 | "switch_name": "{{user `hyperv_switchname`}}", 30 | "type": "hyperv-iso", 31 | "use_fixed_vhd_format": true, 32 | "vm_name": "WindowsServer2019Docker", 33 | "winrm_password": "vagrant", 34 | "winrm_timeout": "{{user `winrm_timeout`}}", 35 | "winrm_username": "vagrant" 36 | } 37 | ], 38 | "post-processors": [], 39 | "provisioners": [ 40 | { 41 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 42 | "scripts": [ 43 | "./scripts/enable-rdp.bat" 44 | ], 45 | "type": "windows-shell" 46 | }, 47 | { 48 | "scripts": [ 49 | "./scripts/debloat-windows.ps1", 50 | "./scripts/docker/set-winrm-automatic.ps1" 51 | ], 52 | "type": "powershell" 53 | }, 54 | { 55 | "restart_timeout": "{{user `restart_timeout`}}", 56 | "type": "windows-restart" 57 | }, 58 | { 59 | "environment_vars": [ 60 | "docker_images={{user `docker_images`}}", 61 | "docker_provider={{user `docker_provider`}}", 62 | "docker_version={{user `docker_version`}}" 63 | ], 64 | "scripts": [ 65 | "./scripts/docker/add-docker-group.ps1", 66 | "./scripts/docker/install-docker.ps1", 67 | "./scripts/docker/docker-pull.ps1", 68 | "./scripts/wait-for-tiworker.ps1", 69 | "./scripts/docker/open-docker-swarm-ports.ps1", 70 | "./scripts/docker/remove-docker-key-json.ps1", 71 | "./scripts/docker/disable-windows-defender.ps1" 72 | ], 73 | "type": "powershell" 74 | }, 75 | { 76 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 77 | "scripts": [ 78 | "./scripts/pin-powershell.bat", 79 | "./scripts/set-winrm-automatic.bat", 80 | "./scripts/uac-enable.bat", 81 | "./scripts/compile-dotnet-assemblies.bat", 82 | "./scripts/dis-updates.bat" 83 | ], 84 | "type": "windows-shell" 85 | }, 86 | { 87 | "scripts": [ 88 | "./scripts/docker/chocolatey-and-tools.ps1", 89 | "./scripts/prepare-for-upload-vhd-image.ps1" 90 | ], 91 | "type": "powershell" 92 | } 93 | ], 94 | "variables": { 95 | "autounattend": "./answer_files/2019/Autounattend.xml", 96 | "disk_size": "51200", 97 | "disk_type_id": "1", 98 | "memory": "2048", 99 | "docker_images": "mcr.microsoft.com/windows/nanoserver:1809 mcr.microsoft.com/windows/servercore:ltsc2019", 100 | "docker_provider": "ee", 101 | "docker_version": "19.03.12", 102 | "headless": "false", 103 | "hyperv_switchname": "{{env `hyperv_switchname`}}", 104 | "iso_checksum": "sha256:6dae072e7f78f4ccab74a45341de0d6e2d45c39be25f1f5920a2ab4f51d7bcbb", 105 | "iso_url": "https://software-static.download.prss.microsoft.com/dbazure/988969d5-f34g-4e03-ac9d-1f9786c66749/17763.3650.221105-1748.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso", 106 | "manually_download_iso_from": "https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2019", 107 | "restart_timeout": "5m", 108 | "winrm_timeout": "2h" 109 | } 110 | } 111 | 112 | -------------------------------------------------------------------------------- /nested/terraform/windows.tf: -------------------------------------------------------------------------------- 1 | 2 | resource "azurerm_virtual_network" "windows" { 3 | name = "windows-virtnet" 4 | address_space = ["10.0.0.0/16"] 5 | location = "${var.location}" 6 | resource_group_name = "${azurerm_resource_group.global.name}" 7 | } 8 | 9 | resource "azurerm_subnet" "windows" { 10 | name = "windows-${format("%02d", count.index + 1)}-sn" 11 | resource_group_name = "${azurerm_resource_group.global.name}" 12 | virtual_network_name = "${azurerm_virtual_network.windows.name}" 13 | address_prefix = "10.0.2.0/24" 14 | } 15 | 16 | resource "azurerm_network_interface" "windows" { 17 | count = "${var.count}" 18 | name = "windows-${format("%02d", count.index + 1)}-nic" 19 | location = "${var.location}" 20 | resource_group_name = "${azurerm_resource_group.global.name}" 21 | 22 | ip_configuration { 23 | name = "testconfiguration1" 24 | subnet_id = "${azurerm_subnet.windows.id}" 25 | public_ip_address_id = "${element(azurerm_public_ip.windows.*.id, count.index)}" 26 | private_ip_address_allocation = "dynamic" 27 | } 28 | } 29 | 30 | resource "azurerm_public_ip" "windows" { 31 | count = "${var.count}" 32 | domain_name_label = "${var.dns_prefix}-${format("%02d", count.index + 1)}" 33 | idle_timeout_in_minutes = 30 34 | location = "${var.location}" 35 | name = "windows-${format("%02d", count.index + 1)}-publicip" 36 | public_ip_address_allocation = "dynamic" 37 | resource_group_name = "${azurerm_resource_group.global.name}" 38 | } 39 | 40 | resource "azurerm_storage_container" "windows" { 41 | container_access_type = "private" 42 | count = "${var.count}" 43 | name = "windows-${format("%02d", count.index + 1)}-storage" 44 | resource_group_name = "${azurerm_resource_group.global.name}" 45 | storage_account_name = "${azurerm_storage_account.global.name}" 46 | } 47 | 48 | resource "azurerm_virtual_machine" "windows" { 49 | count = "${var.count}" 50 | name = "windows-${format("%02d", count.index + 1)}-vm" 51 | location = "${var.location}" 52 | resource_group_name = "${azurerm_resource_group.global.name}" 53 | network_interface_ids = ["${element(azurerm_network_interface.windows.*.id, count.index)}"] 54 | vm_size = "${var.vm_size}" 55 | 56 | storage_image_reference { 57 | publisher = "MicrosoftWindowsServer" 58 | offer = "WindowsServer" 59 | sku = "2016-Datacenter" 60 | version = "latest" 61 | } 62 | 63 | storage_os_disk { 64 | name = "windows-${format("%02d", count.index + 1)}-osdisk" 65 | vhd_uri = "${azurerm_storage_account.global.primary_blob_endpoint}${element(azurerm_storage_container.windows.*.id, count.index)}/disk1.vhd" 66 | caching = "ReadWrite" 67 | create_option = "FromImage" 68 | } 69 | 70 | os_profile { 71 | computer_name = "${var.dns_prefix}-${format("%02d", count.index + 1)}" 72 | admin_username = "${var.admin_username}" 73 | admin_password = "${var.admin_password}" 74 | custom_data = "${base64encode("Param($HostName = \"${var.dns_prefix}-${format("%02d", count.index + 1)}.${var.location}.${var.azure_dns_suffix}\", $Username=\"${var.admin_username}\", $Password=\"${var.admin_password}\") ${file("./provision.ps1")}")}" 75 | } 76 | 77 | os_profile_windows_config { 78 | provision_vm_agent = true 79 | enable_automatic_upgrades = true 80 | additional_unattend_config { 81 | pass = "oobeSystem" 82 | component = "Microsoft-Windows-Shell-Setup" 83 | setting_name = "AutoLogon" 84 | content = "<AutoLogon><Password><Value>${var.admin_password}</Value></Password><Enabled>true</Enabled><LogonCount>1</LogonCount><Username>${var.admin_username}</Username></AutoLogon>" 85 | } 86 | additional_unattend_config { 87 | pass = "oobeSystem" 88 | component = "Microsoft-Windows-Shell-Setup" 89 | setting_name = "FirstLogonCommands" 90 | content = "${file("./FirstLogonCommands.xml")}" 91 | } 92 | } 93 | 94 | tags { 95 | environment = "staging" 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /scripts/openssh.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [switch]$AutoStart = $false 3 | ) 4 | 5 | Write-Output "AutoStart: $AutoStart" 6 | $is_64bit = [IntPtr]::size -eq 8 7 | 8 | # setup openssh 9 | $ssh_download_url = "https://www.mls-software.com/files/setupssh-7.1p1-1.exe" 10 | 11 | if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) { 12 | Write-Output "Downloading $ssh_download_url" 13 | (New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe") 14 | 15 | # initially set the port to 2222 so that there is not a race 16 | # condition in which packer connects to SSH before we can disable the service 17 | Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=2222 /privsep=1 /password=D@rj33l1ng" -NoNewWindow -Wait 18 | } 19 | 20 | Stop-Service "OpenSSHd" -Force 21 | 22 | # ensure vagrant can log in 23 | Write-Output "Setting vagrant user file permissions" 24 | New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh" 25 | C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F" 26 | C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX" 27 | C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX" 28 | 29 | Write-Output "Setting SSH home directories" 30 | (Get-Content "C:\Program Files\OpenSSH\etc\passwd") | 31 | Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } | 32 | Set-Content 'C:\Program Files\OpenSSH\etc\passwd' 33 | 34 | # disabled for vcloud to make vagrant-serverspec work 35 | # Set shell to /bin/sh to return exit status 36 | # $passwd_file = Get-Content 'C:\Program Files\OpenSSH\etc\passwd' 37 | # $passwd_file = $passwd_file -replace '/bin/bash', '/bin/sh' 38 | # Set-Content 'C:\Program Files\OpenSSH\etc\passwd' $passwd_file 39 | 40 | # fix opensshd to not be strict 41 | Write-Output "Setting OpenSSH to be non-strict" 42 | $sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config" 43 | $sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no' 44 | $sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes' 45 | $sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes' 46 | # disable the use of DNS to speed up the time it takes to establish a connection 47 | $sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no' 48 | # disable the login banner 49 | $sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/banner.txt' 50 | # next time OpenSSH starts have it listen on th eproper port 51 | $sshd_config = $sshd_config -replace 'Port 2222', "Port 22" 52 | Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config 53 | 54 | Write-Output "Removing ed25519 key as Vagrant net-ssh 2.9.1 does not support it" 55 | Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key" 56 | Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key.pub" 57 | 58 | # use c:\Windows\Temp as /tmp location 59 | Write-Output "Setting temp directory location" 60 | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\tmp" 61 | C:\Program` Files\OpenSSH\bin\junction.exe /accepteula "C:\Program Files\OpenSSH\tmp" "C:\Windows\Temp" 62 | C:\Windows\System32\icacls.exe "C:\Windows\Temp" /grant "vagrant:(OI)(CI)F" 63 | 64 | # add 64 bit environment variables missing from SSH 65 | Write-Output "Setting SSH environment" 66 | $sshenv = "TEMP=C:\Windows\Temp" 67 | if ($is_64bit) { 68 | $env_vars = "ProgramFiles(x86)=C:\Program Files (x86)", ` 69 | "ProgramW6432=C:\Program Files", ` 70 | "CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files", ` 71 | "CommonProgramW6432=C:\Program Files\Common Files" 72 | $sshenv = $sshenv + "`r`n" + ($env_vars -join "`r`n") 73 | } 74 | Set-Content C:\Users\vagrant\.ssh\environment $sshenv 75 | 76 | # record the path for provisioners (without the newline) 77 | Write-Output "Recording PATH for provisioners" 78 | Set-Content C:\Windows\Temp\PATH ([byte[]][char[]] $env:PATH) -Encoding Byte 79 | 80 | # configure firewall 81 | Write-Output "Configuring firewall" 82 | netsh advfirewall firewall add rule name="SSHD" dir=in action=allow service=OpenSSHd enable=yes 83 | netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="C:\Program Files\OpenSSH\usr\sbin\sshd.exe" enable=yes 84 | netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22 85 | 86 | if ($AutoStart -eq $true) { 87 | Start-Service "OpenSSHd" 88 | } 89 | -------------------------------------------------------------------------------- /windows_2012_r2_core.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "0m", 5 | "communicator": "winrm", 6 | "cpus": 2, 7 | "disk_size": "{{user `disk_size`}}", 8 | "enable_secure_boot": true, 9 | "enable_virtualization_extensions": true, 10 | "floppy_files": [ 11 | "{{user `autounattend`}}", 12 | "./scripts/disable-screensaver.ps1", 13 | "./scripts/disable-winrm.ps1", 14 | "./scripts/enable-winrm.ps1", 15 | "./scripts/microsoft-updates.bat", 16 | "./scripts/unattend.xml", 17 | "./scripts/sysprep.bat", 18 | "./scripts/win-updates.ps1" 19 | ], 20 | "guest_additions_mode": "disable", 21 | "iso_checksum": "{{user `iso_checksum`}}", 22 | "iso_url": "{{user `iso_url`}}", 23 | "memory": "{{user `memory`}}", 24 | "shutdown_command": "a:/sysprep.bat", 25 | "switch_name": "{{user `hyperv_switchname`}}", 26 | "type": "hyperv-iso", 27 | "vm_name": "windows_2012_r2", 28 | "winrm_password": "vagrant", 29 | "winrm_timeout": "{{user `winrm_timeout`}}", 30 | "winrm_username": "vagrant" 31 | }, 32 | { 33 | "boot_wait": "2m", 34 | "communicator": "winrm", 35 | "cpus": 2, 36 | "disk_adapter_type": "lsisas1068", 37 | "disk_size": "{{user `disk_size`}}", 38 | "floppy_files": [ 39 | "{{user `autounattend`}}", 40 | "./scripts/disable-winrm.ps1", 41 | "./scripts/enable-winrm.ps1", 42 | "./scripts/microsoft-updates.bat", 43 | "./scripts/win-updates.ps1" 44 | ], 45 | "guest_os_type": "windows8srv-64", 46 | "headless": "{{user `headless`}}", 47 | "iso_checksum": "{{user `iso_checksum`}}", 48 | "iso_url": "{{user `iso_url`}}", 49 | "memory": "{{user `memory`}}", 50 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 51 | "type": "vmware-iso", 52 | "vmx_data": { 53 | "RemoteDisplay.vnc.enabled": "false", 54 | "RemoteDisplay.vnc.port": "5900" 55 | }, 56 | "vmx_remove_ethernet_interfaces": true, 57 | "vnc_port_max": 5980, 58 | "vnc_port_min": 5900, 59 | "winrm_password": "vagrant", 60 | "winrm_timeout": "{{user `winrm_timeout`}}", 61 | "winrm_username": "vagrant" 62 | }, 63 | { 64 | "boot_wait": "2m", 65 | "communicator": "winrm", 66 | "cpus": 2, 67 | "disk_size": "{{user `disk_size`}}", 68 | "floppy_files": [ 69 | "{{user `autounattend`}}", 70 | "./scripts/disable-winrm.ps1", 71 | "./scripts/enable-winrm.ps1", 72 | "./scripts/microsoft-updates.bat", 73 | "./scripts/win-updates.ps1" 74 | ], 75 | "guest_additions_mode": "disable", 76 | "guest_os_type": "Windows2012_64", 77 | "headless": "{{user `headless`}}", 78 | "iso_checksum": "{{user `iso_checksum`}}", 79 | "iso_url": "{{user `iso_url`}}", 80 | "memory": "{{user `memory`}}", 81 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 82 | "type": "virtualbox-iso", 83 | "winrm_password": "vagrant", 84 | "winrm_timeout": "{{user `winrm_timeout`}}", 85 | "winrm_username": "vagrant" 86 | } 87 | ], 88 | "post-processors": [ 89 | { 90 | "keep_input_artifact": false, 91 | "output": "windows_2012_r2_core_{{.Provider}}.box", 92 | "type": "vagrant", 93 | "vagrantfile_template": "vagrantfile-windows_2012_r2.template" 94 | } 95 | ], 96 | "provisioners": [ 97 | { 98 | "scripts": [ 99 | "./scripts/vm-guest-tools.bat", 100 | "./scripts/enable-rdp.bat", 101 | "./scripts/compile-dotnet-assemblies.bat", 102 | "./scripts/disable-auto-logon.bat", 103 | "./scripts/compact.bat" 104 | ], 105 | "type": "windows-shell" 106 | } 107 | ], 108 | "variables": { 109 | "autounattend": "./answer_files/2012_r2_core/Autounattend.xml", 110 | "disk_size": "61440", 111 | "disk_type_id": "1", 112 | "memory": "2048", 113 | "headless": "true", 114 | "hyperv_switchname": "{{env `hyperv_switchname`}}", 115 | "iso_checksum": "md5:5b5e08c490ad16b59b1d9fab0def883a", 116 | "iso_url": "http://care.dlservice.microsoft.com/dl/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_SERVER_EVAL_EN-US-IR3_SSS_X64FREE_EN-US_DV9.ISO", 117 | "winrm_timeout": "6h" 118 | } 119 | } 120 | 121 | -------------------------------------------------------------------------------- /windows_2012_r2.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "0m", 5 | "communicator": "winrm", 6 | "cpus": 2, 7 | "disk_size": "{{user `disk_size`}}", 8 | "enable_secure_boot": true, 9 | "enable_virtualization_extensions": true, 10 | "floppy_files": [ 11 | "{{user `autounattend`}}", 12 | "./scripts/disable-screensaver.ps1", 13 | "./scripts/disable-winrm.ps1", 14 | "./scripts/enable-winrm.ps1", 15 | "./scripts/microsoft-updates.bat", 16 | "./scripts/unattend.xml", 17 | "./scripts/sysprep.bat", 18 | "./scripts/win-updates.ps1" 19 | ], 20 | "guest_additions_mode": "disable", 21 | "iso_checksum": "{{user `iso_checksum`}}", 22 | "iso_url": "{{user `iso_url`}}", 23 | "memory": "{{user `memory`}}", 24 | "shutdown_command": "a:/sysprep.bat", 25 | "switch_name": "{{user `hyperv_switchname`}}", 26 | "type": "hyperv-iso", 27 | "vm_name": "windows_2012_r2", 28 | "winrm_password": "vagrant", 29 | "winrm_timeout": "{{user `winrm_timeout`}}", 30 | "winrm_username": "vagrant" 31 | }, 32 | { 33 | "boot_wait": "2m", 34 | "communicator": "winrm", 35 | "cpus": 2, 36 | "disk_adapter_type": "lsisas1068", 37 | "disk_size": "{{user `disk_size`}}", 38 | "floppy_files": [ 39 | "{{user `autounattend`}}", 40 | "./scripts/disable-winrm.ps1", 41 | "./scripts/enable-winrm.ps1", 42 | "./scripts/microsoft-updates.bat", 43 | "./scripts/unattend.xml", 44 | "./scripts/win-updates.ps1" 45 | ], 46 | "guest_os_type": "windows8srv-64", 47 | "headless": "{{user `headless`}}", 48 | "iso_checksum": "{{user `iso_checksum`}}", 49 | "iso_url": "{{user `iso_url`}}", 50 | "memory": "{{user `memory`}}", 51 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 52 | "skip_compaction": true, 53 | "type": "vmware-iso", 54 | "vm_name": "windows_2012_r2", 55 | "vmx_data": { 56 | "RemoteDisplay.vnc.enabled": "false", 57 | "RemoteDisplay.vnc.port": "5900" 58 | }, 59 | "vmx_remove_ethernet_interfaces": true, 60 | "vnc_port_max": 5980, 61 | "vnc_port_min": 5900, 62 | "winrm_password": "vagrant", 63 | "winrm_timeout": "{{user `winrm_timeout`}}", 64 | "winrm_username": "vagrant" 65 | }, 66 | { 67 | "boot_wait": "2m", 68 | "communicator": "winrm", 69 | "cpus": 2, 70 | "disk_size": "{{user `disk_size`}}", 71 | "floppy_files": [ 72 | "{{user `autounattend`}}", 73 | "./scripts/disable-winrm.ps1", 74 | "./scripts/enable-winrm.ps1", 75 | "./scripts/microsoft-updates.bat", 76 | "./scripts/unattend.xml", 77 | "./scripts/win-updates.ps1" 78 | ], 79 | "guest_additions_mode": "disable", 80 | "guest_os_type": "Windows2012_64", 81 | "headless": "{{user `headless`}}", 82 | "iso_checksum": "{{user `iso_checksum`}}", 83 | "iso_url": "{{user `iso_url`}}", 84 | "memory": "{{user `memory`}}", 85 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 86 | "type": "virtualbox-iso", 87 | "vm_name": "windows_2012_r2", 88 | "winrm_password": "vagrant", 89 | "winrm_timeout": "{{user `winrm_timeout`}}", 90 | "winrm_username": "vagrant" 91 | } 92 | ], 93 | "post-processors": [ 94 | { 95 | "keep_input_artifact": false, 96 | "output": "windows_2012_r2_{{.Provider}}.box", 97 | "type": "vagrant", 98 | "vagrantfile_template": "vagrantfile-windows_2012_r2.template" 99 | } 100 | ], 101 | "provisioners": [ 102 | { 103 | "scripts": [ 104 | "./scripts/vm-guest-tools.bat", 105 | "./scripts/enable-rdp.bat", 106 | "./scripts/compile-dotnet-assemblies.bat", 107 | "./scripts/compact.bat" 108 | ], 109 | "type": "windows-shell" 110 | } 111 | ], 112 | "variables": { 113 | "autounattend": "./answer_files/2012_r2/Autounattend.xml", 114 | "disk_size": "61440", 115 | "disk_type_id": "1", 116 | "memory": "2048", 117 | "headless": "true", 118 | "hyperv_switchname": "{{env `hyperv_switchname`}}", 119 | "iso_checksum": "md5:5b5e08c490ad16b59b1d9fab0def883a", 120 | "iso_url": "http://care.dlservice.microsoft.com/dl/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_SERVER_EVAL_EN-US-IR3_SSS_X64FREE_EN-US_DV9.ISO", 121 | "winrm_timeout": "6h" 122 | } 123 | } 124 | 125 | -------------------------------------------------------------------------------- /windows_2016_hyperv.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "0s", 5 | "communicator": "winrm", 6 | "configuration_version": "8.0", 7 | "cpus": 2, 8 | "disk_size": "{{user `disk_size`}}", 9 | "enable_secure_boot": true, 10 | "floppy_files": [ 11 | "{{user `autounattend`}}", 12 | "./scripts/disable-winrm.ps1", 13 | "./scripts/enable-winrm.ps1", 14 | "./scripts/microsoft-updates.bat", 15 | "./scripts/win-updates.ps1" 16 | ], 17 | "guest_additions_mode": "disable", 18 | "iso_checksum": "{{user `iso_checksum`}}", 19 | "iso_url": "{{user `iso_url`}}", 20 | "memory": "{{user `memory`}}", 21 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 22 | "switch_name": "{{user `hyperv_switchname`}}", 23 | "type": "hyperv-iso", 24 | "vm_name": "HyperVServer2016", 25 | "winrm_password": "vagrant", 26 | "winrm_timeout": "{{user `winrm_timeout`}}", 27 | "winrm_username": "vagrant" 28 | }, 29 | { 30 | "boot_wait": "2m", 31 | "communicator": "winrm", 32 | "cpus": 2, 33 | "disk_adapter_type": "lsisas1068", 34 | "disk_size": "{{user `disk_size`}}", 35 | "disk_type_id": "{{user `disk_type_id`}}", 36 | "floppy_files": [ 37 | "{{user `autounattend`}}", 38 | "./scripts/disable-winrm.ps1", 39 | "./scripts/enable-winrm.ps1", 40 | "./scripts/microsoft-updates.bat", 41 | "./scripts/win-updates.ps1" 42 | ], 43 | "guest_os_type": "windows9srv-64", 44 | "headless": "{{user `headless`}}", 45 | "iso_checksum": "{{user `iso_checksum`}}", 46 | "iso_url": "{{user `iso_url`}}", 47 | "memory": "{{user `memory`}}", 48 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 49 | "type": "vmware-iso", 50 | "vmx_data": { 51 | "RemoteDisplay.vnc.enabled": "false", 52 | "RemoteDisplay.vnc.port": "5900" 53 | }, 54 | "vmx_remove_ethernet_interfaces": true, 55 | "vnc_port_max": 5980, 56 | "vnc_port_min": 5900, 57 | "winrm_password": "vagrant", 58 | "winrm_timeout": "{{user `winrm_timeout`}}", 59 | "winrm_username": "vagrant" 60 | }, 61 | { 62 | "boot_wait": "2m", 63 | "communicator": "winrm", 64 | "cpus": 2, 65 | "disk_size": "{{user `disk_size`}}", 66 | "floppy_files": [ 67 | "{{user `autounattend`}}", 68 | "./scripts/disable-winrm.ps1", 69 | "./scripts/enable-winrm.ps1", 70 | "./scripts/microsoft-updates.bat", 71 | "./scripts/win-updates.ps1" 72 | ], 73 | "guest_additions_mode": "disable", 74 | "guest_os_type": "Windows2016_64", 75 | "headless": "{{user `headless`}}", 76 | "iso_checksum": "{{user `iso_checksum`}}", 77 | "iso_url": "{{user `iso_url`}}", 78 | "memory": "{{user `memory`}}", 79 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 80 | "type": "virtualbox-iso", 81 | "winrm_password": "vagrant", 82 | "winrm_timeout": "{{user `winrm_timeout`}}", 83 | "winrm_username": "vagrant" 84 | } 85 | ], 86 | "post-processors": [ 87 | { 88 | "keep_input_artifact": false, 89 | "output": "windows_2016_hyperv_{{.Provider}}.box", 90 | "type": "vagrant", 91 | "vagrantfile_template": "vagrantfile-windows_2016.template" 92 | } 93 | ], 94 | "provisioners": [ 95 | { 96 | "scripts": [ 97 | "./scripts/vm-guest-tools.bat", 98 | "./scripts/enable-rdp.bat" 99 | ], 100 | "type": "windows-shell" 101 | }, 102 | { 103 | "scripts": [ 104 | "./scripts/debloat-windows.ps1" 105 | ], 106 | "type": "powershell" 107 | }, 108 | { 109 | "scripts": [ 110 | "./scripts/set-winrm-automatic.bat", 111 | "./scripts/uac-enable.bat", 112 | "./scripts/compile-dotnet-assemblies.bat", 113 | "./scripts/dis-updates.bat", 114 | "./scripts/compact.bat" 115 | ], 116 | "type": "windows-shell" 117 | } 118 | ], 119 | "variables": { 120 | "autounattend": "./answer_files/2016_hyperv/Autounattend.xml", 121 | "disk_size": "61440", 122 | "disk_type_id": "1", 123 | "memory": "2048", 124 | "headless": "false", 125 | "iso_checksum": "sha256:53e2f01dc4077192a85f60f8d2ffb02189074e19b25f990cbe9eb767328d3fb6", 126 | "iso_url": "https://download.microsoft.com/download/8/8/6/886DAAEF-81A7-4418-82D5-07D33B816962/14393.0.161119-1705.RS1_REFRESH_SERVERHYPERCORE_OEM_X64FRE_EN-US.ISO", 127 | "winrm_timeout": "6h" 128 | } 129 | } 130 | 131 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Unreleased 2 | * Fixed issue with Console Output (#245) 3 | * Added a Parallels builder for Windows 2019 with Docker 4 | 5 | ## v1.24 (June 8th, 2015) 6 | 7 | * Clarified use of the `<Key>` element in Windows 8.1 autounattend file (#114) 8 | * Fixed issue with OpenSSH / Packer race condition (#113) 9 | * Fixed issue with Windows 8.1 product key and computer name (#121) 10 | * Fixed issue where disk size would always be 60GB regardless of value in packer template (#117) 11 | * Added Windows 10 Technical Preview (#132, #144) 12 | * Fixed Windows Updates for Windows 2008 R2 builds (#135) 13 | * Display Windows Updates that have been installed (#139) 14 | * Added support for Hyper-V Server 2012 R2 (#120) 15 | * Updated OpenSSH to 6.7 (#111) 16 | * Updated Ultadefrag to 6.1.0 (#145) 17 | * Fixed ComputerName for Windows 7 build (#125) 18 | 19 | ## v1.23 (Nov 5th, 2014) 20 | 21 | * Resolved issue with Windows 7 not successfully completing an update run (#83) 22 | 23 | ## v1.22 (Sept 8th, 2014) 24 | 25 | * Forward SSH port by default on Vagrant boxes (#76) 26 | * Box no longer auto logs on upon boot (#66) 27 | * Updated Virtualbox Guest OS Type for Win8.1 (#81) 28 | 29 | ## v1.21 (Aug 6th, 2014) 30 | 31 | * Added rsync.bat as an optional script to include rsync capabilities to the vagrant box (#88) 32 | * RDP now enabled for use with vagrant (#75) 33 | 34 | ## v1.20 (July 21st, 2014) 35 | 36 | * Update Chocolatey script for Chocolatey 0.9.8.27 37 | * Password for Vagrant user never expires 38 | * Salt installation script 39 | * Microsoft-updates.bat script for Win 7/8 40 | 41 | ## v1.19 (May 17th, 2014) 42 | 43 | * Enable Microsoft Updates by default (#60) 44 | * Remove disable Windows Updates script from Windows 7 and 8.1; you can run this as a provioner step, and use Autounattend sections to achieve the same outcome 45 | 46 | ## v1.18 (May 16th, 2014) 47 | 48 | * Require Vagrant 1.6.2 (#57) 49 | * Remove WinRM port forward, as it's done automatically in Vagrant 1.6.2+ (#57) 50 | * Update chef-client source to getchef.com (#63) 51 | 52 | ## v1.16 (May 7th, 2014) 53 | 54 | * Fix VirtualBox ISO URLs 55 | 56 | ## v1.15 (May 7th, 2014) 57 | 58 | * Update Puppet to 3.5.1 (#54) 59 | * Fix ISO Url for 2008 R2 (#56) 60 | 61 | ## v1.14 (May 6th, 2014) 62 | 63 | * Compact generated VMs using ultradefrag and sdelete (#53) 64 | * Fix 2008 R2 Core Autounattend.xml steps 65 | 66 | ## v1.13 (May 2nd, 2014) 67 | 68 | * Fixed ISO Urls (#47) 69 | 70 | ## v1.12 (April 29th, 2014) 71 | 72 | * Update OpenSSH 73 | 74 | ## v1.11 (April 5th, 2014) 75 | 76 | * Change the default shell for OpenSSH from /bin/bash to /bin/sh (#45) 77 | 78 | ## v1.10 (March 18th, 2014) 79 | 80 | * Ensure WinRM service starts immediately rather than after 120 seconds (#43) 81 | 82 | ## v1.9 (March 14th, 2014) 83 | 84 | * Add support for Windows 8.1 85 | * Add port forwarding for WinRM (5985) by default, with vagrant auto-correct enabled 86 | * Require the use of the vagrant-windows plugin in the Vagrantfile templates 87 | 88 | ## v1.8 (March 7th, 2014) 89 | 90 | * Updated oracle.cer to allow installation of VirtualBox tools 91 | 92 | ## v1.7 (February 26, 2014) 93 | 94 | * Add support for Windows 7 Enterprise 95 | * Add support for Windows 2008 R2 Core 96 | * Add support for Windows 2012 R2 Core 97 | * Remove port forwarding from Vagrantfile templates 98 | * Update Puppet version in scripts/puppet.bat 99 | 100 | ## v1.6 (January 20, 2014) 101 | 102 | * Remove `config.vm.base_mac = "{{ .BaseMacAddress }}"` from vagrantfile templates, ensure SCSI controller is set in VMX (fixes #26) 103 | 104 | ## v1.5 (January 9, 2014) 105 | 106 | * Fix issue with installation of VM guest tools [GH-23] 107 | 108 | ## v1.4 (December 31, 2013) 109 | 110 | * Update .json files to work with Packer 0.5.0 (the `vmware` builder is renamed to `vmware-iso`, the `virtualbox` builder is renamed to `virtualbox-iso`) 111 | * Update README with better examples for using retail custom ISO files and disabling Windows Update installation 112 | 113 | ## v1.3 (December 18, 2013) 114 | 115 | * Allow Packer to upload VMware Tools by default, but fall back to downloading the tools from VMware if required 116 | * Update SCSI bus type for the hard disk in a VMware VM to permit Windows 2012 R2 to install correctly 117 | * Fix Windows 2012 R2 issue where the `vagrant` user did not have its password set 118 | * Fix Windows 2012 R2 issue where autologon only works once 119 | 120 | ## v1.2 (December 18, 2013) 121 | 122 | * Add support for Windows 2012 and Windows 2012 R2 123 | * Switch all configurations to use Microsoft trial images that are publicly accessible so that you do not need MSDN or TechNet to use this repo 124 | 125 | ## v1.1 (December 17, 2013) 126 | 127 | * Initial release, including working Windows 2008 R2 configuration 128 | -------------------------------------------------------------------------------- /windows_2016_core.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "0s", 5 | "communicator": "winrm", 6 | "configuration_version": "8.0", 7 | "cpus": 2, 8 | "disk_size": "{{user `disk_size`}}", 9 | "enable_secure_boot": true, 10 | "floppy_files": [ 11 | "{{user `autounattend`}}", 12 | "./scripts/disable-screensaver.ps1", 13 | "./scripts/disable-winrm.ps1", 14 | "./scripts/enable-winrm.ps1", 15 | "./scripts/microsoft-updates.bat", 16 | "./scripts/win-updates.ps1" 17 | ], 18 | "guest_additions_mode": "disable", 19 | "iso_checksum": "{{user `iso_checksum`}}", 20 | "iso_url": "{{user `iso_url`}}", 21 | "memory": "{{user `memory`}}", 22 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 23 | "switch_name": "{{user `hyperv_switchname`}}", 24 | "type": "hyperv-iso", 25 | "vm_name": "WindowsServer2016Core", 26 | "winrm_password": "vagrant", 27 | "winrm_timeout": "{{user `winrm_timeout`}}", 28 | "winrm_username": "vagrant" 29 | }, 30 | { 31 | "boot_wait": "2m", 32 | "communicator": "winrm", 33 | "cpus": 2, 34 | "disk_adapter_type": "lsisas1068", 35 | "disk_size": "{{user `disk_size`}}", 36 | "disk_type_id": "{{user `disk_type_id`}}", 37 | "floppy_files": [ 38 | "{{user `autounattend`}}", 39 | "./scripts/disable-screensaver.ps1", 40 | "./scripts/disable-winrm.ps1", 41 | "./scripts/enable-winrm.ps1", 42 | "./scripts/microsoft-updates.bat", 43 | "./scripts/win-updates.ps1" 44 | ], 45 | "guest_os_type": "windows9srv-64", 46 | "headless": "{{user `headless`}}", 47 | "iso_checksum": "{{user `iso_checksum`}}", 48 | "iso_url": "{{user `iso_url`}}", 49 | "memory": "{{user `memory`}}", 50 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 51 | "type": "vmware-iso", 52 | "vmx_data": { 53 | "RemoteDisplay.vnc.enabled": "false", 54 | "RemoteDisplay.vnc.port": "5900" 55 | }, 56 | "vmx_remove_ethernet_interfaces": true, 57 | "vnc_port_max": 5980, 58 | "vnc_port_min": 5900, 59 | "winrm_password": "vagrant", 60 | "winrm_timeout": "{{user `winrm_timeout`}}", 61 | "winrm_username": "vagrant" 62 | }, 63 | { 64 | "boot_wait": "2m", 65 | "communicator": "winrm", 66 | "cpus": 2, 67 | "disk_size": "{{user `disk_size`}}", 68 | "floppy_files": [ 69 | "{{user `autounattend`}}", 70 | "./scripts/disable-screensaver.ps1", 71 | "./scripts/disable-winrm.ps1", 72 | "./scripts/enable-winrm.ps1", 73 | "./scripts/microsoft-updates.bat", 74 | "./scripts/win-updates.ps1" 75 | ], 76 | "guest_additions_mode": "disable", 77 | "guest_os_type": "Windows2016_64", 78 | "headless": "{{user `headless`}}", 79 | "iso_checksum": "{{user `iso_checksum`}}", 80 | "iso_url": "{{user `iso_url`}}", 81 | "memory": "{{user `memory`}}", 82 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 83 | "type": "virtualbox-iso", 84 | "winrm_password": "vagrant", 85 | "winrm_timeout": "{{user `winrm_timeout`}}", 86 | "winrm_username": "vagrant" 87 | } 88 | ], 89 | "post-processors": [ 90 | { 91 | "keep_input_artifact": false, 92 | "output": "windows_2016_core_{{.Provider}}.box", 93 | "type": "vagrant", 94 | "vagrantfile_template": "vagrantfile-windows_2016_core.template" 95 | } 96 | ], 97 | "provisioners": [ 98 | { 99 | "scripts": [ 100 | "./scripts/vm-guest-tools.bat", 101 | "./scripts/enable-rdp.bat" 102 | ], 103 | "type": "windows-shell" 104 | }, 105 | { 106 | "scripts": [ 107 | "./scripts/debloat-windows.ps1" 108 | ], 109 | "type": "powershell" 110 | }, 111 | { 112 | "scripts": [ 113 | "./scripts/set-winrm-automatic.bat", 114 | "./scripts/uac-enable.bat", 115 | "./scripts/compile-dotnet-assemblies.bat", 116 | "./scripts/dis-updates.bat", 117 | "./scripts/compact.bat" 118 | ], 119 | "type": "windows-shell" 120 | } 121 | ], 122 | "variables": { 123 | "autounattend": "./answer_files/2016_core/Autounattend.xml", 124 | "disk_size": "61440", 125 | "disk_type_id": "1", 126 | "memory": "2048", 127 | "headless": "false", 128 | "iso_checksum": "md5:70721288BBCDFE3239D8F8C0FAE55F1F", 129 | "iso_url": "https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO", 130 | "winrm_timeout": "6h" 131 | } 132 | } 133 | 134 | -------------------------------------------------------------------------------- /bin/test-box-vcloud.bat: -------------------------------------------------------------------------------- 1 | rem 2 | rem bin\test-box-vcloud.bat ubuntu1204_vcloud.box ubuntu1204 3 | set quick=0 4 | set debug=0 5 | 6 | if "%1x"=="--quickx" ( 7 | shift 8 | set quick=1 9 | ) 10 | if "%1x"=="--debugx" ( 11 | shift 12 | set debug=1 13 | ) 14 | set box_path=%1 15 | set box_name=%2 16 | set box_provider=vcloud 17 | set vagrant_provider=vcloud 18 | set test_src_path=../test/*_spec.rb 19 | 20 | set result=0 21 | 22 | set tmp_path=boxtest 23 | if exist %tmp_path% rmdir /s /q %tmp_path% 24 | 25 | if %quick%==1 goto :do_test 26 | 27 | if exist C:\Users\vagrant\.vagrant.d\Vagrantfile goto :have_vagrantfile 28 | if exist C:\vagrant\resources\Vagrantfile-global ( 29 | copy C:\vagrant\resources\Vagrantfile-global C:\Users\vagrant\.vagrant.d\Vagrantfile 30 | ) 31 | :have_vagrantfile 32 | 33 | rem tested only with box-provider=vcloud 34 | rem vagrant plugin install vagrant-%box_provider% 35 | 36 | rem vagrant plugin install vagrant-serverspec 37 | 38 | vagrant box remove %box_name% --provider=%vagrant_provider% 39 | vagrant box add %box_name% %box_path% 40 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 41 | if ERRORLEVEL 1 goto :done 42 | 43 | @set vcloud_hostname=YOUR-VCLOUD-HOSTNAME 44 | @set vcloud_username=YOUR-VCLOUD-USERNAME 45 | @set vcloud_password=YOUR-VCLOUD-PASSWORD 46 | @set vcloud_org=YOUR-VCLOUD-ORG 47 | @set vcloud_catalog=YOUR-VCLOUD-CATALOG 48 | @set vcloud_vdc=YOUR-VCLOUD-VDC 49 | 50 | if "%VAGRANT_HOME%x"=="x" set VAGRANT_HOME=%USERPROFILE%\.vagrant.d 51 | 52 | if exist c:\vagrant\resources\test-box-vcloud-credentials.bat call c:\vagrant\resources\test-box-vcloud-credentials.bat 53 | 54 | echo Uploading %box_name%.ovf to vCloud %vcloud_hostname% / %vcloud_org% / %vcloud_catalog% / %box_name% 55 | @ovftool --acceptAllEulas --vCloudTemplate --overwrite %VAGRANT_HOME%\boxes\%box_name%\0\%box_provider%\%box_name%.ovf "vcloud://%vcloud_username%:%vcloud_password%@%vcloud_hostname%:443?org=%vcloud_org%&vappTemplate=%box_name%&catalog=%vcloud_catalog%&vdc=%vcloud_vdc%" 56 | if ERRORLEVEL 1 goto :first_upload 57 | goto :test_vagrant_box 58 | :first_upload 59 | @ovftool --acceptAllEulas --vCloudTemplate %VAGRANT_HOME%\boxes\%box_name%\0\%box_provider%\%box_name%.ovf "vcloud://%vcloud_username%:%vcloud_password%@%vcloud_hostname%:443?org=%vcloud_org%&vappTemplate=%box_name%&catalog=%vcloud_catalog%&vdc=%vcloud_vdc%" 60 | if ERRORLEVEL 1 goto :error_vcloud_upload 61 | 62 | :test_vagrant_box 63 | @echo. 64 | @echo Sleeping 300 seconds for vCloud to finish vAppTemplate import 65 | @echo Tests with 240 seconds still cause a 500 internal error while powering on 66 | @echo a vApp in vCloud. So be patient until we have a better upload 67 | @echo solution that waits until the import is really finished. 68 | @ping 1.1.1.1 -n 1 -w 300000 > nul 69 | 70 | :do_test 71 | set result=0 72 | 73 | mkdir %tmp_path% 74 | pushd %tmp_path% 75 | call :create_vagrantfile 76 | if %debug%==1 set VAGRANT_LOG=debug 77 | echo USERPROFILE = %USERPROFILE% 78 | if exist %USERPROFILE%\.ssh\known_hosts type %USERPROFILE%\.ssh\known_hosts 79 | del /F %USERPROFILE%\.ssh\known_hosts 80 | if exist %USERPROFILE%\.ssh\known_hosts echo known_hosts still here!! 81 | vagrant up --provider=%vagrant_provider% 82 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 83 | 84 | if %debug%==1 set VAGRANT_LOG=debug 85 | @echo Sleep 10 seconds 86 | @ping 1.1.1.1 -n 1 -w 10000 > nul 87 | 88 | vagrant destroy -f 89 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 90 | popd 91 | 92 | if %quick%==1 goto :done 93 | 94 | if %debug%==1 set VAGRANT_LOG=debug 95 | vagrant box remove %box_name% --provider=%vagrant_provider% 96 | if ERRORLEVEL 1 set result=%ERRORLEVEL% 97 | 98 | goto :done 99 | 100 | :error_vcloud_upload 101 | echo Error Uploading box to vCloud with ovftool! 102 | goto :done 103 | 104 | :create_vagrantfile 105 | 106 | rem to test if rsync works 107 | if not exist testdir\testfile.txt ( 108 | mkdir testdir 109 | echo Works >testdir\testfile.txt 110 | ) 111 | 112 | echo Vagrant.configure('2') do ^|config^| >Vagrantfile 113 | echo config.vm.define :"tst" do ^|tst^| >>Vagrantfile 114 | echo tst.vm.box = "%box_name%" >>Vagrantfile 115 | echo tst.vm.hostname = "tst" 116 | echo tst.vm.provider :vcloud do ^|vcloud, override^| >>Vagrantfile 117 | echo vcloud.vapp_prefix = "%box_name%" >>Vagrantfile 118 | echo override.vm.usable_port_range = 2200..2999 >>Vagrantfile 119 | echo end >>Vagrantfile 120 | echo tst.vm.provision :serverspec do ^|spec^| >>Vagrantfile 121 | echo spec.pattern = '../test/*_%box_provider%.rb' >>Vagrantfile 122 | echo end >>Vagrantfile 123 | echo end >>Vagrantfile 124 | echo end >>Vagrantfile 125 | 126 | exit /b 127 | 128 | :done 129 | exit %result% 130 | -------------------------------------------------------------------------------- /windows_server_insider.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_command": [ 5 | "<enter>" 6 | ], 7 | "boot_wait": "1s", 8 | "communicator": "winrm", 9 | "cpus": 2, 10 | "disk_size": "{{user `disk_size`}}", 11 | "enable_secure_boot": true, 12 | "enable_virtualization_extensions": true, 13 | "generation": 2, 14 | "guest_additions_mode": "disable", 15 | "iso_checksum": "{{user `iso_checksum`}}", 16 | "iso_url": "{{user `iso_url`}}", 17 | "memory": "{{user `memory`}}", 18 | "secondary_iso_images": [ 19 | "./iso/windows_server_insider_unattend.iso" 20 | ], 21 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 22 | "switch_name": "{{user `hyperv_switchname`}}", 23 | "type": "hyperv-iso", 24 | "vm_name": "WindowsServerInsider", 25 | "winrm_password": "vagrant", 26 | "winrm_timeout": "{{user `winrm_timeout`}}", 27 | "winrm_username": "vagrant" 28 | }, 29 | { 30 | "boot_command": [ 31 | "<enter>" 32 | ], 33 | "boot_wait": "60s", 34 | "communicator": "winrm", 35 | "cpus": 2, 36 | "disk_adapter_type": "lsisas1068", 37 | "disk_size": "{{user `disk_size`}}", 38 | "disk_type_id": "{{user `disk_type_id`}}", 39 | "floppy_files": [ 40 | "./scripts/disable-winrm.ps1", 41 | "./scripts/enable-winrm.ps1" 42 | ], 43 | "guest_os_type": "windows9srv-64", 44 | "headless": "{{user `headless`}}", 45 | "iso_checksum": "{{user `iso_checksum`}}", 46 | "iso_url": "{{user `iso_url`}}", 47 | "memory": "{{user `memory`}}", 48 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 49 | "type": "vmware-iso", 50 | "version": 14, 51 | "vm_name": "WindowsServerInsider", 52 | "vmx_data": { 53 | "RemoteDisplay.vnc.enabled": "false", 54 | "RemoteDisplay.vnc.port": "5900", 55 | "vhv.enable": "{{user `vhv_enable`}}" 56 | }, 57 | "vmx_remove_ethernet_interfaces": true, 58 | "vnc_port_max": 5980, 59 | "vnc_port_min": 5900, 60 | "winrm_password": "vagrant", 61 | "winrm_timeout": "{{user `winrm_timeout`}}", 62 | "winrm_username": "vagrant" 63 | }, 64 | { 65 | "boot_command": [ 66 | "<enter>" 67 | ], 68 | "boot_wait": "60s", 69 | "communicator": "winrm", 70 | "cpus": 2, 71 | "disk_size": "{{user `disk_size`}}", 72 | "floppy_files": [ 73 | "{{user `autounattend`}}", 74 | "./scripts/disable-screensaver.ps1", 75 | "./scripts/disable-winrm.ps1", 76 | "./scripts/enable-winrm.ps1" 77 | ], 78 | "guest_additions_mode": "disable", 79 | "guest_os_type": "Windows2016_64", 80 | "headless": "{{user `headless`}}", 81 | "iso_checksum": "{{user `iso_checksum`}}", 82 | "iso_url": "{{user `iso_url`}}", 83 | "memory": "{{user `memory`}}", 84 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 85 | "type": "virtualbox-iso", 86 | "vm_name": "WindowsServerInsider", 87 | "winrm_password": "vagrant", 88 | "winrm_timeout": "{{user `winrm_timeout`}}", 89 | "winrm_username": "vagrant" 90 | } 91 | ], 92 | "post-processors": [ 93 | { 94 | "keep_input_artifact": false, 95 | "output": "windows_server_insider_{{.Provider}}.box", 96 | "type": "vagrant", 97 | "vagrantfile_template": "vagrantfile-windows_2019_core.template" 98 | } 99 | ], 100 | "provisioners": [ 101 | { 102 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 103 | "scripts": [ 104 | "./scripts/enable-rdp.bat" 105 | ], 106 | "type": "windows-shell" 107 | }, 108 | { 109 | "scripts": [ 110 | "./scripts/vm-guest-tools.ps1" 111 | ], 112 | "type": "powershell" 113 | }, 114 | { 115 | "restart_timeout": "{{user `restart_timeout`}}", 116 | "type": "windows-restart" 117 | }, 118 | { 119 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 120 | "scripts": [ 121 | "./scripts/set-winrm-automatic.bat", 122 | "./scripts/uac-enable.bat", 123 | "./scripts/compact.bat" 124 | ], 125 | "type": "windows-shell" 126 | } 127 | ], 128 | "variables": { 129 | "autounattend": "./answer_files/server_insider/Autounattend.xml", 130 | "disk_size": "61440", 131 | "disk_type_id": "1", 132 | "memory": "2048", 133 | "headless": "false", 134 | "iso_checksum": "sha256:72e950c22f5db8ca4448d8eb277cdc8236901fad3f0900f7a7564cffa0306a78", 135 | "iso_url": "https://software-download.microsoft.com/db/Windows_InsiderPreview_Server_vNext_en-us_20201.iso", 136 | "manually_download_iso_from": "https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewserver", 137 | "restart_timeout": "5m", 138 | "vhv_enable": "false", 139 | "winrm_timeout": "2h" 140 | } 141 | } 142 | 143 | -------------------------------------------------------------------------------- /windows_11_insider.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_command": "", 5 | "boot_wait": "6m", 6 | "communicator": "winrm", 7 | "cpus": 2, 8 | "disk_adapter_type": "lsisas1068", 9 | "disk_size": "{{user `disk_size`}}", 10 | "floppy_files": [ 11 | "{{user `autounattend`}}", 12 | "./floppy/WindowsPowershell.lnk", 13 | "./scripts/fixnetwork.ps1", 14 | "./scripts/disable-screensaver.ps1", 15 | "./scripts/disable-winrm.ps1", 16 | "./scripts/enable-winrm.ps1", 17 | "./scripts/microsoft-updates.bat", 18 | "./scripts/win-updates.ps1" 19 | ], 20 | "guest_os_type": "windows9-64", 21 | "headless": false, 22 | "iso_checksum": "{{user `iso_checksum`}}", 23 | "iso_url": "{{user `iso_url`}}", 24 | "memory": "{{user `memory`}}", 25 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 26 | "type": "vmware-iso", 27 | "version": 14, 28 | "vmx_data": { 29 | "RemoteDisplay.vnc.enabled": "false", 30 | "RemoteDisplay.vnc.port": "5900" 31 | }, 32 | "vmx_remove_ethernet_interfaces": true, 33 | "vnc_port_max": 5980, 34 | "vnc_port_min": 5900, 35 | "winrm_password": "vagrant", 36 | "winrm_timeout": "2h", 37 | "winrm_username": "vagrant" 38 | }, 39 | { 40 | "boot_command": "", 41 | "boot_wait": "6m", 42 | "communicator": "winrm", 43 | "cpus": 2, 44 | "disk_size": "{{user `disk_size`}}", 45 | "floppy_files": [ 46 | "{{user `autounattend`}}", 47 | "./floppy/WindowsPowershell.lnk", 48 | "./scripts/fixnetwork.ps1", 49 | "./scripts/disable-screensaver.ps1", 50 | "./scripts/disable-winrm.ps1", 51 | "./scripts/enable-winrm.ps1", 52 | "./scripts/microsoft-updates.bat", 53 | "./scripts/win-updates.ps1" 54 | ], 55 | "guest_additions_mode": "disable", 56 | "guest_os_type": "Windows10_64", 57 | "headless": false, 58 | "iso_checksum": "{{user `iso_checksum`}}", 59 | "iso_url": "{{user `iso_url`}}", 60 | "memory": "{{user `memory`}}", 61 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 62 | "type": "virtualbox-iso", 63 | "winrm_password": "vagrant", 64 | "winrm_timeout": "2h", 65 | "winrm_username": "vagrant" 66 | }, 67 | { 68 | "boot_command": [ 69 | "<enter>" 70 | ], 71 | "boot_wait": "1s", 72 | "communicator": "winrm", 73 | "cpus": 2, 74 | "disk_size": "{{user `disk_size`}}", 75 | "enable_secure_boot": true, 76 | "enable_virtualization_extensions": true, 77 | "generation": 2, 78 | "guest_additions_mode": "disable", 79 | "iso_checksum": "{{user `iso_checksum`}}", 80 | "iso_url": "{{user `iso_url`}}", 81 | "memory": "{{user `memory`}}", 82 | "secondary_iso_images": [ 83 | "./iso/windows_10_insider_unattend.iso" 84 | ], 85 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 86 | "switch_name": "{{user `hyperv_switchname`}}", 87 | "type": "hyperv-iso", 88 | "vm_name": "Windows11Insider", 89 | "winrm_password": "vagrant", 90 | "winrm_timeout": "2h", 91 | "winrm_username": "vagrant" 92 | } 93 | ], 94 | "post-processors": [ 95 | { 96 | "keep_input_artifact": false, 97 | "output": "windows_11_insider_{{.Provider}}.box", 98 | "type": "vagrant", 99 | "vagrantfile_template": "vagrantfile-windows_10.template" 100 | } 101 | ], 102 | "provisioners": [ 103 | { 104 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 105 | "remote_path": "/tmp/script.bat", 106 | "scripts": [ 107 | "./scripts/vm-guest-tools.bat", 108 | "./scripts/enable-rdp.bat", 109 | "./scripts/enable-uac.bat" 110 | ], 111 | "type": "windows-shell" 112 | }, 113 | { 114 | "scripts": [ 115 | "./scripts/debloat-windows.ps1" 116 | ], 117 | "type": "powershell" 118 | }, 119 | { 120 | "type": "windows-restart" 121 | }, 122 | { 123 | "scripts": [ 124 | "./scripts/set-powerplan.ps1", 125 | "./scripts/docker/disable-windows-defender.ps1" 126 | ], 127 | "type": "powershell" 128 | }, 129 | { 130 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 131 | "remote_path": "/tmp/script.bat", 132 | "scripts": [ 133 | "./scripts/pin-powershell.bat", 134 | "./scripts/compile-dotnet-assemblies.bat", 135 | "./scripts/set-winrm-automatic.bat", 136 | "./scripts/compact.bat" 137 | ], 138 | "type": "windows-shell" 139 | } 140 | ], 141 | "variables": { 142 | "autounattend": "./answer_files/11_insider/Autounattend.xml", 143 | "disk_size": "61440", 144 | "memory": "2048", 145 | "iso_checksum": "sha256:659840981fddbbf2a0e3fe12078f0cb77ab6c614bbd0f3713887cca165c28c4c", 146 | "iso_url": "https://software-download.microsoft.com/db/Windows11_InsiderPreview_Client_x64_en-us_22000.iso", 147 | "manually_download_iso_from": "https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewadvanced" 148 | } 149 | } 150 | 151 | -------------------------------------------------------------------------------- /windows_10_insider.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_command": "", 5 | "boot_wait": "6m", 6 | "communicator": "winrm", 7 | "cpus": 2, 8 | "disk_adapter_type": "lsisas1068", 9 | "disk_size": "{{user `disk_size`}}", 10 | "floppy_files": [ 11 | "{{user `autounattend`}}", 12 | "./floppy/WindowsPowershell.lnk", 13 | "./floppy/PinTo10.exe", 14 | "./scripts/fixnetwork.ps1", 15 | "./scripts/disable-screensaver.ps1", 16 | "./scripts/disable-winrm.ps1", 17 | "./scripts/enable-winrm.ps1", 18 | "./scripts/microsoft-updates.bat", 19 | "./scripts/win-updates.ps1" 20 | ], 21 | "guest_os_type": "windows9-64", 22 | "headless": false, 23 | "iso_checksum": "{{user `iso_checksum`}}", 24 | "iso_url": "{{user `iso_url`}}", 25 | "memory": "{{user `memory`}}", 26 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 27 | "type": "vmware-iso", 28 | "version": 14, 29 | "vmx_data": { 30 | "RemoteDisplay.vnc.enabled": "false", 31 | "RemoteDisplay.vnc.port": "5900" 32 | }, 33 | "vmx_remove_ethernet_interfaces": true, 34 | "vnc_port_max": 5980, 35 | "vnc_port_min": 5900, 36 | "winrm_password": "vagrant", 37 | "winrm_timeout": "2h", 38 | "winrm_username": "vagrant" 39 | }, 40 | { 41 | "boot_command": "", 42 | "boot_wait": "6m", 43 | "communicator": "winrm", 44 | "cpus": 2, 45 | "disk_size": "{{user `disk_size`}}", 46 | "floppy_files": [ 47 | "{{user `autounattend`}}", 48 | "./floppy/WindowsPowershell.lnk", 49 | "./floppy/PinTo10.exe", 50 | "./scripts/fixnetwork.ps1", 51 | "./scripts/disable-screensaver.ps1", 52 | "./scripts/disable-winrm.ps1", 53 | "./scripts/enable-winrm.ps1", 54 | "./scripts/microsoft-updates.bat", 55 | "./scripts/win-updates.ps1" 56 | ], 57 | "guest_additions_mode": "disable", 58 | "guest_os_type": "Windows10_64", 59 | "headless": false, 60 | "iso_checksum": "{{user `iso_checksum`}}", 61 | "iso_url": "{{user `iso_url`}}", 62 | "memory": "{{user `memory`}}", 63 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 64 | "type": "virtualbox-iso", 65 | "winrm_password": "vagrant", 66 | "winrm_timeout": "2h", 67 | "winrm_username": "vagrant" 68 | }, 69 | { 70 | "boot_command": [ 71 | "<enter>" 72 | ], 73 | "boot_wait": "1s", 74 | "communicator": "winrm", 75 | "cpus": 2, 76 | "disk_size": "{{user `disk_size`}}", 77 | "enable_secure_boot": true, 78 | "enable_virtualization_extensions": true, 79 | "generation": 2, 80 | "guest_additions_mode": "disable", 81 | "iso_checksum": "{{user `iso_checksum`}}", 82 | "iso_url": "{{user `iso_url`}}", 83 | "memory": "{{user `memory`}}", 84 | "secondary_iso_images": [ 85 | "./iso/windows_10_insider_unattend.iso" 86 | ], 87 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 88 | "switch_name": "{{user `hyperv_switchname`}}", 89 | "type": "hyperv-iso", 90 | "vm_name": "Windows10Insider", 91 | "winrm_password": "vagrant", 92 | "winrm_timeout": "2h", 93 | "winrm_username": "vagrant" 94 | } 95 | ], 96 | "post-processors": [ 97 | { 98 | "keep_input_artifact": false, 99 | "output": "windows_10_insider_{{.Provider}}.box", 100 | "type": "vagrant", 101 | "vagrantfile_template": "vagrantfile-windows_10.template" 102 | } 103 | ], 104 | "provisioners": [ 105 | { 106 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 107 | "remote_path": "/tmp/script.bat", 108 | "scripts": [ 109 | "./scripts/vm-guest-tools.bat", 110 | "./scripts/enable-rdp.bat", 111 | "./scripts/enable-uac.bat" 112 | ], 113 | "type": "windows-shell" 114 | }, 115 | { 116 | "scripts": [ 117 | "./scripts/debloat-windows.ps1" 118 | ], 119 | "type": "powershell" 120 | }, 121 | { 122 | "type": "windows-restart" 123 | }, 124 | { 125 | "scripts": [ 126 | "./scripts/set-powerplan.ps1", 127 | "./scripts/docker/disable-windows-defender.ps1" 128 | ], 129 | "type": "powershell" 130 | }, 131 | { 132 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 133 | "remote_path": "/tmp/script.bat", 134 | "scripts": [ 135 | "./scripts/pin-powershell.bat", 136 | "./scripts/compile-dotnet-assemblies.bat", 137 | "./scripts/set-winrm-automatic.bat", 138 | "./scripts/compact.bat" 139 | ], 140 | "type": "windows-shell" 141 | } 142 | ], 143 | "variables": { 144 | "autounattend": "./answer_files/10_insider/Autounattend.xml", 145 | "disk_size": "61440", 146 | "memory": "2048", 147 | "iso_checksum": "sha256:b4b774e4816dc4b28ea14ea1e7283ac53beb2be216aca3a0cbcceb60a05d32de", 148 | "iso_url": "https://software-download.microsoft.com/pr/Windows10_InsiderPreview_EnterpriseVL_x64_en-us_19035.iso", 149 | "manually_download_iso_from": "https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewadvanced" 150 | } 151 | } 152 | 153 | -------------------------------------------------------------------------------- /windows_2016.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "boot_wait": "0s", 5 | "communicator": "winrm", 6 | "configuration_version": "8.0", 7 | "cpus": 2, 8 | "disk_size": "{{user `disk_size`}}", 9 | "enable_secure_boot": true, 10 | "enable_virtualization_extensions": true, 11 | "floppy_files": [ 12 | "{{user `autounattend`}}", 13 | "./scripts/disable-screensaver.ps1", 14 | "./scripts/disable-winrm.ps1", 15 | "./scripts/enable-winrm.ps1", 16 | "./scripts/microsoft-updates.bat", 17 | "./scripts/unattend.xml", 18 | "./scripts/sysprep.bat", 19 | "./scripts/win-updates.ps1" 20 | ], 21 | "guest_additions_mode": "disable", 22 | "iso_checksum": "{{user `iso_checksum`}}", 23 | "iso_url": "{{user `iso_url`}}", 24 | "memory": "{{user `memory`}}", 25 | "shutdown_command": "a:/sysprep.bat", 26 | "switch_name": "{{user `hyperv_switchname`}}", 27 | "type": "hyperv-iso", 28 | "vm_name": "WindowsServer2016", 29 | "winrm_password": "vagrant", 30 | "winrm_timeout": "{{user `winrm_timeout`}}", 31 | "winrm_username": "vagrant" 32 | }, 33 | { 34 | "boot_wait": "2m", 35 | "communicator": "winrm", 36 | "cpus": 2, 37 | "disk_adapter_type": "lsisas1068", 38 | "disk_size": "{{user `disk_size`}}", 39 | "disk_type_id": "{{user `disk_type_id`}}", 40 | "floppy_files": [ 41 | "{{user `autounattend`}}", 42 | "./scripts/disable-screensaver.ps1", 43 | "./scripts/disable-winrm.ps1", 44 | "./scripts/enable-winrm.ps1", 45 | "./scripts/microsoft-updates.bat", 46 | "./scripts/unattend.xml", 47 | "./scripts/sysprep.bat", 48 | "./scripts/win-updates.ps1" 49 | ], 50 | "guest_os_type": "windows9srv-64", 51 | "headless": "{{user `headless`}}", 52 | "iso_checksum": "{{user `iso_checksum`}}", 53 | "iso_url": "{{user `iso_url`}}", 54 | "memory": "{{user `memory`}}", 55 | "shutdown_command": "a:/sysprep.bat", 56 | "type": "vmware-iso", 57 | "version": 14, 58 | "vm_name": "WindowsServer2016", 59 | "vmx_data": { 60 | "RemoteDisplay.vnc.enabled": "false", 61 | "RemoteDisplay.vnc.port": "5900" 62 | }, 63 | "vmx_remove_ethernet_interfaces": true, 64 | "vnc_port_max": 5980, 65 | "vnc_port_min": 5900, 66 | "winrm_password": "vagrant", 67 | "winrm_timeout": "{{user `winrm_timeout`}}", 68 | "winrm_username": "vagrant" 69 | }, 70 | { 71 | "boot_wait": "2m", 72 | "communicator": "winrm", 73 | "cpus": 2, 74 | "disk_size": "{{user `disk_size`}}", 75 | "floppy_files": [ 76 | "{{user `autounattend`}}", 77 | "./scripts/disable-screensaver.ps1", 78 | "./scripts/disable-winrm.ps1", 79 | "./scripts/enable-winrm.ps1", 80 | "./scripts/microsoft-updates.bat", 81 | "./scripts/win-updates.ps1", 82 | "./scripts/unattend.xml", 83 | "./scripts/sysprep.bat" 84 | ], 85 | "guest_additions_mode": "disable", 86 | "guest_os_type": "Windows2016_64", 87 | "headless": "{{user `headless`}}", 88 | "iso_checksum": "{{user `iso_checksum`}}", 89 | "iso_url": "{{user `iso_url`}}", 90 | "memory": "{{user `memory`}}", 91 | "shutdown_command": "a:/sysprep.bat", 92 | "type": "virtualbox-iso", 93 | "vm_name": "WindowsServer2016", 94 | "winrm_password": "vagrant", 95 | "winrm_timeout": "{{user `winrm_timeout`}}", 96 | "winrm_username": "vagrant" 97 | } 98 | ], 99 | "post-processors": [ 100 | { 101 | "keep_input_artifact": false, 102 | "output": "windows_2016_{{.Provider}}.box", 103 | "type": "vagrant", 104 | "vagrantfile_template": "vagrantfile-windows_2016.template" 105 | } 106 | ], 107 | "provisioners": [ 108 | { 109 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 110 | "scripts": [ 111 | "./scripts/vm-guest-tools.bat", 112 | "./scripts/enable-rdp.bat" 113 | ], 114 | "type": "windows-shell" 115 | }, 116 | { 117 | "scripts": [ 118 | "./scripts/debloat-windows.ps1" 119 | ], 120 | "type": "powershell" 121 | }, 122 | { 123 | "restart_timeout": "{{user `restart_timeout`}}", 124 | "type": "windows-restart" 125 | }, 126 | { 127 | "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"", 128 | "scripts": [ 129 | "./scripts/pin-powershell.bat", 130 | "./scripts/set-winrm-automatic.bat", 131 | "./scripts/uac-enable.bat", 132 | "./scripts/compile-dotnet-assemblies.bat", 133 | "./scripts/dis-updates.bat", 134 | "./scripts/compact.bat" 135 | ], 136 | "type": "windows-shell" 137 | } 138 | ], 139 | "variables": { 140 | "autounattend": "./answer_files/2016/Autounattend.xml", 141 | "disk_size": "61440", 142 | "disk_type_id": "1", 143 | "memory": "2048", 144 | "headless": "false", 145 | "hyperv_switchname": "{{env `hyperv_switchname`}}", 146 | "iso_checksum": "md5:70721288BBCDFE3239D8F8C0FAE55F1F", 147 | "iso_url": "https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO", 148 | "restart_timeout": "5m", 149 | "winrm_timeout": "4h" 150 | } 151 | } 152 | 153 | --------------------------------------------------------------------------------