knife-windows 3.0.17 → 4.0.0
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 +4 -4
- data/lib/chef/knife/bootstrap_windows_ssh.rb +3 -4
- data/lib/chef/knife/helpers/bootstrap_windows_base.rb +14 -17
- 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/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 -6
- data/lib/chef/knife/helpers/knife_windows_base.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '00669322920507bee3df2da47e879305c6bce383935885fd36975738ea83e50b'
|
4
|
+
data.tar.gz: 8663a57c66f81c31d9664e3c4345adea612db89ca876f8b951f3d75391861a45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eabd372f0cf3fb8b82dcebef93fbaa51fae7b6417bbf3eb2d6b2d76a00c1dc25e1bb9c0f3242cc280c55fb20c6b1bb2a9ab32e0f16468f39ae88b3974ae3439
|
7
|
+
data.tar.gz: f5e0794d88d5e57bb0aee87212959fe3944b3d124cea70871693b2ccabdf7b980ac3ac5a8ca0c3ea1ecf1160e848de3e22ff0af113dc9e2caee6c4ffb46a3b52
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Chisamore (<schisamo@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");
|
@@ -42,13 +42,12 @@ class Chef
|
|
42
42
|
short: "-p PORT",
|
43
43
|
long: "--ssh-port PORT",
|
44
44
|
description: "The ssh port",
|
45
|
-
proc: Proc.new { |key|
|
45
|
+
proc: Proc.new { |key| key.strip }
|
46
46
|
|
47
47
|
option :ssh_gateway,
|
48
48
|
short: "-G GATEWAY",
|
49
49
|
long: "--ssh-gateway GATEWAY",
|
50
|
-
description: "The ssh gateway"
|
51
|
-
proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
|
50
|
+
description: "The ssh gateway"
|
52
51
|
|
53
52
|
option :forward_agent,
|
54
53
|
short: "-A",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Chisamore (<schisamo@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");
|
@@ -43,23 +43,19 @@ class Chef
|
|
43
43
|
|
44
44
|
option :bootstrap_version,
|
45
45
|
long: "--bootstrap-version VERSION",
|
46
|
-
description: "The version of Chef to install"
|
47
|
-
proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
|
46
|
+
description: "The version of Chef to install"
|
48
47
|
|
49
48
|
option :bootstrap_proxy,
|
50
49
|
long: "--bootstrap-proxy PROXY_URL",
|
51
|
-
description: "The proxy server for the node being bootstrapped"
|
52
|
-
proc: Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
|
50
|
+
description: "The proxy server for the node being bootstrapped"
|
53
51
|
|
54
52
|
option :bootstrap_no_proxy,
|
55
53
|
long: "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
|
56
|
-
description: "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode"
|
57
|
-
proc: Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
|
54
|
+
description: "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode"
|
58
55
|
|
59
56
|
option :bootstrap_install_command,
|
60
57
|
long: "--bootstrap-install-command COMMANDS",
|
61
|
-
description: "Custom command to install chef-client"
|
62
|
-
proc: Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
|
58
|
+
description: "Custom command to install chef-client"
|
63
59
|
|
64
60
|
option :bootstrap_template,
|
65
61
|
short: "-t TEMPLATE",
|
@@ -76,10 +72,11 @@ class Chef
|
|
76
72
|
option :hint,
|
77
73
|
long: "--hint HINT_NAME[=HINT_FILE]",
|
78
74
|
description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
|
79
|
-
proc: Proc.new { |h|
|
80
|
-
|
75
|
+
proc: Proc.new { |h, accumulator|
|
76
|
+
accumulator ||= {}
|
81
77
|
name, path = h.split("=")
|
82
|
-
|
78
|
+
accumulator[name] = path ? Chef::JSONCompat.parse(::File.read(path)) : {}
|
79
|
+
accumulator
|
83
80
|
}
|
84
81
|
|
85
82
|
option :first_boot_attributes,
|
@@ -151,12 +148,12 @@ class Chef
|
|
151
148
|
option :bootstrap_vault_item,
|
152
149
|
long: "--bootstrap-vault-item VAULT_ITEM",
|
153
150
|
description: 'A single vault and item to update as "vault:item"',
|
154
|
-
proc: Proc.new { |i|
|
151
|
+
proc: Proc.new { |i, accumulator|
|
155
152
|
(vault, item) = i.split(/:/)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
accumulator ||= {}
|
154
|
+
accumulator[vault] ||= []
|
155
|
+
accumulator[vault].push(item)
|
156
|
+
accumulator
|
160
157
|
}
|
161
158
|
|
162
159
|
option :policy_name,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Chisamore (<schisamo@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");
|
@@ -42,14 +42,12 @@ class Chef
|
|
42
42
|
short: "-x USERNAME",
|
43
43
|
long: "--winrm-user USERNAME",
|
44
44
|
description: "The WinRM username",
|
45
|
-
default: "Administrator"
|
46
|
-
proc: Proc.new { |key| Chef::Config[:knife][:winrm_user] = key }
|
45
|
+
default: "Administrator"
|
47
46
|
|
48
47
|
option :winrm_password,
|
49
48
|
short: "-P PASSWORD",
|
50
49
|
long: "--winrm-password PASSWORD",
|
51
|
-
description: "The WinRM password"
|
52
|
-
proc: Proc.new { |key| Chef::Config[:knife][:winrm_password] = key }
|
50
|
+
description: "The WinRM password"
|
53
51
|
|
54
52
|
option :winrm_shell,
|
55
53
|
long: "--winrm-shell SHELL",
|
@@ -61,42 +59,32 @@ class Chef
|
|
61
59
|
short: "-w TRANSPORT",
|
62
60
|
long: "--winrm-transport TRANSPORT",
|
63
61
|
description: "The WinRM transport type. Valid choices are [ssl, plaintext]",
|
64
|
-
default: "plaintext"
|
65
|
-
proc: Proc.new { |transport|
|
66
|
-
Chef::Config[:knife][:winrm_port] = "5986" if transport == "ssl"
|
67
|
-
Chef::Config[:knife][:winrm_transport] = transport
|
68
|
-
}
|
62
|
+
default: "plaintext"
|
69
63
|
|
70
64
|
option :winrm_port,
|
71
65
|
short: "-p PORT",
|
72
66
|
long: "--winrm-port PORT",
|
73
|
-
description: "The WinRM port, by default this is '5985' for 'plaintext' and '5986' for 'ssl' winrm transport"
|
74
|
-
default: "5985",
|
75
|
-
proc: Proc.new { |key| Chef::Config[:knife][:winrm_port] = key }
|
67
|
+
description: "The WinRM port, by default this is '5985' for 'plaintext' and '5986' for 'ssl' winrm transport"
|
76
68
|
|
77
69
|
option :kerberos_keytab_file,
|
78
70
|
short: "-T KEYTAB_FILE",
|
79
71
|
long: "--keytab-file KEYTAB_FILE",
|
80
|
-
description: "The Kerberos keytab file used for authentication"
|
81
|
-
proc: Proc.new { |keytab| Chef::Config[:knife][:kerberos_keytab_file] = keytab }
|
72
|
+
description: "The Kerberos keytab file used for authentication"
|
82
73
|
|
83
74
|
option :kerberos_realm,
|
84
75
|
short: "-R KERBEROS_REALM",
|
85
76
|
long: "--kerberos-realm KERBEROS_REALM",
|
86
|
-
description: "The Kerberos realm used for authentication"
|
87
|
-
proc: Proc.new { |realm| Chef::Config[:knife][:kerberos_realm] = realm }
|
77
|
+
description: "The Kerberos realm used for authentication"
|
88
78
|
|
89
79
|
option :kerberos_service,
|
90
80
|
short: "-S KERBEROS_SERVICE",
|
91
81
|
long: "--kerberos-service KERBEROS_SERVICE",
|
92
|
-
description: "The Kerberos service used for authentication"
|
93
|
-
proc: Proc.new { |service| Chef::Config[:knife][:kerberos_service] = service }
|
82
|
+
description: "The Kerberos service used for authentication"
|
94
83
|
|
95
84
|
option :ca_trust_file,
|
96
85
|
short: "-f CA_TRUST_FILE",
|
97
86
|
long: "--ca-trust-file CA_TRUST_FILE",
|
98
|
-
description: "The Certificate Authority (CA) trust file used for SSL transport"
|
99
|
-
proc: Proc.new { |trust| Chef::Config[:knife][:ca_trust_file] = trust }
|
87
|
+
description: "The Certificate Authority (CA) trust file used for SSL transport"
|
100
88
|
|
101
89
|
option :winrm_ssl_verify_mode,
|
102
90
|
long: "--winrm-ssl-verify-mode SSL_VERIFY_MODE",
|
@@ -111,8 +99,7 @@ class Chef
|
|
111
99
|
option :winrm_authentication_protocol,
|
112
100
|
long: "--winrm-authentication-protocol AUTHENTICATION_PROTOCOL",
|
113
101
|
description: "The authentication protocol used during WinRM communication. The supported protocols are #{WINRM_AUTH_PROTOCOL_LIST.join(",")}. Default is 'negotiate'.",
|
114
|
-
default: "negotiate"
|
115
|
-
proc: Proc.new { |protocol| Chef::Config[:knife][:winrm_authentication_protocol] = protocol }
|
102
|
+
default: "negotiate"
|
116
103
|
|
117
104
|
option :session_timeout,
|
118
105
|
long: "--session-timeout Minutes",
|
@@ -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");
|
@@ -19,7 +19,6 @@
|
|
19
19
|
require "chef/knife"
|
20
20
|
require_relative "winrm_base"
|
21
21
|
require_relative "winrm_shared_options"
|
22
|
-
require_relative "knife_windows_base"
|
23
22
|
require_relative "winrm_session"
|
24
23
|
|
25
24
|
class Chef
|
@@ -40,10 +39,9 @@ class Chef
|
|
40
39
|
|
41
40
|
include Chef::Knife::WinrmBase
|
42
41
|
include Chef::Knife::WinrmSharedOptions
|
43
|
-
include Chef::Knife::KnifeWindowsBase
|
44
42
|
|
45
43
|
def validate_winrm_options!
|
46
|
-
winrm_auth_protocol =
|
44
|
+
winrm_auth_protocol = config[:winrm_authentication_protocol]
|
47
45
|
|
48
46
|
unless Chef::Knife::WinrmBase::WINRM_AUTH_PROTOCOL_LIST.include?(winrm_auth_protocol)
|
49
47
|
ui.error "Invalid value '#{winrm_auth_protocol}' for --winrm-authentication-protocol option."
|
@@ -121,7 +119,7 @@ class Chef
|
|
121
119
|
@session_results = []
|
122
120
|
queue = Queue.new
|
123
121
|
@winrm_sessions.each { |s| queue << s }
|
124
|
-
num_sessions =
|
122
|
+
num_sessions = config[:concurrency]
|
125
123
|
num_targets = @winrm_sessions.length
|
126
124
|
num_sessions = (num_sessions.nil? || num_sessions == 0) ? num_targets : [num_sessions, num_targets].min
|
127
125
|
|
@@ -147,7 +145,7 @@ class Chef
|
|
147
145
|
if authorization_error?(e)
|
148
146
|
unless config[:suppress_auth_failure]
|
149
147
|
# Display errors if the caller hasn't opted to retry
|
150
|
-
ui.error "Failed to authenticate to #{s.host} as #{
|
148
|
+
ui.error "Failed to authenticate to #{s.host} as #{config[:winrm_user]}"
|
151
149
|
ui.info "Response: #{e.message}"
|
152
150
|
ui.info get_failed_authentication_hint
|
153
151
|
raise e
|
@@ -203,33 +201,35 @@ class Chef
|
|
203
201
|
end
|
204
202
|
|
205
203
|
def resolve_session_options
|
204
|
+
config[:winrm_port] ||= ( config[:winrm_transport] == "ssl" ) ? "5986" : "5985"
|
205
|
+
|
206
206
|
@session_opts = {
|
207
207
|
user: resolve_winrm_user,
|
208
|
-
password:
|
209
|
-
port:
|
208
|
+
password: config[:winrm_password],
|
209
|
+
port: config[:winrm_port],
|
210
210
|
operation_timeout: resolve_winrm_session_timeout,
|
211
211
|
basic_auth_only: resolve_winrm_basic_auth,
|
212
212
|
disable_sspi: resolve_winrm_disable_sspi,
|
213
213
|
transport: resolve_winrm_transport,
|
214
214
|
no_ssl_peer_verification: resolve_no_ssl_peer_verification,
|
215
215
|
ssl_peer_fingerprint: resolve_ssl_peer_fingerprint,
|
216
|
-
shell:
|
217
|
-
codepage:
|
216
|
+
shell: config[:winrm_shell],
|
217
|
+
codepage: config[:winrm_codepage],
|
218
218
|
}
|
219
219
|
|
220
220
|
if @session_opts[:user] && (not @session_opts[:password])
|
221
|
-
@session_opts[:password] =
|
221
|
+
@session_opts[:password] = config[:winrm_password] = get_password
|
222
222
|
end
|
223
223
|
|
224
224
|
if @session_opts[:transport] == :kerberos
|
225
225
|
@session_opts.merge!(resolve_winrm_kerberos_options)
|
226
226
|
end
|
227
227
|
|
228
|
-
@session_opts[:ca_trust_path] =
|
228
|
+
@session_opts[:ca_trust_path] = config[:ca_trust_file] if config[:ca_trust_file]
|
229
229
|
end
|
230
230
|
|
231
231
|
def resolve_winrm_user
|
232
|
-
user =
|
232
|
+
user = config[:winrm_user]
|
233
233
|
|
234
234
|
# Prefixing with '.\' when using negotiate
|
235
235
|
# to auth user against local machine domain
|
@@ -245,23 +245,23 @@ class Chef
|
|
245
245
|
|
246
246
|
def resolve_winrm_session_timeout
|
247
247
|
# 30 min (Default) OperationTimeout for long bootstraps fix for KNIFE_WINDOWS-8
|
248
|
-
|
248
|
+
config[:session_timeout].to_i * 60 if config[:session_timeout]
|
249
249
|
end
|
250
250
|
|
251
251
|
def resolve_winrm_basic_auth
|
252
|
-
|
252
|
+
config[:winrm_authentication_protocol] == "basic"
|
253
253
|
end
|
254
254
|
|
255
255
|
def resolve_winrm_kerberos_options
|
256
256
|
kerberos_opts = {}
|
257
|
-
kerberos_opts[:keytab] =
|
258
|
-
kerberos_opts[:realm] =
|
259
|
-
kerberos_opts[:service] =
|
257
|
+
kerberos_opts[:keytab] = config[:kerberos_keytab_file] if config[:kerberos_keytab_file]
|
258
|
+
kerberos_opts[:realm] = config[:kerberos_realm] if config[:kerberos_realm]
|
259
|
+
kerberos_opts[:service] = config[:kerberos_service] if config[:kerberos_service]
|
260
260
|
kerberos_opts
|
261
261
|
end
|
262
262
|
|
263
263
|
def resolve_winrm_transport
|
264
|
-
transport =
|
264
|
+
transport = config[:winrm_transport].to_sym
|
265
265
|
if config.any? { |k, v| k.to_s =~ /kerberos/ && !v.nil? }
|
266
266
|
transport = :kerberos
|
267
267
|
elsif transport != :ssl && negotiate_auth?
|
@@ -272,11 +272,11 @@ class Chef
|
|
272
272
|
end
|
273
273
|
|
274
274
|
def resolve_no_ssl_peer_verification
|
275
|
-
|
275
|
+
config[:ca_trust_file].nil? && config[:winrm_ssl_verify_mode] == :verify_none && resolve_winrm_transport == :ssl
|
276
276
|
end
|
277
277
|
|
278
278
|
def resolve_ssl_peer_fingerprint
|
279
|
-
|
279
|
+
config[:ssl_peer_fingerprint]
|
280
280
|
end
|
281
281
|
|
282
282
|
def resolve_winrm_disable_sspi
|
@@ -288,7 +288,7 @@ class Chef
|
|
288
288
|
end
|
289
289
|
|
290
290
|
def negotiate_auth?
|
291
|
-
|
291
|
+
config[:winrm_authentication_protocol] == "negotiate"
|
292
292
|
end
|
293
293
|
|
294
294
|
def warn_no_ssl_peer_verification
|
data/lib/chef/knife/winrm.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Chisamore (<schisamo@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");
|
@@ -18,14 +18,12 @@
|
|
18
18
|
|
19
19
|
require "chef/knife"
|
20
20
|
require_relative "helpers/winrm_knife_base" # WinrmCommandSharedFunctions
|
21
|
-
require_relative "helpers/knife_windows_base"
|
22
21
|
|
23
22
|
class Chef
|
24
23
|
class Knife
|
25
24
|
class Winrm < Knife
|
26
25
|
|
27
26
|
include Chef::Knife::WinrmCommandSharedFunctions
|
28
|
-
include Chef::Knife::KnifeWindowsBase
|
29
27
|
|
30
28
|
deps do
|
31
29
|
require_relative "windows_cert_generate"
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
# Author:: Adam Edwards (<adamed@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");
|
@@ -22,7 +22,22 @@ def sample_data(file_name)
|
|
22
22
|
File.read(file)
|
23
23
|
end
|
24
24
|
|
25
|
+
class UnexpectedSystemExit < RuntimeError
|
26
|
+
def self.from(system_exit)
|
27
|
+
new(system_exit.message).tap { |e| e.set_backtrace(system_exit.backtrace) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
25
31
|
RSpec.configure do |config|
|
32
|
+
config.raise_on_warning = true
|
33
|
+
config.raise_errors_for_deprecations!
|
26
34
|
config.run_all_when_everything_filtered = true
|
27
35
|
config.filter_run focus: true
|
36
|
+
config.around(:example) do |ex|
|
37
|
+
begin
|
38
|
+
ex.run
|
39
|
+
rescue SystemExit => e
|
40
|
+
raise UnexpectedSystemExit.from(e)
|
41
|
+
end
|
42
|
+
end
|
28
43
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan <btm@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");
|
@@ -250,7 +250,7 @@ describe Chef::Knife::Winrm do
|
|
250
250
|
end
|
251
251
|
|
252
252
|
it "sets the user specified winrm port" do
|
253
|
-
|
253
|
+
winrm_command_http.config[:knife] = { winrm_port: "5988" }
|
254
254
|
expect(Chef::Knife::WinrmSession).to receive(:new).with(hash_including(transport: :plaintext)).and_call_original
|
255
255
|
expect(WinRM::Connection).to receive(:new).with(hash_including(transport: :plaintext)).and_return(winrm_connection)
|
256
256
|
winrm_command_http.configure_chef
|
@@ -269,7 +269,7 @@ describe Chef::Knife::Winrm do
|
|
269
269
|
let(:winrm_command_https) { Chef::Knife::Winrm.new(["-m", "localhost", "-x", "testuser", "-P", "testpassword", "--winrm-transport", "ssl", "echo helloworld"]) }
|
270
270
|
|
271
271
|
it "uses the https uri scheme if the ssl transport is specified" do
|
272
|
-
|
272
|
+
winrm_command_http.config[:winrm_transport] = "ssl"
|
273
273
|
expect(Chef::Knife::WinrmSession).to receive(:new).with(hash_including(transport: :ssl)).and_call_original
|
274
274
|
expect(WinRM::Connection).to receive(:new).with(hash_including(endpoint: "https://localhost:5986/wsman")).and_return(winrm_connection)
|
275
275
|
winrm_command_https.configure_chef
|
@@ -277,7 +277,7 @@ describe Chef::Knife::Winrm do
|
|
277
277
|
end
|
278
278
|
|
279
279
|
it "uses the winrm port '5986' by default for ssl transport" do
|
280
|
-
|
280
|
+
winrm_command_http.config[:winrm_transport] = "ssl"
|
281
281
|
expect(Chef::Knife::WinrmSession).to receive(:new).with(hash_including(transport: :ssl)).and_call_original
|
282
282
|
expect(WinRM::Connection).to receive(:new).with(hash_including(endpoint: "https://localhost:5986/wsman")).and_return(winrm_connection)
|
283
283
|
winrm_command_https.configure_chef
|
@@ -361,8 +361,8 @@ describe Chef::Knife::Winrm do
|
|
361
361
|
|
362
362
|
before(:each) do
|
363
363
|
allow(Chef::Knife::WinrmSession).to receive(:new).and_return(session)
|
364
|
-
Chef::Config[:knife] = { winrm_transport: "plaintext" }
|
365
364
|
@winrm = Chef::Knife::Winrm.new(["-m", "localhost", "-x", "testuser", "-P", "testpassword", "--winrm-authentication-protocol", "basic", "echo helloworld"])
|
365
|
+
@winrm.config[:winrm_transport] = "plaintext"
|
366
366
|
end
|
367
367
|
|
368
368
|
it "returns with 0 if the command succeeds" do
|
@@ -375,7 +375,6 @@ describe Chef::Knife::Winrm do
|
|
375
375
|
command_status = 510
|
376
376
|
|
377
377
|
@winrm.config[:returns] = "0"
|
378
|
-
Chef::Config[:knife][:returns] = [0]
|
379
378
|
|
380
379
|
allow(@winrm).to receive(:relay_winrm_command)
|
381
380
|
allow(@winrm.ui).to receive(:error)
|
@@ -386,7 +385,6 @@ describe Chef::Knife::Winrm do
|
|
386
385
|
it "exits with non-zero status if the command fails and returns config is set to 0" do
|
387
386
|
command_status = 1
|
388
387
|
@winrm.config[:returns] = "0,53"
|
389
|
-
Chef::Config[:knife][:returns] = [0, 53]
|
390
388
|
allow(@winrm).to receive(:relay_winrm_command).and_return(command_status)
|
391
389
|
allow(@winrm.ui).to receive(:error)
|
392
390
|
allow(session).to receive(:exit_code).and_return(command_status)
|
@@ -395,7 +393,7 @@ describe Chef::Knife::Winrm do
|
|
395
393
|
|
396
394
|
it "exits with a zero status if the command returns an expected non-zero status" do
|
397
395
|
command_status = 53
|
398
|
-
|
396
|
+
@winrm.config[:returns] = "0,53"
|
399
397
|
allow(@winrm).to receive(:relay_winrm_command).and_return(command_status)
|
400
398
|
allow(session).to receive(:exit_codes).and_return({ "thishost" => command_status })
|
401
399
|
exit_code = @winrm.run
|
@@ -448,7 +446,7 @@ describe Chef::Knife::Winrm do
|
|
448
446
|
|
449
447
|
context "when winrm_authentication_protocol specified" do
|
450
448
|
before do
|
451
|
-
|
449
|
+
@winrm.config[:winrm_transport] = "plaintext"
|
452
450
|
allow(@winrm).to receive(:relay_winrm_command).and_return(0)
|
453
451
|
end
|
454
452
|
|
@@ -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.0
|
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-05-
|
11
|
+
date: 2020-05-29 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
|
@@ -123,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
122
|
requirements:
|
124
123
|
- - ">="
|
125
124
|
- !ruby/object:Gem::Version
|
126
|
-
version: 2.
|
125
|
+
version: 2.6.0
|
127
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
127
|
requirements:
|
129
128
|
- - ">="
|
@@ -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
|