Skip to content

Commit 6da0bda

Browse files
committed
Land #586, download windows pre-req using host OS
2 parents 2dadd8c + 4cdd769 commit 6da0bda

File tree

13 files changed

+95
-44
lines changed

13 files changed

+95
-44
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
packer_cache/
33
packer/builds/
44
resources/drivers/
5+
resources/windows_pre_downloads/
56
*.vfd
67
*.exe
78
*.msi

packer/answer_files/2008_r2/Autounattend.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,6 @@
261261
<CommandLine>cmd.exe /c mkdir -p C:\vagrant\scripts</CommandLine>
262262
<Description>Create directory for vagrant files to avoid provisioner bug with packer.</Description>
263263
<Order>26</Order>
264-
</SynchronousCommand>
265-
<SynchronousCommand wcm:action="add">
266-
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\install_dotnet45.ps1 -AutoStart</CommandLine>
267-
<Order>97</Order>
268-
<Description>Install .NET 4.5.1</Description>
269-
</SynchronousCommand>
270-
<SynchronousCommand wcm:action="add">
271-
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\install_wmf.ps1 -AutoStart</CommandLine>
272-
<Order>98</Order>
273-
<Description>Installing Windows Management Framework 5.0</Description>
274264
</SynchronousCommand>
275265
<!--WITHOUT WINDOWS UPDATES -->
276266
<SynchronousCommand wcm:action="add">

packer/templates/windows_2008_r2.json

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
1919
"{{user `scripts_dir`}}/configs/win-updates.ps1",
2020
"{{user `scripts_dir`}}/installs/openssh.ps1",
21-
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
22-
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
2321
"{{user `resources_dir`}}/certs/oracle-cert.cer",
2422
"{{user `resources_dir`}}/certs/gdig2.crt",
2523
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
@@ -56,8 +54,6 @@
5654
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
5755
"{{user `scripts_dir`}}/configs/win-updates.ps1",
5856
"{{user `scripts_dir`}}/installs/openssh.ps1",
59-
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
60-
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
6157
"{{user `resources_dir`}}/certs/oracle-cert.cer",
6258
"{{user `resources_dir`}}/certs/gdig2.crt",
6359
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
@@ -99,8 +95,6 @@
9995
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
10096
"{{user `scripts_dir`}}/configs/win-updates.ps1",
10197
"{{user `scripts_dir`}}/installs/openssh.ps1",
102-
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
103-
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
10498
"{{user `resources_dir`}}/certs/oracle-cert.cer",
10599
"{{user `resources_dir`}}/certs/gdig2.crt",
106100
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
@@ -150,8 +144,6 @@
150144
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
151145
"{{user `scripts_dir`}}/configs/win-updates.ps1",
152146
"{{user `scripts_dir`}}/installs/openssh.ps1",
153-
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
154-
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
155147
"{{user `resources_dir`}}/certs/oracle-cert.cer",
156148
"{{user `resources_dir`}}/certs/gdig2.crt",
157149
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
@@ -184,6 +176,16 @@
184176
}
185177
],
186178
"provisioners": [
179+
{
180+
"type": "shell-local",
181+
"only_on": ["linux", "darwin"],
182+
"inline": ["cd {{user `resources_dir`}} && {{user `resources_dir`}}/download-windows-files.sh"]
183+
},
184+
{
185+
"type": "shell-local",
186+
"only_on": ["windows"],
187+
"inline": ["cd {{user `resources_dir`}} && powershell {{user `resources_dir`}}/download-windows-files.ps1"]
188+
},
187189
{
188190
"type": "file",
189191
"source": "{{user `scripts_dir`}}",
@@ -200,7 +202,6 @@
200202
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
201203
"scripts": [
202204
"{{user `scripts_dir`}}/configs/update_root_certs.bat",
203-
"{{user `scripts_dir`}}/configs/disable-auto-logon.bat",
204205
"{{user `scripts_dir`}}/configs/enable-rdp.bat"
205206
]
206207
},
@@ -215,6 +216,25 @@
215216
{
216217
"type": "windows-restart"
217218
},
219+
{
220+
"type": "powershell",
221+
"scripts": [
222+
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1"
223+
]
224+
},
225+
{
226+
"type": "windows-restart"
227+
},
228+
{
229+
"type": "powershell",
230+
"scripts": [
231+
"{{user `scripts_dir`}}/installs/install_wmf.ps1"
232+
]
233+
},
234+
{
235+
"type": "windows-restart",
236+
"pause_before": "180s"
237+
},
218238
{
219239
"type": "powershell",
220240
"scripts": [
@@ -240,7 +260,9 @@
240260
"remote_path": "C:/Windows/Temp/script.bat",
241261
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
242262
"scripts": [
243-
"{{user `scripts_dir`}}/installs/install_boxstarter.bat",
263+
"{{user `scripts_dir`}}/configs/disable-auto-logon.bat",
264+
"{{user `scripts_dir`}}/chocolatey_installs/chocolatey-compatibility.bat",
265+
"{{user `scripts_dir`}}/chocolatey_installs/boxstarter.bat",
244266
"{{user `scripts_dir`}}/chocolatey_installs/7zip.bat",
245267
"{{user `scripts_dir`}}/configs/apply_password_settings.bat",
246268
"{{user `scripts_dir`}}/configs/create_users.bat",
@@ -267,7 +289,7 @@
267289
"{{user `scripts_dir`}}/installs/install_wordpress.bat",
268290
"{{user `scripts_dir`}}/installs/install_openjdk6.bat",
269291
"{{user `scripts_dir`}}/installs/setup_jmx.bat",
270-
"{{user `scripts_dir`}}/installs/install_ruby.bat",
292+
"{{user `scripts_dir`}}/chocolatey_installs/ruby.bat",
271293
"{{user `scripts_dir`}}/installs/install_devkit.bat"
272294
]
273295
},
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$Logfile = "C:\Windows\Temp\wmf-install.log"
2+
function LogWrite {
3+
Param ([string]$logstring)
4+
$now = Get-Date -format s
5+
Add-Content $Logfile -value "$now $logstring"
6+
Write-Host $logstring
7+
}
8+
9+
LogWrite "Downloading dotNet 4.5.2"
10+
try {
11+
(New-Object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', 'windows_pre_downloads/dotnet.exe')
12+
} catch {
13+
LogWrite $_.Exception | Format-List -force
14+
LogWrite "Failed to download file."
15+
}
16+
17+
LogWrite "Downloading Windows Management Framework 5.1"
18+
try {
19+
(New-Object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip', 'windows_pre_downloads/wmf.zip')
20+
} catch {
21+
LogWrite $_.Exception | Format-List -force
22+
LogWrite "Failed to download file."
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash -e
2+
curl -L --output windows_pre_downloads/dotnet.exe https://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe
3+
curl -L --output windows_pre_downloads/wmf.zip https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip

resources/windows_pre_downloads/.gitkeep

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
chocolatey feature enable -n=allowGlobalConfirmation
2+
choco install chocolatey-compatibility.extension
3+
chocolatey feature disable -n=allowGlobalConfirmation
4+
exit
File renamed without changes.

scripts/installs/chocolatey.cmd

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)