knife-windows 4.0.2 → 4.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,332 +0,0 @@
1
- @rem
2
- @rem Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- @rem Copyright:: Copyright (c) 2011 Opscode, Inc.
4
- @rem License:: Apache License, Version 2.0
5
- @rem
6
- @rem Licensed under the Apache License, Version 2.0 (the "License");
7
- @rem you may not use this file except in compliance with the License.
8
- @rem You may obtain a copy of the License at
9
- @rem
10
- @rem http://www.apache.org/licenses/LICENSE-2.0
11
- @rem
12
- @rem Unless required by applicable law or agreed to in writing, software
13
- @rem distributed under the License is distributed on an "AS IS" BASIS,
14
- @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- @rem See the License for the specific language governing permissions and
16
- @rem limitations under the License.
17
- @rem
18
-
19
- @rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the
20
- @rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when
21
- @rem the line is read. See help for the /E switch from cmd.exe /? .
22
- @setlocal ENABLEDELAYEDEXPANSION
23
-
24
-
25
-
26
- @set BOOTSTRAP_DIRECTORY=C:\chef
27
- @echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"...
28
- @if NOT EXIST %BOOTSTRAP_DIRECTORY% (
29
- @echo Existing directory not found, creating.
30
- @mkdir %BOOTSTRAP_DIRECTORY%
31
- ) else (
32
- @echo Existing directory found, skipping creation.
33
- )
34
-
35
- > C:\chef\wget.vbs (
36
- echo.url = WScript.Arguments.Named^("url"^)
37
- echo.path = WScript.Arguments.Named^("path"^)
38
- echo.proxy = null
39
- echo.'* Vaguely attempt to handle file:// scheme urls by url unescaping and switching all
40
- echo.'* / into . Also assume that file:/// is a local absolute path and that file://^<foo^>
41
- echo.'* is possibly a network file path.
42
- echo.If InStr^(url, "file://"^) = 1 Then
43
- echo.url = Unescape^(url^)
44
- echo.If InStr^(url, "file:///"^) = 1 Then
45
- echo.sourcePath = Mid^(url, Len^("file:///"^) + 1^)
46
- echo.Else
47
- echo.sourcePath = Mid^(url, Len^("file:"^) + 1^)
48
- echo.End If
49
- echo.sourcePath = Replace^(sourcePath, "/", "\"^)
50
- echo.
51
- echo.Set objFSO = CreateObject^("Scripting.FileSystemObject"^)
52
- echo.If objFSO.Fileexists^(path^) Then objFSO.DeleteFile path
53
- echo.objFSO.CopyFile sourcePath, path, true
54
- echo.Set objFSO = Nothing
55
- echo.
56
- echo.Else
57
- echo.Set objXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP"^)
58
- echo.Set wshShell = CreateObject^( "WScript.Shell" ^)
59
- echo.Set objUserVariables = wshShell.Environment^("USER"^)
60
- echo.
61
- echo.rem http proxy is optional
62
- echo.rem attempt to read from HTTP_PROXY env var first
63
- echo.On Error Resume Next
64
- echo.
65
- echo.If NOT ^(objUserVariables^("HTTP_PROXY"^) = ""^) Then
66
- echo.proxy = objUserVariables^("HTTP_PROXY"^)
67
- echo.
68
- echo.rem fall back to named arg
69
- echo.ElseIf NOT ^(WScript.Arguments.Named^("proxy"^) = ""^) Then
70
- echo.proxy = WScript.Arguments.Named^("proxy"^)
71
- echo.End If
72
- echo.
73
- echo.If NOT isNull^(proxy^) Then
74
- echo.rem setProxy method is only available on ServerXMLHTTP 6.0+
75
- echo.Set objXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP.6.0"^)
76
- echo.objXMLHTTP.setProxy 2, proxy
77
- echo.End If
78
- echo.
79
- echo.On Error Goto 0
80
- echo.
81
- echo.objXMLHTTP.open "GET", url, false
82
- echo.objXMLHTTP.send^(^)
83
- echo.If objXMLHTTP.Status = 200 Then
84
- echo.Set objADOStream = CreateObject^("ADODB.Stream"^)
85
- echo.objADOStream.Open
86
- echo.objADOStream.Type = 1
87
- echo.objADOStream.Write objXMLHTTP.ResponseBody
88
- echo.objADOStream.Position = 0
89
- echo.Set objFSO = Createobject^("Scripting.FileSystemObject"^)
90
- echo.If objFSO.Fileexists^(path^) Then objFSO.DeleteFile path
91
- echo.Set objFSO = Nothing
92
- echo.objADOStream.SaveToFile path
93
- echo.objADOStream.Close
94
- echo.Set objADOStream = Nothing
95
- echo.End If
96
- echo.Set objXMLHTTP = Nothing
97
- echo.End If
98
-
99
- )
100
-
101
- > C:\chef\wget.ps1 (
102
- echo.param^(
103
- echo. [String] $remoteUrl,
104
- echo. [String] $localPath
105
- echo.^)
106
- echo.
107
- echo.$ProxyUrl = $env:http_proxy;
108
- echo.$webClient = new-object System.Net.WebClient;
109
- echo.
110
- echo.if ^($ProxyUrl -ne ''^) {
111
- echo. $WebProxy = New-Object System.Net.WebProxy^($ProxyUrl,$true^)
112
- echo. $WebClient.Proxy = $WebProxy
113
- echo.}
114
- echo.
115
- echo.$webClient.DownloadFile^($remoteUrl, $localPath^);
116
-
117
- )
118
-
119
- @rem Determine the version and the architecture
120
-
121
- @FOR /F "usebackq tokens=1-8 delims=.[] " %%A IN (`ver`) DO (
122
- @set WinMajor=%%D
123
- @set WinMinor=%%E
124
- @set WinBuild=%%F
125
- )
126
-
127
- @echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild%
128
-
129
- @set LATEST_OS_VERSION_MAJOR=6
130
- @set LATEST_OS_VERSION_MINOR=3
131
-
132
- @if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown
133
- @if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR% (
134
- @if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown
135
- )
136
-
137
- goto Version%WinMajor%.%WinMinor%
138
-
139
- :VersionUnknown
140
- @rem If this is an unknown version of windows set the default
141
- @set MACHINE_OS=2008r2
142
- @echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS%
143
- goto architecture_select
144
-
145
- :Version6.0
146
- @set MACHINE_OS=2008
147
- goto architecture_select
148
-
149
- :Version5.2
150
- @set MACHINE_OS=2003r2
151
- goto architecture_select
152
-
153
- :Version6.1
154
- @set MACHINE_OS=2008r2
155
- goto architecture_select
156
-
157
- :Version6.2
158
- @set MACHINE_OS=2012
159
- goto architecture_select
160
-
161
- @rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012
162
- :Version6.3
163
- goto Version6.2
164
-
165
- :architecture_select
166
- goto Architecture%PROCESSOR_ARCHITEW6432%
167
-
168
- :Architecture
169
- goto Architecture%PROCESSOR_ARCHITECTURE%
170
-
171
- @rem If this is an unknown architecture set the default
172
- @set MACHINE_ARCH=i686
173
- goto install
174
-
175
- :Architecturex86
176
- @set MACHINE_ARCH=i686
177
- goto install
178
-
179
- :Architectureamd64
180
- @set MACHINE_ARCH=x86_64
181
- goto install
182
-
183
- :install
184
- @rem If user has provided the custom installation command for chef-client then execute it
185
- @rem Install Chef using chef-client MSI installer
186
-
187
- @set "LOCAL_DESTINATION_MSI_PATH=%TEMP%\chef-client-latest.msi"
188
- @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\chef-client-msi%RANDOM%.log"
189
-
190
- @rem Clear any pre-existing downloads
191
- @echo Checking for existing downloaded package at "%LOCAL_DESTINATION_MSI_PATH%"
192
- @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
193
- @echo Found existing downloaded package, deleting.
194
- @del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
195
- @if ERRORLEVEL 1 (
196
- echo Warning: Failed to delete pre-existing package with status code !ERRORLEVEL! > "&2"
197
- )
198
- ) else (
199
- echo No existing downloaded packages to delete.
200
- )
201
-
202
- @rem If there is somehow a name collision, remove pre-existing log
203
- @if EXIST "%CHEF_CLIENT_MSI_LOG_PATH%" del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
204
-
205
- @echo Attempting to download client package using PowerShell if available...
206
- @set "REMOTE_SOURCE_MSI_URL=https://www.chef.io/chef/download?p=windows&pv=%MACHINE_OS%&m=%MACHINE_ARCH%&DownloadContext=PowerShell&v=13"
207
- @set powershell_download=powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File C:\chef\wget.ps1 "%REMOTE_SOURCE_MSI_URL%" "%LOCAL_DESTINATION_MSI_PATH%"
208
- @echo !powershell_download!
209
- @call !powershell_download!
210
-
211
- @set DOWNLOAD_ERROR_STATUS=!ERRORLEVEL!
212
-
213
- @if ERRORLEVEL 1 (
214
- @echo Failed PowerShell download with status code !DOWNLOAD_ERROR_STATUS! > "&2"
215
- @if !DOWNLOAD_ERROR_STATUS!==0 set DOWNLOAD_ERROR_STATUS=2
216
- ) else (
217
- @rem Sometimes the error level is not set even when the download failed,
218
- @rem so check for the file to be sure it is there -- if it is not, we will retry
219
- @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
220
- echo Failed download: download completed, but downloaded file not found > "&2"
221
- set DOWNLOAD_ERROR_STATUS=2
222
- ) else (
223
- echo Download via PowerShell succeeded.
224
- )
225
- )
226
-
227
- @if NOT %DOWNLOAD_ERROR_STATUS%==0 (
228
- @echo Warning: Failed to download "%REMOTE_SOURCE_MSI_URL%" to "%LOCAL_DESTINATION_MSI_PATH%"
229
- @echo Warning: Retrying download with cscript ...
230
-
231
- @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
232
-
233
- @set "REMOTE_SOURCE_MSI_URL=https://www.chef.io/chef/download?p=windows&pv=%MACHINE_OS%&m=%MACHINE_ARCH%&v=13"
234
- cscript /nologo C:\chef\wget.vbs /url:"%REMOTE_SOURCE_MSI_URL%" /path:"%LOCAL_DESTINATION_MSI_PATH%"
235
-
236
- @if NOT ERRORLEVEL 1 (
237
- @rem Sometimes the error level is not set even when the download failed,
238
- @rem so check for the file to be sure it is there.
239
- @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
240
- echo Failed download: download completed, but downloaded file not found > "&2"
241
- echo Exiting without bootstrapping due to download failure. > "&2"
242
- exit /b 1
243
- ) else (
244
- echo Download via cscript succeeded.
245
- )
246
- ) else (
247
- echo Failed to download "%REMOTE_SOURCE_MSI_URL%" with status code !ERRORLEVEL!. > "&2"
248
- echo Exiting without bootstrapping due to download failure. > "&2"
249
- exit /b 1
250
- )
251
- )
252
-
253
- @echo Installing downloaded client package...
254
-
255
- msiexec /qn /log "%CHEF_CLIENT_MSI_LOG_PATH%" /i "%LOCAL_DESTINATION_MSI_PATH%"
256
- @set MSIERRORCODE=!ERRORLEVEL!
257
- @if ERRORLEVEL 1 (
258
- @echo WARNING: Failed to install Chef Client MSI package in remote context with status code !MSIERRORCODE!.
259
- @echo WARNING: This may be due to a defect in operating system update KB2918614: http://support.microsoft.com/kb/2918614
260
- @set OLDLOGLOCATION="%CHEF_CLIENT_MSI_LOG_PATH%-fail.log"
261
- @move "%CHEF_CLIENT_MSI_LOG_PATH%" "!OLDLOGLOCATION!" > NUL
262
- @echo WARNING: Saving installation log of failure at !OLDLOGLOCATION!
263
- @echo WARNING: Retrying installation with local context...
264
- @schtasks /create /f /sc once /st 00:00:00 /tn chefclientbootstraptask /ru SYSTEM /rl HIGHEST /tr "cmd /c msiexec /qn /log '%CHEF_CLIENT_MSI_LOG_PATH%' /i '%LOCAL_DESTINATION_MSI_PATH%' & sleep 2 & waitfor /s %computername% /si chefclientinstalldone"
265
-
266
- @if ERRORLEVEL 1 (
267
- @echo ERROR: Failed to create Chef Client installation scheduled task with status code !ERRORLEVEL! > "&2"
268
- ) else (
269
- @echo Successfully created scheduled task to install Chef Client.
270
- @schtasks /run /tn chefclientbootstraptask
271
- @if ERRORLEVEL 1 (
272
- @echo ERROR: Failed to execut Chef Client installation scheduled task with status code !ERRORLEVEL!. > "&2"
273
- ) else (
274
- @echo Successfully started Chef Client installation scheduled task.
275
- @echo Waiting for installation to complete -- this may take a few minutes...
276
- waitfor chefclientinstalldone /t 600
277
- if ERRORLEVEL 1 (
278
- @echo ERROR: Timed out waiting for Chef Client package to install
279
- ) else (
280
- @echo Finished waiting for Chef Client package to install.
281
- )
282
- @schtasks /delete /f /tn chefclientbootstraptask > NUL
283
- )
284
- )
285
- ) else (
286
- @echo Successfully installed Chef Client package.
287
- )
288
-
289
-
290
- @if ERRORLEVEL 1 (
291
- echo Chef-client package failed to install with status code !ERRORLEVEL!. > "&2"
292
- echo See installation log for additional detail: %CHEF_CLIENT_MSI_LOG_PATH%. > "&2"
293
- ) else (
294
- @echo Installation completed successfully
295
- del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
296
- )
297
-
298
-
299
- @endlocal
300
-
301
- @echo off
302
-
303
-
304
- echo Writing validation key...
305
-
306
-
307
- echo Validation key written.
308
- @echo on
309
-
310
-
311
-
312
-
313
- > C:\chef\client.rb (
314
- echo.chef_server_url "https://localhost:443"
315
- echo.validation_client_name "chef-validator"
316
- echo.file_cache_path "c:/chef/cache"
317
- echo.file_backup_path "c:/chef/backup"
318
- echo.cache_options ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
319
- echo.# Using default node name ^(fqdn^)
320
- echo.log_level :info
321
- echo.log_location STDOUT
322
-
323
- )
324
-
325
- > C:\chef\first-boot.json (
326
- echo.{"run_list":null}
327
- )
328
-
329
- @echo Starting chef to bootstrap the node...
330
- SET "PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\ruby\bin;C:\opscode\chef\bin;C:\opscode\chef\embedded\bin"
331
- chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json
332
-
@@ -1,246 +0,0 @@
1
- @rem
2
- @rem Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- @rem Copyright:: Copyright (c) 2011 Opscode, Inc.
4
- @rem License:: Apache License, Version 2.0
5
- @rem
6
- @rem Licensed under the Apache License, Version 2.0 (the "License");
7
- @rem you may not use this file except in compliance with the License.
8
- @rem You may obtain a copy of the License at
9
- @rem
10
- @rem http://www.apache.org/licenses/LICENSE-2.0
11
- @rem
12
- @rem Unless required by applicable law or agreed to in writing, software
13
- @rem distributed under the License is distributed on an "AS IS" BASIS,
14
- @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- @rem See the License for the specific language governing permissions and
16
- @rem limitations under the License.
17
- @rem
18
-
19
- @rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the
20
- @rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when
21
- @rem the line is read. See help for the /E switch from cmd.exe /? .
22
- @setlocal ENABLEDELAYEDEXPANSION
23
-
24
- <%= "SETX HTTP_PROXY \"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] %>
25
-
26
- @set BOOTSTRAP_DIRECTORY=<%= bootstrap_directory %>
27
- @echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"...
28
- @if NOT EXIST %BOOTSTRAP_DIRECTORY% (
29
- @echo Existing directory not found, creating.
30
- @mkdir %BOOTSTRAP_DIRECTORY%
31
- ) else (
32
- @echo Existing directory found, skipping creation.
33
- )
34
-
35
- > <%= bootstrap_directory %>\wget.vbs (
36
- <%= win_wget %>
37
- )
38
-
39
- > <%= bootstrap_directory %>\wget.ps1 (
40
- <%= win_wget_ps %>
41
- )
42
-
43
- @rem Determine the version and the architecture
44
-
45
- @FOR /F "usebackq tokens=1-8 delims=.[] " %%A IN (`ver`) DO (
46
- @set WinMajor=%%D
47
- @set WinMinor=%%E
48
- @set WinBuild=%%F
49
- )
50
-
51
- @echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild%
52
-
53
- @set LATEST_OS_VERSION_MAJOR=6
54
- @set LATEST_OS_VERSION_MINOR=3
55
-
56
- @if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown
57
- @if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR% (
58
- @if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown
59
- )
60
-
61
- goto Version%WinMajor%.%WinMinor%
62
-
63
- :VersionUnknown
64
- @rem If this is an unknown version of windows set the default
65
- @set MACHINE_OS=2008r2
66
- @echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS%
67
- goto architecture_select
68
-
69
- :Version6.0
70
- @set MACHINE_OS=2008
71
- goto architecture_select
72
-
73
- :Version5.2
74
- @set MACHINE_OS=2003r2
75
- goto architecture_select
76
-
77
- :Version6.1
78
- @set MACHINE_OS=2008r2
79
- goto architecture_select
80
-
81
- :Version6.2
82
- @set MACHINE_OS=2012
83
- goto architecture_select
84
-
85
- @rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012
86
- :Version6.3
87
- goto Version6.2
88
-
89
- :architecture_select
90
- goto Architecture%PROCESSOR_ARCHITEW6432%
91
-
92
- :Architecture
93
- goto Architecture%PROCESSOR_ARCHITECTURE%
94
-
95
- @rem If this is an unknown architecture set the default
96
- @set MACHINE_ARCH=i686
97
- goto install
98
-
99
- :Architecturex86
100
- @set MACHINE_ARCH=i686
101
- goto install
102
-
103
- :Architectureamd64
104
- @set MACHINE_ARCH=x86_64
105
- goto install
106
-
107
- :install
108
- @rem If user has provided the custom installation command for chef-client then execute it
109
- <% if @chef_config[:knife][:bootstrap_install_command] %>
110
- <%= @chef_config[:knife][:bootstrap_install_command] %>
111
- <% else %>
112
- @rem Install Chef using chef-client MSI installer
113
-
114
- @set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>"
115
- @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\chef-client-msi%RANDOM%.log"
116
-
117
- @rem Clear any pre-existing downloads
118
- @echo Checking for existing downloaded package at "%LOCAL_DESTINATION_MSI_PATH%"
119
- @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
120
- @echo Found existing downloaded package, deleting.
121
- @del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
122
- @if ERRORLEVEL 1 (
123
- echo Warning: Failed to delete pre-existing package with status code !ERRORLEVEL! > "&2"
124
- )
125
- ) else (
126
- echo No existing downloaded packages to delete.
127
- )
128
-
129
- @rem If there is somehow a name collision, remove pre-existing log
130
- @if EXIST "%CHEF_CLIENT_MSI_LOG_PATH%" del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
131
-
132
- @echo Attempting to download client package using PowerShell if available...
133
- @set "REMOTE_SOURCE_MSI_URL=<%= msi_url('%MACHINE_OS%', '%MACHINE_ARCH%', 'PowerShell') %>"
134
- @set powershell_download=powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File <%= bootstrap_directory %>\wget.ps1 "%REMOTE_SOURCE_MSI_URL%" "%LOCAL_DESTINATION_MSI_PATH%"
135
- @echo !powershell_download!
136
- @call !powershell_download!
137
-
138
- @set DOWNLOAD_ERROR_STATUS=!ERRORLEVEL!
139
-
140
- @if ERRORLEVEL 1 (
141
- @echo Failed PowerShell download with status code !DOWNLOAD_ERROR_STATUS! > "&2"
142
- @if !DOWNLOAD_ERROR_STATUS!==0 set DOWNLOAD_ERROR_STATUS=2
143
- ) else (
144
- @rem Sometimes the error level is not set even when the download failed,
145
- @rem so check for the file to be sure it is there -- if it is not, we will retry
146
- @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
147
- echo Failed download: download completed, but downloaded file not found > "&2"
148
- set DOWNLOAD_ERROR_STATUS=2
149
- ) else (
150
- echo Download via PowerShell succeeded.
151
- )
152
- )
153
-
154
- @if NOT %DOWNLOAD_ERROR_STATUS%==0 (
155
- @echo Warning: Failed to download "%REMOTE_SOURCE_MSI_URL%" to "%LOCAL_DESTINATION_MSI_PATH%"
156
- @echo Warning: Retrying download with cscript ...
157
-
158
- @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
159
-
160
- @set "REMOTE_SOURCE_MSI_URL=<%= msi_url('%MACHINE_OS%', '%MACHINE_ARCH%') %>"
161
- cscript /nologo <%= bootstrap_directory %>\wget.vbs /url:"%REMOTE_SOURCE_MSI_URL%" /path:"%LOCAL_DESTINATION_MSI_PATH%"
162
-
163
- @if NOT ERRORLEVEL 1 (
164
- @rem Sometimes the error level is not set even when the download failed,
165
- @rem so check for the file to be sure it is there.
166
- @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
167
- echo Failed download: download completed, but downloaded file not found > "&2"
168
- echo Exiting without bootstrapping due to download failure. > "&2"
169
- exit /b 1
170
- ) else (
171
- echo Download via cscript succeeded.
172
- )
173
- ) else (
174
- echo Failed to download "%REMOTE_SOURCE_MSI_URL%" with status code !ERRORLEVEL!. > "&2"
175
- echo Exiting without bootstrapping due to download failure. > "&2"
176
- exit /b 1
177
- )
178
- )
179
-
180
- @echo Installing downloaded client package...
181
-
182
- <%= install_chef %>
183
-
184
- @if ERRORLEVEL 1 (
185
- echo Chef-client package failed to install with status code !ERRORLEVEL!. > "&2"
186
- echo See installation log for additional detail: %CHEF_CLIENT_MSI_LOG_PATH%. > "&2"
187
- ) else (
188
- @echo Installation completed successfully
189
- del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
190
- )
191
-
192
- <% end %>
193
-
194
- @endlocal
195
-
196
- @echo off
197
-
198
- <% if client_pem -%>
199
- > <%= bootstrap_directory %>\client.pem (
200
- <%= escape_and_echo(::File.read(::File.expand_path(client_pem))) %>
201
- )
202
- <% end -%>
203
-
204
- echo Writing validation key...
205
-
206
- <% if validation_key -%>
207
- > <%= bootstrap_directory %>\validation.pem (
208
- <%= escape_and_echo(validation_key) %>
209
- )
210
- <% end -%>
211
-
212
- echo Validation key written.
213
- @echo on
214
-
215
- <% if @config[:secret] -%>
216
- > <%= bootstrap_directory %>\encrypted_data_bag_secret (
217
- <%= secret %>
218
- )
219
- <% end -%>
220
-
221
- <% unless trusted_certs_script.empty? -%>
222
- mkdir <%= bootstrap_directory %>\trusted_certs
223
- <%= trusted_certs_script %>
224
- <% end -%>
225
-
226
- <%# Generate Ohai Hints -%>
227
- <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
228
- mkdir <%= bootstrap_directory %>\ohai\hints
229
-
230
- <% @chef_config[:knife][:hints].each do |name, hash| -%>
231
- > <%= bootstrap_directory %>\ohai\hints\<%= name %>.json (
232
- <%= escape_and_echo(hash.to_json) %>
233
- )
234
- <% end -%>
235
- <% end -%>
236
-
237
- > <%= bootstrap_directory %>\client.rb (
238
- <%= config_content %>
239
- )
240
-
241
- > <%= bootstrap_directory %>\first-boot.json (
242
- <%= first_boot %>
243
- )
244
-
245
- @echo Starting chef to bootstrap the node...
246
- <%= start_chef %>