├── .gitignore
├── Answerfiles
└── 2012r2
│ └── Autounattend.xml
├── Invoke-Packer.ps1
├── LICENSE
├── Logs
└── .gitignore
├── README.md
├── Scripts
├── Archive
│ ├── clean_and_scrub.ps1
│ └── run_ngen.ps1
├── Boxstarter.ps1
├── Install-DevTools.ps1
├── Install-PowerShell5.ps1
├── Install-VirtualboxGuestAdditions.ps1
├── Package.ps1
├── PackerShutdown.bat
├── Set-Sysprep.ps1
├── SetupComplete-2012.cmd
├── Test-Command.ps1
├── UK-postunattend.xml
├── azure-prep.ps1
├── cleanup-full.ps1
└── cleanup.ps1
├── Vagrantfile
├── azure-test
├── create_vm.sh
├── init_azure.sh
├── install_packer.sh
├── rhel.json
├── test_packer.ps1
├── test_packer.sh
├── test_packer_cleanup.sh
├── ubuntu-ask-on-error.json
├── ubuntu-breakpoints.json
└── ubuntu.json
├── azure-ubuntu.json
├── azure-windows-2012r2.json
├── vb-win2012r2-base.json
├── vb-win2012r2-export-vagrant.json
├── vb-win2012r2-powershell5.json
├── vb-win2012r2-wmf5-devtools.json
├── vb-win2016-devtools.json
├── vb-win2016-export-vagrant.json
├── win2012-VagrantBoxDescription.md
├── win2016-VagrantBoxDescription.md
├── win2016-std-dev_VagrantBoxDescription.md
└── windows-template.vagrantfile
/.gitignore:
--------------------------------------------------------------------------------
1 | # Cache objects
2 | packer_cache/
3 |
4 | # For built boxes
5 | *.box
6 |
7 | # VM Output folders
8 | output*
9 |
10 | # Misc
11 | /.vscode
12 | /.vagrant
13 |
--------------------------------------------------------------------------------
/Answerfiles/2012r2/Autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
11 | A:\
12 |
13 |
14 |
15 |
18 |
19 | en-US
20 |
21 | en-US
22 | en-US
23 | en-US
24 | en-US
25 | en-US
26 |
27 |
30 |
31 |
32 |
33 |
34 | Primary
35 | 1
36 | 350
37 |
38 |
39 | 2
40 | Primary
41 | true
42 |
43 |
44 |
45 |
46 | true
47 | NTFS
48 |
49 | 1
50 | 1
51 |
52 |
53 | NTFS
54 |
55 | C
56 | 2
57 | 2
58 |
59 |
60 | 0
61 | true
62 |
63 |
64 |
65 |
66 |
67 |
68 | /IMAGE/NAME
69 | Windows Server 2012 R2 SERVERSTANDARD
70 |
71 |
72 |
73 | 0
74 | 2
75 |
76 |
77 |
78 |
79 |
80 | OnError
81 |
82 | true
83 | Vagrant
84 | Vagrant
85 |
86 |
87 |
88 |
89 |
92 | 1
93 |
94 |
97 | false
98 | false
99 |
100 |
101 |
102 |
105 | en-US
106 | en-US
107 | en-US
108 | en-US
109 |
110 |
113 |
114 | true
115 | true
116 | true
117 | true
118 | true
119 | Home
120 | 1
121 |
122 | UTC
123 |
124 |
125 | vagrant
126 | true
127 |
128 |
129 |
130 |
131 | vagrant
132 | true
133 |
134 | administrators
135 | Vagrant
136 | vagrant
137 | Vagrant User
138 |
139 |
140 |
141 |
142 |
143 | vagrant
144 | true
145 |
146 | true
147 | vagrant
148 |
149 |
150 |
151 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\Boxstarter.ps1
152 | 1
153 |
154 |
155 |
156 |
157 |
158 |
161 | true
162 |
163 |
166 | false
167 | false
168 |
169 |
172 | true
173 |
174 |
175 |
176 |
--------------------------------------------------------------------------------
/Invoke-Packer.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Invokes Packer with support for multiple config files
4 | .DESCRIPTION
5 | Invokes Packer with support for multiple config files
6 | Enables logging and starts a timer
7 | .PARAMETER Path
8 | An array of Packer config paths
9 | .EXAMPLE
10 | .\Invoke-Packer.ps1
11 |
12 | Starts Packer using the default Azure image config, "azure-windows-2012r2.json"
13 | .EXAMPLE
14 | $packerConfigPaths = "vb-win2012r2-base.json", "vb-win2012r2-powershell5.json", "vb-win2012r2-export-vagrant.json"
15 | .\Invoke-Packer.ps1 -Path $packerConfigPaths
16 |
17 | Loops through 3 configs in order shown. Each one building upon the previous.
18 | .NOTES
19 | Author: Adam Rush
20 | Blog: https://adamrushuk.github.io
21 | GitHub: https://github.com/adamrushuk
22 | Twitter: @adamrushuk
23 | #>
24 |
25 | [CmdletBinding()]
26 | param (
27 | [ValidateNotNullOrEmpty()]
28 | [String[]]$Path = "azure-windows-2012r2.json"
29 | )
30 |
31 | # Start timer
32 | $timer = [Diagnostics.Stopwatch]::StartNew()
33 |
34 | # Start packer build for all configs
35 | foreach ($packerConfigPath in $Path) {
36 | # Enable logging
37 | Write-Host "Set logging environment variables..." -ForegroundColor "Yellow"
38 | $timestamp = Get-Date -Format "yyyyMMdd-HHmmss.fff"
39 | $env:PACKER_LOG = 1
40 | $env:PACKER_LOG_PATH = ".\logs\packer-$($timestamp).log"
41 | # Check environment vars
42 | Get-ChildItem env: | Where-Object Name -match "packer"
43 |
44 | # Check syntax
45 | Write-Host "`nChecking syntax for [$packerConfigPath]..." -ForegroundColor "Yellow"
46 | packer validate -syntax-only $packerConfigPath
47 |
48 | # Run Packer
49 | Write-Host "`nRunning Packer using [$packerConfigPath] config file..." -ForegroundColor "Yellow"
50 | packer build -force $packerConfigPath
51 | }
52 |
53 | # Stop timer
54 | $timer.Stop()
55 | Write-Host "`nPacker build(s) complete after [$($timer.Elapsed.Minutes)m$($timer.Elapsed.Seconds)s]`n" -ForegroundColor "Green"
56 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Adam Rush
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Packer-Templates
2 |
3 | Packer Template examples to accompany
4 | [https://adamrushuk.github.io/packer-example-windows/](https://adamrushuk.github.io/packer-example-windows/)
5 |
6 | ## Azure Windows Image
7 |
8 | To create an example Azure Windows image, complete the following steps:
9 |
10 | 1. Set required values in variables section of `azure-windows-2012r2.json`
11 | 1. Run commands in `Scripts\azure-prep.ps1` to:
12 | 1. Login to Azure
13 | 1. Create a Service Principle for Packer
14 | 1. Set Azure environment variables
15 | 1. Create a Resource Group for VM image
16 | 1. Run `.\Invoke-Packer.ps1 -Path "azure-windows-2012r2.json"`
17 |
18 | ## Azure Ubuntu Image
19 |
20 | To create an example Azure Ubuntu image, complete the following steps:
21 |
22 | 1. Set required values in variables section of `azure-ubuntu.json`
23 | 1. Run commands in `Scripts\azure-prep.ps1` to:
24 | 1. Login to Azure
25 | 1. Create a Service Principle for Packer
26 | 1. Set Azure environment variables
27 | 1. Create a Resource Group for VM image
28 | 1. Run `.\Invoke-Packer.ps1 -Path "azure-ubuntu.json"`
29 |
--------------------------------------------------------------------------------
/Scripts/Archive/clean_and_scrub.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "Cleaning updates.."
2 | Stop-Service -Name wuauserv -Force
3 | Remove-Item c:\Windows\SoftwareDistribution\Download\* -Recurse -Force
4 | Start-Service -Name wuauserv
5 |
6 | Write-Host "Cleaning SxS..."
7 | Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
8 |
9 | @(
10 | "$env:localappdata\Nuget",
11 | "$env:localappdata\temp\*",
12 | "$env:windir\logs",
13 | "$env:windir\panther",
14 | "$env:windir\temp\*",
15 | "$env:windir\winsxs\manifestcache"
16 | ) | % {
17 | if (Test-Path $_) {
18 | Write-Host "Removing $_"
19 | try {
20 | Takeown /d Y /R /f $_
21 | Icacls $_ /GRANT:r administrators:F /T /c /q 2>&1 | Out-Null
22 | Remove-Item $_ -Recurse -Force | Out-Null
23 | }
24 | catch { $global:error.RemoveAt(0) }
25 | }
26 | }
27 |
28 | Write-Host "defragging..."
29 | if (Get-Command Optimize-Volume -ErrorAction SilentlyContinue) {
30 | Optimize-Volume -DriveLetter C
31 | }
32 | else {
33 | Defrag.exe c: /H
34 | }
35 |
36 | Write-Host "0ing out empty space..."
37 | $FilePath = "c:\zero.tmp"
38 | $Volume = Get-WmiObject win32_logicaldisk -filter "DeviceID='C:'"
39 | $ArraySize = 64kb
40 | $SpaceToLeave = $Volume.Size * 0.05
41 | $FileSize = $Volume.FreeSpace - $SpacetoLeave
42 | $ZeroArray = new-object byte[]($ArraySize)
43 |
44 | $Stream = [io.File]::OpenWrite($FilePath)
45 | try {
46 | $CurFileSize = 0
47 | while ($CurFileSize -lt $FileSize) {
48 | $Stream.Write($ZeroArray, 0, $ZeroArray.Length)
49 | $CurFileSize += $ZeroArray.Length
50 | }
51 | }
52 | finally {
53 | if ($Stream) {
54 | $Stream.Close()
55 | }
56 | }
57 |
58 | Del $FilePath
59 |
--------------------------------------------------------------------------------
/Scripts/Archive/run_ngen.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "Disabling ngen scheduled task" -ForegroundColor 'Cyan'
2 | $ngen = Get-ScheduledTask '.NET Framework NGEN v4.0.30319', '.NET Framework NGEN v4.0.30319 64'
3 | $ngen | Disable-ScheduledTask
4 |
5 | Write-Host "Running ngen.exe" -ForegroundColor 'Cyan'
6 | . c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe executeQueuedItems
7 |
--------------------------------------------------------------------------------
/Scripts/Boxstarter.ps1:
--------------------------------------------------------------------------------
1 | # Enable AutoLogin which is required for multiple reboots during Windows Update
2 | $WinlogonPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
3 | Remove-ItemProperty -Path $WinlogonPath -Name AutoAdminLogon
4 | Remove-ItemProperty -Path $WinlogonPath -Name DefaultUserName
5 |
6 | # Install Chocolatey and Boxstarter if required
7 | Invoke-Expression ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/mwrock/boxstarter/master/BuildScripts/bootstrapper.ps1'))
8 | Get-Boxstarter -Force
9 |
10 | # Build vagrant credential
11 | $secpasswd = ConvertTo-SecureString "vagrant" -AsPlainText -Force
12 | $cred = New-Object System.Management.Automation.PSCredential ("vagrant", $secpasswd)
13 |
14 | # Run package script
15 | Import-Module (Join-Path -Path $env:ProgramData -ChildPath 'Boxstarter\Boxstarter.Chocolatey\Boxstarter.Chocolatey.psd1')
16 | Install-BoxstarterPackage -PackageName a:\package.ps1 -Credential $cred
17 |
--------------------------------------------------------------------------------
/Scripts/Install-DevTools.ps1:
--------------------------------------------------------------------------------
1 | # Install chocolatey
2 | if (-not [bool](Get-Command 'choco' -ErrorAction 'SilentlyContinue')) {
3 | Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
4 | }
5 |
6 | # Install Dev Tools
7 | Write-Host "`nSTARTED: Installing Dev Tools..." -ForegroundColor 'Yellow'
8 | choco install sysinternals treesizefree cmdermini notepadplusplus.install putty mremoteng git.install poshgit visualstudiocode 7zip.install chefdk lockhunter -y
9 |
10 | Write-Host 'Installing VS Code extensions...' -ForegroundColor 'Yellow'
11 | $codeCmdPath = Join-Path -Path $env:ProgramFiles -ChildPath 'Microsoft VS Code\bin\code.cmd'
12 | $extensions = @(
13 | 'aaron-bond.better-comments'
14 | 'bierner.markdown-preview-github-styles'
15 | 'coenraads.bracket-pair-colorizer-2'
16 | 'davidanson.vscode-markdownlint'
17 | 'DotJoshJohnson.xml'
18 | 'drmattsm.replace-smart-characters'
19 | 'eamodio.gitlens'
20 | 'esbenp.prettier-vscode'
21 | 'grapecity.gc-excelviewer'
22 | 'marcostazi.vs-code-vagrantfile'
23 | 'ms-vscode.PowerShell'
24 | 'robertohuertasm.vscode-icons'
25 | 'sidneys1.gitconfig'
26 | 'stkb.rewrap'
27 | 'wengerk.highlight-bad-chars'
28 | 'yzhang.markdown-all-in-one'
29 | )
30 |
31 | foreach ($extension in $extensions) {
32 | Write-Host "`nInstalling extension $extension..." -ForegroundColor 'Yellow'
33 | & $codeCmdPath --install-extension $extension
34 | }
35 |
36 | Write-Host "`nFINISHED: Installing Dev Tools." -ForegroundColor 'Green'
37 |
--------------------------------------------------------------------------------
/Scripts/Install-PowerShell5.ps1:
--------------------------------------------------------------------------------
1 | # Install PowerShell 5 if not installed
2 | if ($PSVersionTable.PSVersion.Major -lt 5) {
3 | Write-Host "Installing PowerShell 5" -ForegroundColor Green
4 | choco install powershell -y
5 | }
6 | else {
7 | Write-Host "PowerShell 5 or above already installed. Skipping..." -ForegroundColor Red
8 | }
--------------------------------------------------------------------------------
/Scripts/Install-VirtualboxGuestAdditions.ps1:
--------------------------------------------------------------------------------
1 | # Install Virtualbox Guest Additions
2 | if (Test-Path "e:/VBoxWindowsAdditions.exe") {
3 | Write-Host "Installing Guest Additions"
4 | Get-ChildItem E:\cert\ -Filter vbox*.cer | ForEach-Object {
5 | E:\cert\VBoxCertUtil.exe add-trusted-publisher $_.FullName --root $_.FullName
6 | }
7 |
8 | mkdir "C:\Windows\Temp\virtualbox" -ErrorAction SilentlyContinue
9 | Start-Process -FilePath "e:/VBoxWindowsAdditions.exe" -ArgumentList "/S" -WorkingDirectory "C:\Windows\Temp\virtualbox" -Wait
10 |
11 | Remove-Item C:\Windows\Temp\virtualbox -Recurse -Force
12 | }
13 |
--------------------------------------------------------------------------------
/Scripts/Package.ps1:
--------------------------------------------------------------------------------
1 | $ErrorActionPreference = "Stop"
2 |
3 | . a:\Test-Command.ps1
4 |
5 | Enable-RemoteDesktop
6 | netsh advfirewall firewall add rule name="Remote Desktop" dir=in localport=3389 protocol=TCP action=allow
7 |
8 | Update-ExecutionPolicy -Policy Unrestricted
9 |
10 | <# Uncomment to remove WindowsFeature source files - I leave commented out for offline development
11 | if (Test-Command -cmdname 'Uninstall-WindowsFeature') {
12 | Write-BoxstarterMessage "Removing unused features..."
13 | Remove-WindowsFeature -Name 'Powershell-ISE'
14 | Get-WindowsFeature |
15 | ? { $_.InstallState -eq 'Available' } |
16 | Uninstall-WindowsFeature -Remove
17 | }
18 | #>
19 |
20 | Install-WindowsUpdate -AcceptEula
21 |
22 | Write-BoxstarterMessage "Removing page file"
23 | $pageFileMemoryKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
24 | Set-ItemProperty -Path $pageFileMemoryKey -Name PagingFiles -Value ""
25 |
26 | if (Test-PendingReboot) { Invoke-Reboot }
27 |
28 | # Enable WinRM
29 | Write-BoxstarterMessage "Setting up winrm"
30 | netsh advfirewall firewall add rule name="WinRM-HTTP" dir=in localport=5985 protocol=TCP action=allow
31 |
32 | $enableArgs = @{Force = $true}
33 | try {
34 | $command = Get-Command Enable-PSRemoting
35 | if ($command.Parameters.Keys -contains "skipnetworkprofilecheck") {
36 | $enableArgs.skipnetworkprofilecheck = $true
37 | }
38 | }
39 | catch {
40 | $global:error.RemoveAt(0)
41 | }
42 | Enable-PSRemoting @enableArgs
43 | Enable-WSManCredSSP -Force -Role Server
44 | winrm set winrm/config/client/auth '@{Basic="true"}'
45 | winrm set winrm/config/service/auth '@{Basic="true"}'
46 | winrm set winrm/config/service '@{AllowUnencrypted="true"}'
47 | Write-BoxstarterMessage "winrm setup complete"
48 |
--------------------------------------------------------------------------------
/Scripts/PackerShutdown.bat:
--------------------------------------------------------------------------------
1 | :: Disable WinRM so Vagrant doesnt trip over on first reboot post sysprep
2 |
3 | :: Uncomment below if you dont need basic and unencrypted WinRM, as more secure
4 | :: call winrm set winrm/config/service/auth @{Basic="false"}
5 | :: call winrm set winrm/config/service @{AllowUnencrypted="false"}
6 |
7 | :: Disable firewall rule
8 | netsh advfirewall firewall set rule name="WinRM-HTTP" new action=block
9 |
10 |
11 | :: Sysprep and shutdown
12 | C:/windows/system32/sysprep/sysprep.exe /generalize /oobe /unattend:C:/Windows/Panther/Unattend/unattend.xml /quiet /shutdown
13 |
--------------------------------------------------------------------------------
/Scripts/Set-Sysprep.ps1:
--------------------------------------------------------------------------------
1 | # Copy files to correct locations in prior to sysprep
2 | Write-Host "Copying UK auto unattend file" -ForegroundColor Green
3 | New-Item -Path 'C:\Windows\Panther\Unattend' -ItemType 'Directory' -Force
4 | Copy-Item -Path 'a:\UK-postunattend.xml' -Destination 'C:\Windows\Panther\Unattend\unattend.xml'
5 |
6 | Write-Host "Copy SetupComplete file for execution on first boot" -ForegroundColor Green
7 | New-Item -Path 'C:\Windows\setup\scripts' -ItemType 'Directory' -Force
8 | Copy-Item -Path 'a:\SetupComplete-2012.cmd' -Destination 'C:\Windows\setup\scripts\SetupComplete.cmd' -Force
9 |
10 |
--------------------------------------------------------------------------------
/Scripts/SetupComplete-2012.cmd:
--------------------------------------------------------------------------------
1 | REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\WSMAN\Service /v allow_unencrypted /t REG_DWORD /d 1 /f
2 | REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\WSMAN\Service /v auth_basic /t REG_DWORD /d 1 /f
3 | REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\WSMAN\Client /v auth_basic /t REG_DWORD /d 1 /f
4 |
5 | netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
6 | netsh advfirewall firewall set rule name="WinRM-HTTP" new action=allow
7 |
8 | wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
9 |
--------------------------------------------------------------------------------
/Scripts/Test-Command.ps1:
--------------------------------------------------------------------------------
1 | function Test-Command($cmdname)
2 | {
3 | try {
4 | Get-Command -Name $cmdname
5 | return $true
6 | }
7 | catch {
8 | $global:error.RemoveAt(0)
9 | return $false
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Scripts/UK-postunattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 | 1
9 |
10 |
11 |
12 |
17 |
20 | 0809:00000809
21 | en-GB
22 | en-GB
23 | en-US
24 | en-GB
25 |
26 |
29 |
30 | true
31 | true
32 | true
33 | true
34 | Work
35 | 1
36 | true
37 | true
38 |
39 |
40 |
41 | vagrant
42 | true
43 |
44 |
45 |
46 |
47 | vagrant
48 | true
49 |
50 | administrators
51 | Vagrant
52 | vagrant
53 | Vagrant User
54 |
55 |
56 |
57 | true
58 | GMT Standard Time
59 |
60 | 2
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/Scripts/azure-prep.ps1:
--------------------------------------------------------------------------------
1 | # Login
2 | az login
3 |
4 | # List my current Service Principles
5 | az ad sp list --show-mine --query '[].{"id":"appId", "tenant":"appOwnerTenantId"}'
6 |
7 | # Create new Service Principle for Packer
8 | az ad sp create-for-rbac --name packer --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
9 | az account show --query "{ subscription_id: id }"
10 |
11 | # Ensure Azure environment variables exist, using the values from previous commands
12 | $env:ARM_TENANT_ID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
13 | $env:ARM_SUBSCRIPTION_ID = "ppppppp-pppp-pppp-pppp-ppppppppppp"
14 | $env:ARM_CLIENT_ID = "zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"
15 | $env:ARM_CLIENT_SECRET = "yyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyy"
16 |
17 | # Create Resource Group (make sure values match packer config)
18 | az group create -n packertest-rg -l uksouth
19 |
--------------------------------------------------------------------------------
/Scripts/cleanup-full.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "Cleaning updates.." -ForegroundColor 'Cyan'
2 | Stop-Service -Name wuauserv -Force
3 | Remove-Item c:\Windows\SoftwareDistribution\Download\* -Recurse -Force
4 | Start-Service -Name wuauserv
5 |
6 | Write-Host "Cleaning SxS..." -ForegroundColor 'Cyan'
7 | Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
8 |
9 | @(
10 | "$env:localappdata\Nuget",
11 | "$env:localappdata\temp\*",
12 | "$env:windir\logs",
13 | "$env:windir\panther",
14 | "$env:windir\temp\*",
15 | "$env:windir\winsxs\manifestcache"
16 | ) | ForEach-Object {
17 | if (Test-Path $_) {
18 | Write-Host "Removing $_"
19 | try {
20 | Takeown /d Y /R /f $_
21 | Icacls $_ /GRANT:r administrators:F /T /c /q 2>&1 | Out-Null
22 | Remove-Item $_ -Recurse -Force | Out-Null
23 | }
24 | catch { $global:error.RemoveAt(0) }
25 | }
26 | }
27 |
28 | Write-Host "Disabling ngen scheduled task" -ForegroundColor 'Cyan'
29 | $ngen = Get-ScheduledTask '.NET Framework NGEN v4.0.30319', '.NET Framework NGEN v4.0.30319 64'
30 | $ngen | Disable-ScheduledTask
31 |
32 | Write-Host "Running ngen.exe" -ForegroundColor 'Cyan'
33 | . c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe executeQueuedItems
34 |
35 | Write-Host "defragging..." -ForegroundColor 'Cyan'
36 | if (Get-Command Optimize-Volume -ErrorAction SilentlyContinue) {
37 | Optimize-Volume -DriveLetter C
38 | }
39 | else {
40 | Defrag.exe c: /H
41 | }
42 |
43 | Write-Host "0ing out empty space..." -ForegroundColor 'Cyan'
44 | $FilePath = "c:\zero.tmp"
45 | $Volume = Get-WmiObject win32_logicaldisk -filter "DeviceID='C:'"
46 | $ArraySize = 64kb
47 | $SpaceToLeave = $Volume.Size * 0.05
48 | $FileSize = $Volume.FreeSpace - $SpacetoLeave
49 | $ZeroArray = new-object byte[]($ArraySize)
50 |
51 | $Stream = [io.File]::OpenWrite($FilePath)
52 | try {
53 | $CurFileSize = 0
54 | while ($CurFileSize -lt $FileSize) {
55 | $Stream.Write($ZeroArray, 0, $ZeroArray.Length)
56 | $CurFileSize += $ZeroArray.Length
57 | }
58 | }
59 | finally {
60 | if ($Stream) {
61 | $Stream.Close()
62 | }
63 | }
64 |
65 | Remove-Item $FilePath
66 |
--------------------------------------------------------------------------------
/Scripts/cleanup.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "Cleaning updates.." -ForegroundColor 'Cyan'
2 | Stop-Service -Name wuauserv -Force
3 | Remove-Item c:\Windows\SoftwareDistribution\Download\* -Recurse -Force
4 | Start-Service -Name wuauserv
5 |
6 | # Write-Host "Cleaning SxS..." -ForegroundColor 'Cyan'
7 | # Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
8 |
9 | @(
10 | "$env:localappdata\Nuget",
11 | "$env:localappdata\temp\*",
12 | #"$env:windir\logs",
13 | "$env:windir\panther",
14 | "$env:windir\temp\*",
15 | "$env:windir\winsxs\manifestcache"
16 | ) | ForEach-Object {
17 | if (Test-Path $_) {
18 | Write-Host "Removing $_"
19 | try {
20 | Takeown /d Y /R /f $_
21 | Icacls $_ /GRANT:r administrators:F /T /c /q 2>&1 | Out-Null
22 | Remove-Item $_ -Recurse -Force | Out-Null
23 | }
24 | catch { $global:error.RemoveAt(0) }
25 | }
26 | }
27 |
28 | # Write-Host "Disabling ngen scheduled task" -ForegroundColor 'Cyan'
29 | # $ngen = Get-ScheduledTask '.NET Framework NGEN v4.0.30319', '.NET Framework NGEN v4.0.30319 64'
30 | # $ngen | Disable-ScheduledTask
31 |
32 | # Write-Host "Running ngen.exe" -ForegroundColor 'Cyan'
33 | # . c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe executeQueuedItems
34 |
35 | Write-Host "defragging..." -ForegroundColor 'Cyan'
36 | if (Get-Command Optimize-Volume -ErrorAction SilentlyContinue) {
37 | Optimize-Volume -DriveLetter C
38 | }
39 | else {
40 | Defrag.exe c: /H
41 | }
42 |
43 | Write-Host "0ing out empty space..." -ForegroundColor 'Cyan'
44 | $FilePath = "c:\zero.tmp"
45 | $Volume = Get-WmiObject win32_logicaldisk -filter "DeviceID='C:'"
46 | $ArraySize = 64kb
47 | $SpaceToLeave = $Volume.Size * 0.05
48 | $FileSize = $Volume.FreeSpace - $SpacetoLeave
49 | $ZeroArray = new-object byte[]($ArraySize)
50 |
51 | $Stream = [io.File]::OpenWrite($FilePath)
52 | try {
53 | $CurFileSize = 0
54 | while ($CurFileSize -lt $FileSize) {
55 | $Stream.Write($ZeroArray, 0, $ZeroArray.Length)
56 | $CurFileSize += $ZeroArray.Length
57 | }
58 | }
59 | finally {
60 | if ($Stream) {
61 | $Stream.Close()
62 | }
63 | }
64 |
65 | Remove-Item $FilePath
66 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | # Plugin checker by DevNIX: https://github.com/DevNIX/Vagrant-dependency-manager
2 | # vagrant-reload is required to solve issues with rebooting Windows machines after domain join
3 | #require File.dirname(__FILE__)+'./Vagrant/dependency_manager'
4 | #check_plugins ['vagrant-reload']
5 |
6 | # Variables
7 | # Domain / Network
8 | net_prefix = '192.168.56'
9 | base_box = 'win2016-dev'
10 | #box_version = '0.2.1'
11 | dc01_ip = "#{net_prefix}.2"
12 | sp01_ip = "#{net_prefix}.3"
13 | domain_controller = 'dc01'
14 | domain_name = 'lab.local'
15 | netbios_name = 'LAB'
16 | safemode_admin_pw = 'Passw0rds123'
17 | domain_admins = 'vagrant'
18 | opsp_trigram_sitecode = 'TST'
19 | # Dependencies
20 | psdepend_config_path = 'C:\vagrant\Vagrant\provision\all\OS.requirements.psd1'
21 | source = 'C:\\vagrant\\Vagrant\\provision\\Source' # Must be available to VM
22 | dest_source = 'C:\\Source'
23 |
24 | Vagrant.configure('2') do |config|
25 | # Box
26 | config.vm.box = base_box
27 | #config.vm.box_version = box_version
28 |
29 | # VirtualBox global box settings
30 | config.vm.provider 'virtualbox' do |vb|
31 | vb.linked_clone = true
32 | vb.gui = true
33 | end
34 |
35 | # WinRM plaintext is required for the domain to build properly (This should NOT be used in production)
36 | config.vm.communicator = 'winrm'
37 | config.winrm.transport = :plaintext
38 | config.winrm.basic_auth_only = true
39 |
40 | # Increase timeout in case VMs joining the domain take a while to boot
41 | config.vm.boot_timeout = 600
42 |
43 | # DC
44 | config.vm.define 'dc01' do |dc01|
45 | dc01.vm.provider 'virtualbox' do |vb|
46 | vb.cpus = '2'
47 | vb.memory = '2048'
48 | end
49 |
50 | # Hostname and networking
51 | dc01.vm.hostname = 'dc01'
52 | dc01.vm.network 'private_network', ip: dc01_ip
53 | dc01.vm.network 'forwarded_port', guest: 3389, host: 33389, auto_correct: true
54 |
55 | # Build domain
56 | #dc01.vm.provision 'shell', path: 'Vagrant/provision/dc01/install-AD.ps1', args: [dc01_ip]
57 | #dc01.vm.provision 'shell', path: 'Vagrant/provision/dc01/install-forest.ps1', args: [domain_name, netbios_name, safemode_admin_pw]
58 | #dc01.vm.provision 'shell', path: 'Vagrant/provision/dc01/AD-Groups-Users.ps1', args: [domain_admins, opsp_trigram_sitecode, domain_name, domain_controller], keep_color: true
59 | end
60 |
61 | # SQL and SharePoint
62 | config.vm.define 'sp01' do |sp01|
63 | sp01.vm.provider 'virtualbox' do |vb|
64 | vb.cpus = '3'
65 | vb.memory = '6144'
66 | end
67 |
68 | sp01.vm.hostname = 'sp01'
69 | sp01.vm.network 'private_network', ip: sp01_ip
70 | sp01.vm.network 'forwarded_port', guest: 3389, host: 33390, auto_correct: true
71 | #sp01.vm.provision 'shell', path: 'Vagrant/provision/all/join-domain.ps1', args: [domain_name, 'vagrant', 'vagrant', dc01_ip]
72 | ## We need to reload using the vagrant-reload plugin because a restart seems to break winrm comms
73 | #sp01.vm.provision :reload
74 | #sp01.vm.provision 'shell', path: 'Vagrant/provision/all/source-copy.ps1', args: [source, dest_source]
75 | end
76 | end
77 |
--------------------------------------------------------------------------------
/azure-test/create_vm.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # create vm from new image
3 |
4 | # vars
5 | resource_group_name="packertest-rg"
6 | vm1_name="linux01"
7 | vm2_name="linux02"
8 | image_name="UbuntuImage"
9 | public_ssh_key_path="$HOME/.ssh/id_rsa.pub"
10 |
11 | # create vm
12 | # https://docs.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest#az-vm-create
13 | az vm create \
14 | --resource-group $resource_group_name \
15 | --name $vm1_name \
16 | --image $image_name \
17 | --admin-username sysadmin \
18 | --ssh-key-values $public_ssh_key_path \
19 | --no-wait
20 |
21 | az vm create \
22 | --resource-group $resource_group_name \
23 | --name $vm2_name \
24 | --image $image_name \
25 | --admin-username sysadmin \
26 | --ssh-key-values $public_ssh_key_path
27 |
28 | # open port
29 | az vm open-port \
30 | --resource-group $resource_group_name \
31 | --name $vm1_name \
32 | --port 80
33 |
34 | # get public IP address
35 | vm1_ip=$(az vm list-ip-addresses --resource-group $resource_group_name --name $vm1_name --query [].virtualMachine.network.publicIpAddresses[].ipAddress -o tsv)
36 | vm2_ip=$(az vm list-ip-addresses --resource-group $resource_group_name --name $vm2_name --query [].virtualMachine.network.publicIpAddresses[].ipAddress -o tsv)
37 |
38 | # test web servers
39 | curl -v $vm1_ip
40 | curl -v $vm2_ip
41 |
42 |
43 | # test direct connectivity using netcat
44 | # connect to vm1
45 | ssh sysadmin@$vm1_ip
46 |
47 | # start netcat listener on port 80
48 | sudo nc -l 80
49 |
50 | # from a second console session, send test message from vm2 to vm1
51 | ssh sysadmin@$vm2_ip echo "Connectivity works between [$vm1_ip] and [$vm2_ip]" | nc $vm1_ip 80
52 |
--------------------------------------------------------------------------------
/azure-test/init_azure.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # initialise azure for packer usage
3 |
4 | # vars
5 | resource_group_name="packertest-rg"
6 | location_name="uksouth"
7 |
8 | # OPTION 1: use existing Service Principle
9 | source ~/.azhpacker.sh
10 | printenv | grep ARM
11 |
12 |
13 |
14 | #region OPTION 2: create new service principle for packer
15 | # login
16 | az login
17 |
18 | # create SP
19 | sp_json=$(az ad sp create-for-rbac --name packer --query "{ client_id: appId, client_secret: password, tenant_id: tenant }")
20 |
21 | # export azure environment variables
22 | export ARM_TENANT_ID=$(echo "$sp_json" | jq -r ".tenant_id")
23 | export ARM_SUBSCRIPTION_ID=$(az account show --query "{ subscription_id: id }" | jq -r ".subscription_id")
24 | export ARM_CLIENT_ID=$(echo "$sp_json" | jq -r ".client_id")
25 | export ARM_CLIENT_SECRET=$(echo "$sp_json" | jq -r ".client_secret")
26 | printenv | grep ARM
27 | #endregion OPTION 2
28 |
29 |
30 |
31 | # create resource group (make sure values match packer config)
32 | az group create -n $resource_group_name -l $location_name
33 |
--------------------------------------------------------------------------------
/azure-test/install_packer.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # install packer
4 |
5 | # vars
6 | PACKER_VERSION="1.6.0"
7 | PACKER_INSTALL_PATH="/usr/local/bin"
8 |
9 | # check
10 | command -v packer
11 | ll $PACKER_INSTALL_PATH
12 |
13 | # download
14 | wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip
15 |
16 | # unzip
17 | unzip packer_${PACKER_VERSION}_linux_amd64.zip
18 |
19 | # install
20 | sudo install packer $PACKER_INSTALL_PATH
21 |
22 | # check
23 | command -v packer
24 | packer version
25 |
26 | # cleanup
27 | rm -f packer_${PACKER_VERSION}_linux_amd64.zip
28 | rm -f packer
29 |
--------------------------------------------------------------------------------
/azure-test/rhel.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "location": "uksouth",
4 | "resource_group_name": "packertest-rg",
5 | "image_name": "Rhel7Image",
6 | "vm_size": "Standard_DS2_v2",
7 |
8 | "tenant_id": "{{env `ARM_TENANT_ID`}}",
9 | "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
10 | "client_id": "{{env `ARM_CLIENT_ID`}}",
11 | "client_secret": "{{env `ARM_CLIENT_SECRET`}}"
12 | },
13 | "builders": [{
14 | "type": "azure-arm",
15 |
16 | "tenant_id": "{{user `tenant_id`}}",
17 | "subscription_id": "{{user `subscription_id`}}",
18 | "client_id": "{{user `client_id`}}",
19 | "client_secret": "{{user `client_secret`}}",
20 |
21 | "managed_image_resource_group_name": "{{user `resource_group_name`}}",
22 | "managed_image_name": "{{user `image_name`}}",
23 |
24 | "os_type": "Linux",
25 | "image_publisher": "RedHat",
26 | "image_offer": "RHEL",
27 | "image_sku": "7-RAW-CI",
28 |
29 | "azure_tags": {
30 | "environment": "dev",
31 | "engineer": "Adam Rush"
32 | },
33 |
34 | "location": "{{user `location`}}",
35 | "vm_size": "{{user `vm_size`}}",
36 |
37 | "ssh_username": "sysadmin",
38 | "ssh_private_key_file": "~/.ssh/id_rsa"
39 | }],
40 | "provisioners": [
41 | {
42 | "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
43 | "inline": [
44 | "echo 'sleeping for 2m'",
45 | "sleep 2m"
46 | ],
47 | "inline_shebang": "/bin/sh -x",
48 | "type": "shell"
49 | },
50 | {
51 | "type": "breakpoint",
52 | "note": "pause to test ssh connection"
53 | },
54 | {
55 | "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
56 | "inline": [
57 | "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
58 | ],
59 | "inline_shebang": "/bin/sh -x",
60 | "type": "shell"
61 | }
62 | ]
63 | }
64 |
--------------------------------------------------------------------------------
/azure-test/test_packer.ps1:
--------------------------------------------------------------------------------
1 | # Testing Packer breakpoints and ask on error
2 |
3 | # vars
4 | $packerConfigPath = "./ubuntu-ask-on-error.json"
5 | $packerBinaryPath = "packer.exe"
6 |
7 | # enter test folder
8 | Set-Location azure-test
9 |
10 | # show packer version
11 | & $packerBinaryPath version
12 |
13 | # Enable logging
14 | Write-Host "Set logging environment variables..." -ForegroundColor "Yellow"
15 | $timestamp = Get-Date -Format "yyyyMMdd-HHmmss.fff"
16 | $env:PACKER_LOG = 1
17 | $env:PACKER_LOG_PATH = "packer-$($timestamp).log"
18 | # Check environment vars
19 | Get-ChildItem env: | Where-Object Name -match "packer"
20 |
21 | # Check syntax
22 | Write-Host "`nChecking syntax for [$packerConfigPath]..." -ForegroundColor "Yellow"
23 | packer.exe validate -syntax-only $packerConfigPath
24 |
25 | # Run Packer
26 | Write-Host "`nRunning Packer using [$packerConfigPath] config file..." -ForegroundColor "Yellow"
27 | packer.exe build -on-error=ask $packerConfigPath
28 |
--------------------------------------------------------------------------------
/azure-test/test_packer.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Testing Packer with SSH override options
3 | # logged issue: https://github.com/hashicorp/packer/issues/9130
4 | # confirmed fix is in upcoming version (v1.5.6):
5 | # https://app.circleci.com/pipelines/github/hashicorp/packer/4726/workflows/24332680-9fe6-445d-ac2e-14c0bf75ab1f/jobs/47286/artifacts
6 |
7 | # vars
8 | packer_config_path="./ubuntu-ask-on-error.json"
9 | # use "packer" for default binary
10 | # using fixed version (will be v1.5.6)
11 | # packer_binary_path="./packer_linux_amd64"
12 | packer_binary_path="packer"
13 |
14 | # enter test folder
15 | cd azure-test
16 |
17 | # show packer version and existing ssh keys
18 | $packer_binary_path version
19 | ll ~/.ssh/
20 | cat ~/.ssh/id_rsa.pub
21 |
22 | # enable logging
23 | echo "Set logging environment variables..."
24 | timestamp=$(date +"%Y%m%d-%H%M")
25 | export PACKER_LOG=1
26 | export PACKER_LOG_PATH="./packer_$timestamp.log"
27 |
28 | # check environment vars
29 | printenv | grep PACKER
30 |
31 | # check syntax
32 | echo "Checking syntax..."
33 | $packer_binary_path validate -syntax-only $packer_config_path
34 |
35 | # Run Packer
36 | # https://www.packer.io/docs/commands/build.html#on-error-cleanup
37 | echo "Running Packer with -on-error=ask..."
38 | $packer_binary_path build -on-error=ask -color=false $packer_config_path
39 |
40 |
41 | # Troubleshoot
42 | # should be able to connect when allowing use of custom "sysadmin" ssh_username
43 | ssh sysadmin@
44 |
45 | ## if required, reset public ssh key in portal for new user (eg: "adamr"), then connect to public ip
46 | ssh adamr@
47 |
48 | # check current users
49 | ll /home
50 | cat /etc/passwd | sort
51 |
52 | # show user public keys
53 | ll /home/*/.ssh/authorized_keys
54 | cat /home/*/.ssh/authorized_keys
55 |
--------------------------------------------------------------------------------
/azure-test/test_packer_cleanup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Testing Packer cleanup issue
4 | # logged issue: https://github.com/hashicorp/packer/issues/9482
5 |
6 | # vars
7 | packer_config_path="./ubuntu.json"
8 | packer_binary_path="packer"
9 |
10 | # enter test folder
11 | cd azure-test
12 |
13 | # info
14 | $packer_binary_path version
15 |
16 | # enable logging
17 | echo "Set logging environment variables..."
18 | timestamp=$(date +"%Y%m%d-%H%M")
19 | export PACKER_LOG=1
20 | export PACKER_LOG_PATH="./packer_$timestamp.log"
21 |
22 | # check environment vars
23 | printenv | grep PACKER
24 |
25 | # check syntax
26 | echo "Checking syntax..."
27 | $packer_binary_path validate -syntax-only $packer_config_path
28 |
29 | # Run Packer
30 | # https://www.packer.io/docs/commands/build.html#on-error-cleanup
31 | echo "Running Packer with -on-error=ask..."
32 | $packer_binary_path build -on-error=ask -color=false $packer_config_path
33 |
--------------------------------------------------------------------------------
/azure-test/ubuntu-ask-on-error.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "location": "uksouth",
4 | "resource_group_name": "packertest-rg",
5 | "image_name": "UbuntuImage",
6 | "vm_size": "Standard_DS2_v2",
7 |
8 | "tenant_id": "{{env `ARM_TENANT_ID`}}",
9 | "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
10 | "client_id": "{{env `ARM_CLIENT_ID`}}",
11 | "client_secret": "{{env `ARM_CLIENT_SECRET`}}"
12 | },
13 | "builders": [{
14 | "type": "azure-arm",
15 |
16 | "tenant_id": "{{user `tenant_id`}}",
17 | "subscription_id": "{{user `subscription_id`}}",
18 | "client_id": "{{user `client_id`}}",
19 | "client_secret": "{{user `client_secret`}}",
20 |
21 | "managed_image_resource_group_name": "{{user `resource_group_name`}}",
22 | "managed_image_name": "{{user `image_name`}}",
23 |
24 | "os_type": "Linux",
25 | "image_publisher": "Canonical",
26 | "image_offer": "UbuntuServer",
27 | "image_sku": "18.04-LTS",
28 |
29 | "azure_tags": {
30 | "environment": "dev",
31 | "engineer": "Adam Rush"
32 | },
33 |
34 | "location": "{{user `location`}}",
35 | "vm_size": "{{user `vm_size`}}"
36 | }],
37 | "provisioners": [
38 | {
39 | "type": "shell",
40 | "inline": [
41 | "echo 'This Shell provisioner step is: Pre error'"
42 | ]
43 | },
44 | {
45 | "type": "shell",
46 | "inline": [
47 | "echo Triggering error to make Packer stop [-on-error=ask]...",
48 | "exit 1"
49 | ]
50 | },
51 | {
52 | "type": "shell",
53 | "inline": [
54 | "echo 'This Shell provisioner step is: Post error'"
55 | ]
56 | },
57 | {
58 | "type": "shell",
59 | "inline_shebang": "/bin/sh -x",
60 | "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
61 | "inline": [
62 | "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
63 | ]
64 | }
65 | ]
66 | }
67 |
--------------------------------------------------------------------------------
/azure-test/ubuntu-breakpoints.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "location": "uksouth",
4 | "resource_group_name": "packertest-rg",
5 | "image_name": "UbuntuImage",
6 | "vm_size": "Standard_DS2_v2",
7 |
8 | "tenant_id": "{{env `ARM_TENANT_ID`}}",
9 | "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
10 | "client_id": "{{env `ARM_CLIENT_ID`}}",
11 | "client_secret": "{{env `ARM_CLIENT_SECRET`}}"
12 | },
13 | "builders": [{
14 | "type": "azure-arm",
15 |
16 | "tenant_id": "{{user `tenant_id`}}",
17 | "subscription_id": "{{user `subscription_id`}}",
18 | "client_id": "{{user `client_id`}}",
19 | "client_secret": "{{user `client_secret`}}",
20 |
21 | "managed_image_resource_group_name": "{{user `resource_group_name`}}",
22 | "managed_image_name": "{{user `image_name`}}",
23 |
24 | "os_type": "Linux",
25 | "image_publisher": "Canonical",
26 | "image_offer": "UbuntuServer",
27 | "image_sku": "18.04-LTS",
28 |
29 | "azure_tags": {
30 | "environment": "dev",
31 | "engineer": "Adam Rush"
32 | },
33 |
34 | "location": "{{user `location`}}",
35 | "vm_size": "{{user `vm_size`}}",
36 |
37 | "ssh_username": "sysadmin",
38 | "ssh_private_key_file": "~/.ssh/id_rsa"
39 | }],
40 | "provisioners": [
41 | {
42 | "type": "shell",
43 | "inline": [
44 | "echo 'Pre breakpoint'"
45 | ]
46 | },
47 | {
48 | "type": "breakpoint",
49 | "note": "Packer should pause here..."
50 | },
51 | {
52 | "type": "shell",
53 | "inline": [
54 | "echo 'Post breakpoint'"
55 | ]
56 | },
57 | {
58 | "type": "shell",
59 | "inline_shebang": "/bin/sh -x",
60 | "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
61 | "inline": [
62 | "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
63 | ]
64 | }
65 | ]
66 | }
67 |
--------------------------------------------------------------------------------
/azure-test/ubuntu.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "location": "uksouth",
4 | "resource_group_name": "packertest-rg",
5 | "image_name": "UbuntuImage",
6 | "vm_size": "Standard_DS2_v2",
7 |
8 | "tenant_id": "{{env `ARM_TENANT_ID`}}",
9 | "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
10 | "client_id": "{{env `ARM_CLIENT_ID`}}",
11 | "client_secret": "{{env `ARM_CLIENT_SECRET`}}"
12 | },
13 | "builders": [{
14 | "type": "azure-arm",
15 |
16 | "tenant_id": "{{user `tenant_id`}}",
17 | "subscription_id": "{{user `subscription_id`}}",
18 | "client_id": "{{user `client_id`}}",
19 | "client_secret": "{{user `client_secret`}}",
20 |
21 | "managed_image_resource_group_name": "{{user `resource_group_name`}}",
22 | "managed_image_name": "{{user `image_name`}}",
23 |
24 | "os_type": "Linux",
25 | "image_publisher": "Canonical",
26 | "image_offer": "UbuntuServer",
27 | "image_sku": "18.04-LTS",
28 |
29 | "azure_tags": {
30 | "environment": "dev",
31 | "engineer": "Adam Rush"
32 | },
33 |
34 | "location": "{{user `location`}}",
35 | "vm_size": "{{user `vm_size`}}",
36 |
37 | "ssh_username": "sysadmin",
38 | "ssh_private_key_file": "~/.ssh/id_rsa"
39 | }],
40 | "provisioners": [
41 | {
42 | "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
43 | "inline": [
44 | "apt-get update",
45 | "apt-get upgrade -y",
46 | "apt-get -y install nginx"
47 | ],
48 | "inline_shebang": "/bin/sh -x",
49 | "type": "shell"
50 | },
51 | {
52 | "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
53 | "inline": [
54 | "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
55 | ],
56 | "inline_shebang": "/bin/sh -x",
57 | "type": "shell"
58 | }
59 | ]
60 | }
61 |
--------------------------------------------------------------------------------
/azure-ubuntu.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "location": "uksouth",
4 | "resource_group_name": "packertest-rg",
5 | "image_name": "ArUbuntu1604Image",
6 | "vm_size": "Standard_DS2_v2",
7 |
8 | "tenant_id": "{{env `ARM_TENANT_ID`}}",
9 | "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
10 | "client_id": "{{env `ARM_CLIENT_ID`}}",
11 | "client_secret": "{{env `ARM_CLIENT_SECRET`}}"
12 | },
13 | "builders": [{
14 | "type": "azure-arm",
15 |
16 | "tenant_id": "{{user `tenant_id`}}",
17 | "subscription_id": "{{user `subscription_id`}}",
18 | "client_id": "{{user `client_id`}}",
19 | "client_secret": "{{user `client_secret`}}",
20 |
21 | "managed_image_resource_group_name": "{{user `resource_group_name`}}",
22 | "managed_image_name": "{{user `image_name`}}",
23 |
24 | "os_type": "Linux",
25 | "image_publisher": "Canonical",
26 | "image_offer": "UbuntuServer",
27 | "image_sku": "16.04-LTS",
28 |
29 | "azure_tags": {
30 | "environment": "dev",
31 | "engineer": "Adam Rush"
32 | },
33 |
34 | "location": "{{user `location`}}",
35 | "vm_size": "{{user `vm_size`}}"
36 | }],
37 | "provisioners": [{
38 | "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
39 | "inline": [
40 | "apt-get update",
41 | "apt-get upgrade -y",
42 | "apt-get -y install nginx",
43 |
44 | "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
45 | ],
46 | "inline_shebang": "/bin/sh -x",
47 | "type": "shell"
48 | }]
49 | }
50 |
--------------------------------------------------------------------------------
/azure-windows-2012r2.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "location": "uksouth",
4 | "resource_group_name": "packertest-rg",
5 | "image_name": "ArWin2012R2Image",
6 | "vm_size": "Standard_DS2_v2",
7 |
8 | "tenant_id": "{{env `ARM_TENANT_ID`}}",
9 | "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
10 | "client_id": "{{env `ARM_CLIENT_ID`}}",
11 | "client_secret": "{{env `ARM_CLIENT_SECRET`}}"
12 | },
13 | "builders": [
14 | {
15 | "type": "azure-arm",
16 |
17 | "tenant_id": "{{user `tenant_id`}}",
18 | "subscription_id": "{{user `subscription_id`}}",
19 | "client_id": "{{user `client_id`}}",
20 | "client_secret": "{{user `client_secret`}}",
21 |
22 | "managed_image_resource_group_name": "{{user `resource_group_name`}}",
23 | "managed_image_name": "{{user `image_name`}}",
24 |
25 | "os_type": "Windows",
26 | "image_publisher": "MicrosoftWindowsServer",
27 | "image_offer": "WindowsServer",
28 | "image_sku": "2012-R2-Datacenter",
29 |
30 | "communicator": "winrm",
31 | "winrm_use_ssl": "true",
32 | "winrm_insecure": "true",
33 | "winrm_timeout": "3m",
34 | "winrm_username": "packer",
35 |
36 | "location": "{{user `location`}}",
37 | "vm_size": "{{user `vm_size`}}"
38 | }
39 | ],
40 | "provisioners": [
41 | {
42 | "type": "powershell",
43 | "inline": [
44 | " # NOTE: the following *3* lines are only needed if the you have installed the Guest Agent.",
45 | " while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }",
46 | " while ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running') { Start-Sleep -s 5 }",
47 | " while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }",
48 | "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
49 | "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
50 | "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; Write-Output $imageState.ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Start-Sleep -s 10 } else { break } }"
51 | ]
52 | }
53 | ]
54 | }
55 |
--------------------------------------------------------------------------------
/vb-win2012r2-base.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "os_name": "win2012r2",
4 | "image_name": "base",
5 | "guest_os_type": "Windows2012_64",
6 | "headless": "true",
7 | "iso_checksum": "849734f37346385dac2c101e4aacba4626bb141c",
8 | "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"
9 | },
10 | "builders": [
11 | {
12 | "type": "virtualbox-iso",
13 | "vboxmanage": [
14 | [
15 | "modifyvm",
16 | "{{.Name}}",
17 | "--memory",
18 | "2048"
19 | ],
20 | [
21 | "modifyvm",
22 | "{{.Name}}",
23 | "--vram",
24 | "48"
25 | ],
26 | [
27 | "modifyvm",
28 | "{{.Name}}",
29 | "--cpus",
30 | "2"
31 | ]
32 | ],
33 | "disk_size": 81920,
34 | "vm_name": "{{ user `os_name` }}-{{ user `image_name` }}",
35 | "guest_additions_mode": "attach",
36 | "guest_os_type": "{{ user `guest_os_type` }}",
37 | "headless": "{{ user `headless` }}",
38 | "iso_url": "{{ user `iso_url` }}",
39 | "iso_checksum": "{{ user `iso_checksum` }}",
40 | "iso_checksum_type": "sha1",
41 | "communicator": "winrm",
42 | "winrm_username": "vagrant",
43 | "winrm_password": "vagrant",
44 | "winrm_timeout": "12h",
45 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
46 | "shutdown_timeout": "1h",
47 | "floppy_files": [
48 | "Answerfiles/2012r2/Autounattend.xml",
49 | "Scripts/Boxstarter.ps1",
50 | "Scripts/Test-Command.ps1",
51 | "Scripts/Package.ps1"
52 | ],
53 | "output_directory": "./output-{{ user `os_name` }}-{{ user `image_name` }}/"
54 | }
55 | ],
56 | "provisioners": [
57 | {
58 | "type": "powershell",
59 | "elevated_user": "vagrant",
60 | "elevated_password": "vagrant",
61 | "script": "Scripts/Install-VirtualboxGuestAdditions.ps1"
62 | }
63 | ]
64 | }
--------------------------------------------------------------------------------
/vb-win2012r2-export-vagrant.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "os_name": "win2012r2",
4 | "image_name": "wmf5-dev-clean",
5 | "vagrant_box_version": "0.2.1",
6 | "source_path": "./output-win2012r2-wmf5-devtools/win2012r2-wmf5-devtools.ovf",
7 | "headless": "true"
8 | },
9 | "builders": [
10 | {
11 | "type": "virtualbox-ovf",
12 | "vboxmanage": [
13 | [
14 | "modifyvm",
15 | "{{.Name}}",
16 | "--memory",
17 | "2048"
18 | ],
19 | [
20 | "modifyvm",
21 | "{{.Name}}",
22 | "--vram",
23 | "48"
24 | ],
25 | [
26 | "modifyvm",
27 | "{{.Name}}",
28 | "--cpus",
29 | "2"
30 | ]
31 | ],
32 | "source_path": "{{user `source_path`}}",
33 | "vm_name": "{{ user `os_name` }}-{{ user `image_name` }}-{{ user `vagrant_box_version` }}",
34 | "guest_additions_mode": "disable",
35 | "headless": "{{ user `headless` }}",
36 | "communicator": "winrm",
37 | "winrm_username": "vagrant",
38 | "winrm_password": "vagrant",
39 | "winrm_timeout": "8h",
40 | "shutdown_command": "a:/PackerShutdown.bat",
41 | "shutdown_timeout": "15m",
42 | "output_directory": "./output-{{ user `os_name` }}-{{ user `image_name` }}/",
43 | "floppy_files": [
44 | "Scripts/UK-postunattend.xml",
45 | "Scripts/SetupComplete-2012.cmd",
46 | "Scripts/PackerShutdown.bat"
47 | ]
48 | }
49 | ],
50 | "provisioners": [
51 | {
52 | "type": "powershell",
53 | "elevated_password": "vagrant",
54 | "elevated_user": "vagrant",
55 | "script": "scripts/cleanup.ps1"
56 | },
57 | {
58 | "type": "powershell",
59 | "elevated_user": "vagrant",
60 | "elevated_password": "vagrant",
61 | "script": "Scripts/Set-Sysprep.ps1"
62 | }
63 | ],
64 | "post-processors": [
65 | [
66 | {
67 | "type": "vagrant",
68 | "keep_input_artifact": true,
69 | "output": "./output-{{ user `os_name` }}-{{ user `image_name` }}/Win2012R2-Std-WMF5-Dev.box",
70 | "vagrantfile_template": "windows-template.vagrantfile"
71 | }
72 | ]
73 | ]
74 | }
--------------------------------------------------------------------------------
/vb-win2012r2-powershell5.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "os_name": "win2012r2",
4 | "image_name": "powershell5",
5 | "source_path": "./output-win2012r2-base/win2012r2-base.ovf",
6 | "headless": "true"
7 | },
8 | "builders": [
9 | {
10 | "type": "virtualbox-ovf",
11 | "vboxmanage": [
12 | [
13 | "modifyvm",
14 | "{{.Name}}",
15 | "--memory",
16 | "2048"
17 | ],
18 | [
19 | "modifyvm",
20 | "{{.Name}}",
21 | "--vram",
22 | "48"
23 | ],
24 | [
25 | "modifyvm",
26 | "{{.Name}}",
27 | "--cpus",
28 | "2"
29 | ]
30 | ],
31 | "source_path": "{{user `source_path`}}",
32 | "vm_name": "{{ user `os_name` }}-{{ user `image_name` }}",
33 | "guest_additions_mode": "disable",
34 | "headless": "{{ user `headless` }}",
35 | "communicator": "winrm",
36 | "winrm_username": "vagrant",
37 | "winrm_password": "vagrant",
38 | "winrm_timeout": "1h",
39 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
40 | "shutdown_timeout": "1h",
41 | "output_directory": "./output-{{ user `os_name` }}-{{ user `image_name` }}/"
42 | }
43 | ],
44 | "provisioners": [
45 | {
46 | "type": "powershell",
47 | "elevated_user": "vagrant",
48 | "elevated_password": "vagrant",
49 | "script": "Scripts/Install-PowerShell5.ps1",
50 | "valid_exit_codes": [
51 | 0,
52 | 3010
53 | ]
54 | },
55 | {
56 | "type": "windows-restart",
57 | "restart_timeout": "1h"
58 | },
59 | {
60 | "elevated_password": "vagrant",
61 | "elevated_user": "vagrant",
62 | "script": "scripts/cleanup.ps1",
63 | "type": "powershell"
64 | }
65 | ]
66 | }
--------------------------------------------------------------------------------
/vb-win2012r2-wmf5-devtools.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "os_name": "win2012r2",
4 | "image_name": "wmf5-devtools",
5 | "source_path": "./output-win2012r2-base/win2012r2-base.ovf",
6 | "headless": "true"
7 | },
8 | "builders": [
9 | {
10 | "type": "virtualbox-ovf",
11 | "vboxmanage": [
12 | [
13 | "modifyvm",
14 | "{{.Name}}",
15 | "--memory",
16 | "2048"
17 | ],
18 | [
19 | "modifyvm",
20 | "{{.Name}}",
21 | "--vram",
22 | "48"
23 | ],
24 | [
25 | "modifyvm",
26 | "{{.Name}}",
27 | "--cpus",
28 | "2"
29 | ]
30 | ],
31 | "source_path": "{{user `source_path`}}",
32 | "vm_name": "{{ user `os_name` }}-{{ user `image_name` }}",
33 | "guest_additions_mode": "disable",
34 | "headless": "{{ user `headless` }}",
35 | "communicator": "winrm",
36 | "winrm_username": "vagrant",
37 | "winrm_password": "vagrant",
38 | "winrm_timeout": "1h",
39 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
40 | "shutdown_timeout": "1h",
41 | "output_directory": "./output-{{ user `os_name` }}-{{ user `image_name` }}/"
42 | }
43 | ],
44 | "provisioners": [
45 | {
46 | "type": "powershell",
47 | "elevated_user": "vagrant",
48 | "elevated_password": "vagrant",
49 | "script": "Scripts/Install-PowerShell5.ps1",
50 | "valid_exit_codes": [
51 | 0,
52 | 3010
53 | ]
54 | },
55 | {
56 | "type": "windows-restart",
57 | "restart_timeout": "1h"
58 | },
59 | {
60 | "type": "powershell",
61 | "elevated_user": "vagrant",
62 | "elevated_password": "vagrant",
63 | "script": "Scripts/Install-DevTools.ps1",
64 | "valid_exit_codes": [
65 | 0,
66 | 3010
67 | ]
68 | }
69 | ]
70 | }
--------------------------------------------------------------------------------
/vb-win2016-devtools.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "os_name": "win2016",
4 | "image_name": "std-dev",
5 | "source_path": "./output-win2016-base/WindowsServer2016.ovf",
6 | "headless": "false"
7 | },
8 | "builders": [
9 | {
10 | "type": "virtualbox-ovf",
11 | "vboxmanage": [
12 | [
13 | "modifyvm",
14 | "{{.Name}}",
15 | "--memory",
16 | "2048"
17 | ],
18 | [
19 | "modifyvm",
20 | "{{.Name}}",
21 | "--vram",
22 | "48"
23 | ],
24 | [
25 | "modifyvm",
26 | "{{.Name}}",
27 | "--cpus",
28 | "2"
29 | ]
30 | ],
31 | "source_path": "{{user `source_path`}}",
32 | "vm_name": "{{ user `os_name` }}-{{ user `image_name` }}",
33 | "guest_additions_mode": "disable",
34 | "headless": "{{ user `headless` }}",
35 | "communicator": "winrm",
36 | "winrm_username": "vagrant",
37 | "winrm_password": "vagrant",
38 | "winrm_timeout": "1h",
39 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
40 | "shutdown_timeout": "1h",
41 | "output_directory": "./output-{{ user `os_name` }}-{{ user `image_name` }}/"
42 | }
43 | ],
44 | "provisioners": [
45 | {
46 | "type": "powershell",
47 | "script": "Scripts/Install-DevTools.ps1",
48 | "valid_exit_codes": [
49 | 0,
50 | 3010
51 | ]
52 | }
53 | ]
54 | }
55 |
--------------------------------------------------------------------------------
/vb-win2016-export-vagrant.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "os_name": "win2016",
4 | "image_name": "std-dev",
5 | "vagrant_box_version": "1809.2.1",
6 | "source_path": "./output-win2016-std-dev/win2016-std-dev.ovf",
7 | "headless": "true"
8 | },
9 | "builders": [
10 | {
11 | "type": "virtualbox-ovf",
12 | "vboxmanage": [
13 | [
14 | "modifyvm",
15 | "{{.Name}}",
16 | "--memory",
17 | "2048"
18 | ],
19 | [
20 | "modifyvm",
21 | "{{.Name}}",
22 | "--vram",
23 | "48"
24 | ],
25 | [
26 | "modifyvm",
27 | "{{.Name}}",
28 | "--cpus",
29 | "2"
30 | ]
31 | ],
32 | "source_path": "{{user `source_path`}}",
33 | "vm_name": "{{ user `os_name` }}-{{ user `image_name` }}-{{ user `vagrant_box_version` }}",
34 | "guest_additions_mode": "disable",
35 | "headless": "{{ user `headless` }}",
36 | "communicator": "winrm",
37 | "winrm_username": "vagrant",
38 | "winrm_password": "vagrant",
39 | "winrm_timeout": "8h",
40 | "shutdown_command": "a:/PackerShutdown.bat",
41 | "shutdown_timeout": "15m",
42 | "output_directory": "./output-{{ user `os_name` }}-{{ user `image_name` }}-{{ user `vagrant_box_version` }}/",
43 | "floppy_files": [
44 | "Scripts/UK-postunattend.xml",
45 | "Scripts/SetupComplete-2012.cmd",
46 | "Scripts/PackerShutdown.bat"
47 | ]
48 | }
49 | ],
50 | "provisioners": [
51 | {
52 | "type": "powershell",
53 | "script": "scripts/cleanup.ps1"
54 | },
55 | {
56 | "type": "powershell",
57 | "script": "Scripts/Set-Sysprep.ps1"
58 | }
59 | ],
60 | "post-processors": [
61 | [
62 | {
63 | "type": "vagrant",
64 | "keep_input_artifact": true,
65 | "output": "./output-{{ user `os_name` }}-{{ user `image_name` }}-{{ user `vagrant_box_version` }}/win2016-std-dev-{{ user `vagrant_box_version` }}.box",
66 | "vagrantfile_template": "windows-template.vagrantfile"
67 | }
68 | ]
69 | ]
70 | }
71 |
--------------------------------------------------------------------------------
/win2012-VagrantBoxDescription.md:
--------------------------------------------------------------------------------
1 | # Vagrant box upload notes
2 |
3 | ## URL
4 |
5 | [https://app.vagrantup.com/adamrushuk/boxes/win2012r2-std-wmf5-dev](https://app.vagrantup.com/adamrushuk/boxes/win2012r2-std-wmf5-dev)
6 |
7 | ## Local Path
8 |
9 | Choose `virtualbox` provider
10 |
11 | `C:\Source\Repos\Packer-Templates\output-win2012r2-powershell5-vagrant\Win2012R2-Std-WMF5-Dev.box`
12 |
13 | ## Version
14 |
15 | 0.2.1
16 |
17 | ## Short Description (per box)
18 |
19 | A fully patched Windows Server 2012 R2 (standard) box , with useful development tools installed.
20 |
21 | ## Long Description (per version)
22 |
23 | - `March 2018` Windows Updates installed.
24 | - Dev tools installed: `sysinternals`, `treesizefree`, `cmder`, `notepadplusplus.install`, `putty`, `git.install`, `poshgit`, `7zip`, `visualstudiocode`.
25 | - VSCode Extensions installed: `ms-vscode.PowerShell`, `eamodio.gitlens`, `DotJoshJohnson.xml`, `robertohuertasm.vscode-icons`
26 | - VirtualBox Guest Additions `v5.2.8` installed.
27 | - Disk cleanup tasks completed.
28 |
--------------------------------------------------------------------------------
/win2016-VagrantBoxDescription.md:
--------------------------------------------------------------------------------
1 | # Vagrant box upload notes
2 |
3 | ## URL
4 |
5 | [https://app.vagrantup.com/adamrushuk/boxes/win2016-datacenter-dev](https://app.vagrantup.com/adamrushuk/boxes/win2016-datacenter-dev)
6 |
7 | ## Local Path
8 |
9 | Choose `virtualbox` provider
10 |
11 | `C:\Source\Repos\packer-templates\output-win2016-dev-1809.0.0\win2016-std-dev-1809.0.0.box`
12 |
13 | ## Version
14 |
15 | 1809.0.0
16 |
17 | ## Short Description (per box)
18 |
19 | A fully patched Windows Server 2016 (Datacenter) box, with useful development tools installed.
20 |
21 | ## Long Description (per box version)
22 |
23 | - `September 2018` Windows Updates installed.
24 | - Dev tools installed:
25 | `7zip.install`,
26 | `chefdk`,
27 | `cmdermini`,
28 | `git.install`,
29 | `mremoteng`,
30 | `notepadplusplus.install`,
31 | `poshgit`,
32 | `putty`,
33 | `sysinternals`,
34 | `treesizefree`,
35 | `visualstudiocode`,
36 | `lockhunter`
37 | - VSCode Extensions installed:
38 | `aaron-bond.better-comments`,
39 | `bierner.markdown-preview-github-styles`,
40 | `coenraads.bracket-pair-colorizer-2`,
41 | `davidanson.vscode-markdownlint`,
42 | `DotJoshJohnson.xml`,
43 | `drmattsm.replace-smart-characters`,
44 | `eamodio.gitlens`,
45 | `grapecity.gc-excelviewer`,
46 | `marcostazi.vs-code-vagrantfile`,
47 | `ms-vscode.PowerShell`,
48 | `robertohuertasm.vscode-icons`,
49 | `sidneys1.gitconfig`,
50 | `stkb.rewrap`,
51 | `wengerk.highlight-bad-chars`,
52 | `yzhang.markdown-all-in-one`
53 | - VirtualBox Guest Additions `v5.2.18` installed.
54 | - Disk cleanup tasks completed.
55 |
56 | ## Final Steps
57 |
58 | - Release the uploaded version on Vagrant website.
59 | - Download the latest version using `vagrant box update --box adamrushuk/win2016-datacenter-dev`
60 |
--------------------------------------------------------------------------------
/win2016-std-dev_VagrantBoxDescription.md:
--------------------------------------------------------------------------------
1 | # Vagrant box upload notes
2 |
3 | ## URL
4 |
5 | [https://app.vagrantup.com/adamrushuk/boxes/win2016-std-dev](https://app.vagrantup.com/adamrushuk/boxes/win2016-std-dev)
6 |
7 | ## Version
8 |
9 | 1809.1.0
10 |
11 | ## Short Description (per box)
12 |
13 | A fully patched Windows Server 2016 (Standard) box, with useful development tools installed.
14 |
15 | ## Description (new box version)
16 |
17 | - `September 2018` Windows Updates installed.
18 | - Dev tools installed:
19 | `7zip.install`,
20 | `chefdk`,
21 | `cmdermini`,
22 | `git.install`,
23 | `mremoteng`,
24 | `notepadplusplus.install`,
25 | `poshgit`,
26 | `putty`,
27 | `sysinternals`,
28 | `treesizefree`,
29 | `visualstudiocode`,
30 | `lockhunter`
31 | - VSCode Extensions installed:
32 | `aaron-bond.better-comments`,
33 | `bierner.markdown-preview-github-styles`,
34 | `coenraads.bracket-pair-colorizer-2`,
35 | `davidanson.vscode-markdownlint`,
36 | `DotJoshJohnson.xml`,
37 | `drmattsm.replace-smart-characters`,
38 | `eamodio.gitlens`,
39 | `esbenp.prettier-vscode`
40 | `grapecity.gc-excelviewer`,
41 | `marcostazi.vs-code-vagrantfile`,
42 | `ms-vscode.PowerShell`,
43 | `robertohuertasm.vscode-icons`,
44 | `sidneys1.gitconfig`,
45 | `stkb.rewrap`,
46 | `wengerk.highlight-bad-chars`,
47 | `yzhang.markdown-all-in-one`
48 | - VirtualBox Guest Additions `v5.2.18` installed.
49 | - Disk cleanup tasks completed.
50 |
51 | ## Local Path
52 |
53 | Choose `virtualbox` provider
54 |
55 | `C:\Source\Repos\packer-templates\output-win2016-std-dev-1809.1.0\win2016-std-dev-1809.1.0.box`
56 |
57 | ## Final Steps
58 |
59 | - Release the uploaded version on Vagrant website.
60 | - Download the latest version using `vagrant box update --box adamrushuk/win2016-std-dev`
61 |
--------------------------------------------------------------------------------
/windows-template.vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 | Vagrant.configure(2) do |config|
5 | config.vm.guest = :windows
6 | config.vm.communicator = "winrm"
7 | config.vm.boot_timeout = 300
8 |
9 | config.vm.provider "virtualbox" do |vb|
10 | vb.gui = true
11 | vb.customize ["modifyvm", :id, "--memory", 2048]
12 | vb.customize ["modifyvm", :id, "--cpus", 2]
13 | vb.customize ["modifyvm", :id, "--vram", 128]
14 | vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
15 | vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
16 | end
17 |
18 | config.vm.provider 'hyperv' do |hv|
19 | hv.ip_address_timeout = 240
20 | hv.memory = 1024
21 | end
22 |
23 | config.vm.provider :libvirt do |domain|
24 | domain.memory = 2028
25 | domain.cpus = 2
26 | end
27 | end
28 |
--------------------------------------------------------------------------------