knife-windows 3.0.17 → 4.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/bootstrap_windows_ssh.rb +3 -4
- data/lib/chef/knife/helpers/bootstrap_windows_base.rb +14 -21
- data/lib/chef/knife/helpers/winrm_base.rb +10 -23
- data/lib/chef/knife/helpers/winrm_knife_base.rb +22 -22
- data/lib/chef/knife/helpers/winrm_session.rb +1 -2
- data/lib/chef/knife/windows_cert_generate.rb +3 -3
- data/lib/chef/knife/windows_listener_create.rb +1 -1
- data/lib/chef/knife/winrm.rb +1 -3
- data/lib/knife-windows/version.rb +1 -1
- data/spec/spec_helper.rb +16 -1
- data/spec/unit/knife/winrm_spec.rb +7 -9
- data/spec/unit/knife/wsman_test_spec.rb +2 -1
- metadata +5 -18
- data/lib/chef/knife/helpers/knife_windows_base.rb +0 -34
- data/spec/assets/win_template_rendered_with_bootstrap_install_command.txt +0 -220
- data/spec/assets/win_template_rendered_with_bootstrap_install_command_on_13_client.txt +0 -220
- data/spec/assets/win_template_rendered_without_bootstrap_install_command.txt +0 -332
- data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt +0 -332
- data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_13_client.txt +0 -332
- data/spec/assets/win_template_unrendered.txt +0 -246
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Steven Murawski (<smurawski@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -37,6 +37,7 @@ describe Chef::Knife::WsmanTest do
|
|
37
37
|
allow(Chef::HTTP::DefaultSSLPolicy).to receive(:new)
|
38
38
|
.with(http_client_mock.ssl_config)
|
39
39
|
.and_return(ssl_policy)
|
40
|
+
subject.merge_configs
|
40
41
|
end
|
41
42
|
|
42
43
|
subject { Chef::Knife::WsmanTest.new(["-m", "localhost"]) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-windows
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Chisamore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '15.
|
19
|
+
version: '15.11'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '15.
|
26
|
+
version: '15.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: winrm
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,7 +78,6 @@ files:
|
|
78
78
|
- lib/chef/knife/bootstrap_windows_ssh.rb
|
79
79
|
- lib/chef/knife/bootstrap_windows_winrm.rb
|
80
80
|
- lib/chef/knife/helpers/bootstrap_windows_base.rb
|
81
|
-
- lib/chef/knife/helpers/knife_windows_base.rb
|
82
81
|
- lib/chef/knife/helpers/winrm_base.rb
|
83
82
|
- lib/chef/knife/helpers/winrm_knife_base.rb
|
84
83
|
- lib/chef/knife/helpers/winrm_session.rb
|
@@ -94,12 +93,6 @@ files:
|
|
94
93
|
- spec/assets/fake_trusted_certs/github.pem
|
95
94
|
- spec/assets/fake_trusted_certs/google.crt
|
96
95
|
- spec/assets/win_fake_trusted_cert_script.txt
|
97
|
-
- spec/assets/win_template_rendered_with_bootstrap_install_command.txt
|
98
|
-
- spec/assets/win_template_rendered_with_bootstrap_install_command_on_13_client.txt
|
99
|
-
- spec/assets/win_template_rendered_without_bootstrap_install_command.txt
|
100
|
-
- spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt
|
101
|
-
- spec/assets/win_template_rendered_without_bootstrap_install_command_on_13_client.txt
|
102
|
-
- spec/assets/win_template_unrendered.txt
|
103
96
|
- spec/data/client.d_00/00-foo.rb
|
104
97
|
- spec/data/client.d_00/foo/bar.rb
|
105
98
|
- spec/data/client.d_01/foo/bar.rb
|
@@ -123,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
116
|
requirements:
|
124
117
|
- - ">="
|
125
118
|
- !ruby/object:Gem::Version
|
126
|
-
version: 2.
|
119
|
+
version: 2.6.0
|
127
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
121
|
requirements:
|
129
122
|
- - ">="
|
@@ -140,12 +133,6 @@ test_files:
|
|
140
133
|
- spec/assets/fake_trusted_certs/github.pem
|
141
134
|
- spec/assets/fake_trusted_certs/google.crt
|
142
135
|
- spec/assets/win_fake_trusted_cert_script.txt
|
143
|
-
- spec/assets/win_template_rendered_with_bootstrap_install_command.txt
|
144
|
-
- spec/assets/win_template_rendered_with_bootstrap_install_command_on_13_client.txt
|
145
|
-
- spec/assets/win_template_rendered_without_bootstrap_install_command.txt
|
146
|
-
- spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt
|
147
|
-
- spec/assets/win_template_rendered_without_bootstrap_install_command_on_13_client.txt
|
148
|
-
- spec/assets/win_template_unrendered.txt
|
149
136
|
- spec/data/client.d_00/00-foo.rb
|
150
137
|
- spec/data/client.d_00/foo/bar.rb
|
151
138
|
- spec/data/client.d_01/foo/bar.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Aliasgar Batterywala (<aliasgar.batterywala@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "chef/knife"
|
20
|
-
|
21
|
-
class Chef
|
22
|
-
class Knife
|
23
|
-
module KnifeWindowsBase
|
24
|
-
|
25
|
-
def locate_config_value(key)
|
26
|
-
key = key.to_sym
|
27
|
-
value = config[key] || Chef::Config[:knife][key] || default_config[key]
|
28
|
-
Chef::Log.debug("Looking for key #{key} and found value #{value}")
|
29
|
-
value
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,220 +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
|
-
chef-client -o recipe[cbk1::rec2]
|
186
|
-
|
187
|
-
@endlocal
|
188
|
-
|
189
|
-
@echo off
|
190
|
-
|
191
|
-
|
192
|
-
echo Writing validation key...
|
193
|
-
|
194
|
-
|
195
|
-
echo Validation key written.
|
196
|
-
@echo on
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
> C:\chef\client.rb (
|
202
|
-
echo.chef_server_url "https://localhost:443"
|
203
|
-
echo.validation_client_name "chef-validator"
|
204
|
-
echo.file_cache_path "c:/chef/cache"
|
205
|
-
echo.file_backup_path "c:/chef/backup"
|
206
|
-
echo.cache_options ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
|
207
|
-
echo.# Using default node name ^(fqdn^)
|
208
|
-
echo.log_level :info
|
209
|
-
echo.log_location STDOUT
|
210
|
-
|
211
|
-
)
|
212
|
-
|
213
|
-
> C:\chef\first-boot.json (
|
214
|
-
echo.{"run_list":null}
|
215
|
-
)
|
216
|
-
|
217
|
-
@echo Starting chef to bootstrap the node...
|
218
|
-
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"
|
219
|
-
chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json
|
220
|
-
|
@@ -1,220 +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
|
-
chef-client -o recipe[cbk1::rec2]
|
186
|
-
|
187
|
-
@endlocal
|
188
|
-
|
189
|
-
@echo off
|
190
|
-
|
191
|
-
|
192
|
-
echo Writing validation key...
|
193
|
-
|
194
|
-
|
195
|
-
echo Validation key written.
|
196
|
-
@echo on
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
> C:\chef\client.rb (
|
202
|
-
echo.chef_server_url "https://localhost:443"
|
203
|
-
echo.validation_client_name "chef-validator"
|
204
|
-
echo.file_cache_path "c:/chef/cache"
|
205
|
-
echo.file_backup_path "c:/chef/backup"
|
206
|
-
echo.cache_options ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
|
207
|
-
echo.# Using default node name ^(fqdn^)
|
208
|
-
echo.log_level :info
|
209
|
-
echo.log_location STDOUT
|
210
|
-
|
211
|
-
)
|
212
|
-
|
213
|
-
> C:\chef\first-boot.json (
|
214
|
-
echo.{"run_list":null}
|
215
|
-
)
|
216
|
-
|
217
|
-
@echo Starting chef to bootstrap the node...
|
218
|
-
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"
|
219
|
-
chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json
|
220
|
-
|