knife-windows 0.8.0.rc.0 → 0.8.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.md +2 -0
- data/RELEASE_NOTES.md +6 -16
- data/lib/chef/knife/core/windows_bootstrap_context.rb +51 -1
- data/lib/chef/knife/winrm.rb +2 -1
- data/lib/knife-windows/version.rb +1 -1
- data/spec/unit/knife/winrm_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzZkYmVmZGQwY2Y4ZWRjNDNhYjMwYTI3ZTEzYzMwYmRkYjQ0OWJiZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjE5MzMwYWQ1ODNlMDNiMjRhMDMyZGU3YWJmNGZjZjg5MjQ0MDFkMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTdlOWZhZjliYjg0ZGQwZDk5N2NmOWUzMjE3ZTJiNTNjZGRhYTQwZDJiOGE3
|
10
|
+
ZTE4ZGRhZTU0ODJlNWM2YzNkOWZmNmFmMWMwOWJhMjEyYTcyYThjZGY3ZDQw
|
11
|
+
MzI2YzY4ZTNkZWY1OTA1ODQ0M2U1M2QxZTczMzQwZDc3YjRjM2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGU0MGRjNTE2YjFiMzMyMzRmOWVlNjM2ZTk3Nzg3NTYwYzhkNWNlMzQ3MWFl
|
14
|
+
Njc2MjdkYTUyNzhmMThkYTM0MjEyZDk2NmI1ODQ2ZWE5MjJkMWJhYmZjYjQ0
|
15
|
+
MGU0NzY0MzMzMWQ1NjhhYmUyOTMyNzljNGU5NDFmMWQ0MTcxNGE=
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
None.
|
5
5
|
|
6
6
|
## Latest release: 0.8.0
|
7
|
+
* [knife-windows #98](https://github.com/opscode/knife-windows/issues/96) Get winrm command exit code if it is not expected
|
8
|
+
* [knife-windows #96](https://github.com/opscode/knife-windows/issues/96) Fix break from OS patch KB2918614
|
7
9
|
* Update winrm-s dependency along with em-winrm and winrm dependencies
|
8
10
|
* Return failure codes from knife winrm even when `returns` is not set
|
9
11
|
* Support Windows negotiate authentication protocol when running knife on Windows
|
data/RELEASE_NOTES.md
CHANGED
@@ -11,8 +11,7 @@ This release of knife-windows enables the Windows negotiate protocol to be
|
|
11
11
|
used with the `winrm` and `bootstrap windows winrm` subcommands and also
|
12
12
|
contains bug fixes and dependency updates.
|
13
13
|
|
14
|
-
A thank you goes to contributor **Josh Mahowald** for contributing a fix
|
15
|
-
[KNIFE-450](https://tickets.opscode.com/browse/KNIFE-450).
|
14
|
+
A thank you goes to contributor **Josh Mahowald** for contributing a fix to return nonzero exit codes.
|
16
15
|
|
17
16
|
Issues with `knife-windows` should be reported in the ticketing system at
|
18
17
|
https://github.com/opscode/knife-windows/issues. Learn more about how you can
|
@@ -37,18 +36,9 @@ https://rubygems.org/gems/knife-windows
|
|
37
36
|
https://github.com/opscode/knife-windows
|
38
37
|
|
39
38
|
## Issues fixed in knife-windows 0.8.0
|
40
|
-
* [
|
41
|
-
* [
|
42
|
-
*
|
39
|
+
* [knife-windows #98](https://github.com/opscode/knife-windows/issues/96) Get winrm command exit code if it is not expected
|
40
|
+
* [knife-windows #96](https://github.com/opscode/knife-windows/issues/96) Fix break from OS patch KB2918614
|
41
|
+
* Update winrm-s dependency along with em-winrm and winrm dependencies
|
42
|
+
* Return failure codes from knife winrm even when `returns` is not set
|
43
|
+
* Support Windows negotiate authentication protocol when running knife on Windows
|
43
44
|
|
44
|
-
## knife-windows breaking changes
|
45
|
-
|
46
|
-
### Error status being returned from `winrm` and `bootstrap windows winrm` remote commands
|
47
|
-
|
48
|
-
Previously, `knife winrm` would always return an exit status of 0 if it was able to
|
49
|
-
execute a command on the remote node, regardless whether the command that it
|
50
|
-
invoked on the remote node returned a status of 0. It now returns a non-zero
|
51
|
-
exit code if the command's exit code was non-zero. This may cause failures in
|
52
|
-
scripts that use the `knife winrm` or `knife bootstrap windows winrm` commands
|
53
|
-
and check to see if the exit status of the command is successful (0). Such
|
54
|
-
scripts should be altered to ignore the exit status if the failure is truly non-fatal.
|
@@ -149,7 +149,9 @@ WGET_PS
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def install_chef
|
152
|
-
|
152
|
+
# The normal install command uses regular double quotes in
|
153
|
+
# the install command, so request such a string from install_command
|
154
|
+
install_chef = install_command('"') + "\n" + fallback_install_task_command
|
153
155
|
end
|
154
156
|
|
155
157
|
def bootstrap_directory
|
@@ -171,6 +173,54 @@ WGET_PS
|
|
171
173
|
def escape_and_echo(file_contents)
|
172
174
|
file_contents.gsub(/^(.*)$/, 'echo.\1').gsub(/([(<|>)^])/, '^\1')
|
173
175
|
end
|
176
|
+
|
177
|
+
private
|
178
|
+
|
179
|
+
def install_command(executor_quote)
|
180
|
+
"msiexec /qn /log #{executor_quote}%CHEF_CLIENT_MSI_LOG_PATH%#{executor_quote} /i #{executor_quote}%LOCAL_DESTINATION_MSI_PATH%#{executor_quote}"
|
181
|
+
end
|
182
|
+
|
183
|
+
def fallback_install_task_command
|
184
|
+
# This command will be executed by schtasks.exe in the batch
|
185
|
+
# code below. To handle tasks that contain arguments that
|
186
|
+
# need to be double quoted, schtasks allows the use of single
|
187
|
+
# quotes that will later be converted to double quotes
|
188
|
+
command = install_command('\'')
|
189
|
+
<<-EOH
|
190
|
+
@set MSIERRORCODE=!ERRORLEVEL!
|
191
|
+
@if ERRORLEVEL 1 (
|
192
|
+
@echo WARNING: Failed to install Chef Client MSI package in remote context with status code !MSIERRORCODE!.
|
193
|
+
@echo WARNING: This may be due to a defect in operating system update KB2918614: http://support.microsoft.com/kb/2918614
|
194
|
+
@set OLDLOGLOCATION="%CHEF_CLIENT_MSI_LOG_PATH%-fail.log"
|
195
|
+
@move "%CHEF_CLIENT_MSI_LOG_PATH%" "!OLDLOGLOCATION!" > NUL
|
196
|
+
@echo WARNING: Saving installation log of failure at !OLDLOGLOCATION!
|
197
|
+
@echo WARNING: Retrying installation with local context...
|
198
|
+
@schtasks /create /f /sc once /st 00:00:00 /tn chefclientbootstraptask /ru SYSTEM /rl HIGHEST /tr \"cmd /c #{command} & sleep 2 & waitfor /s %computername% /si chefclientinstalldone\"
|
199
|
+
|
200
|
+
@if ERRORLEVEL 1 (
|
201
|
+
@echo ERROR: Failed to create Chef Client installation scheduled task with status code !ERRORLEVEL! > "&2"
|
202
|
+
) else (
|
203
|
+
@echo Successfully created scheduled task to install Chef Client.
|
204
|
+
@schtasks /run /tn chefclientbootstraptask
|
205
|
+
@if ERRORLEVEL 1 (
|
206
|
+
@echo ERROR: Failed to execut Chef Client installation scheduled task with status code !ERRORLEVEL!. > "&2"
|
207
|
+
) else (
|
208
|
+
@echo Successfully started Chef Client installation scheduled task.
|
209
|
+
@echo Waiting for installation to complete -- this may take a few minutes...
|
210
|
+
waitfor chefclientinstalldone /t 600
|
211
|
+
if ERRORLEVEL 1 (
|
212
|
+
@echo ERROR: Timed out waiting for Chef Client package to install
|
213
|
+
) else (
|
214
|
+
@echo Finished waiting for Chef Client package to install.
|
215
|
+
)
|
216
|
+
@schtasks /delete /f /tn chefclientbootstraptask > NUL
|
217
|
+
)
|
218
|
+
)
|
219
|
+
) else (
|
220
|
+
@echo Successfully installed Chef Client package.
|
221
|
+
)
|
222
|
+
EOH
|
223
|
+
end
|
174
224
|
end
|
175
225
|
end
|
176
226
|
end
|
data/lib/chef/knife/winrm.rb
CHANGED
@@ -253,8 +253,9 @@ class Chef
|
|
253
253
|
def check_for_errors!(exit_codes)
|
254
254
|
|
255
255
|
exit_codes.each do |host, value|
|
256
|
+
Chef::Log.debug("Exit code found: #{value}")
|
256
257
|
unless success_return_codes.include? value.to_i
|
257
|
-
@exit_code =
|
258
|
+
@exit_code = value.to_i
|
258
259
|
ui.error "Failed to execute command on #{host} return code #{value}"
|
259
260
|
end
|
260
261
|
end
|
@@ -97,6 +97,22 @@ describe Chef::Knife::Winrm do
|
|
97
97
|
expect(exit_code).to be_zero
|
98
98
|
end
|
99
99
|
|
100
|
+
it "should exit the process with exact exit status if the command fails and returns config is set to 0" do
|
101
|
+
command_status = 510
|
102
|
+
@winrm.config[:returns] = "0"
|
103
|
+
Chef::Config[:knife][:returns] = [0]
|
104
|
+
allow(@winrm).to receive(:winrm_command).and_return(command_status)
|
105
|
+
session_mock = EventMachine::WinRM::Session.new
|
106
|
+
allow(EventMachine::WinRM::Session).to receive(:new).and_return(session_mock)
|
107
|
+
allow(session_mock).to receive(:exit_codes).and_return({"thishost" => command_status})
|
108
|
+
begin
|
109
|
+
@winrm.run
|
110
|
+
expect(0).to eq(510)
|
111
|
+
rescue Exception => e
|
112
|
+
expect(e.status).to eq(command_status)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
100
116
|
it "should exit the process with non-zero status if the command fails and returns config is set to 0" do
|
101
117
|
command_status = 1
|
102
118
|
@winrm.config[:returns] = "0,53"
|
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: 0.8.0.rc.
|
4
|
+
version: 0.8.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Chisamore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: winrm-s
|