knife-windows 0.5.8 → 0.5.10.rc.1
Sign up to get free protection for your applications and to get access to all the features.
data/knife-windows.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.description = s.summary
|
16
16
|
|
17
17
|
s.required_ruby_version = ">= 1.9.1"
|
18
|
-
s.add_dependency "em-winrm", "= 0.5.
|
18
|
+
s.add_dependency "em-winrm", "= 0.5.4.rc.1"
|
19
19
|
|
20
20
|
s.files = `git ls-files`.split("\n")
|
21
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -135,7 +135,11 @@ class Chef
|
|
135
135
|
# create a bootstrap.bat file on the node
|
136
136
|
# we have to run the remote commands in 2047 char chunks
|
137
137
|
create_bootstrap_bat_command do |command_chunk, chunk_num|
|
138
|
-
|
138
|
+
begin
|
139
|
+
run_command("cmd.exe /C echo \"Rendering '#{bootstrap_bat_file}' chunk #{chunk_num}\" && #{command_chunk}").run
|
140
|
+
rescue SystemExit => e
|
141
|
+
raise unless e.success?
|
142
|
+
end
|
139
143
|
end
|
140
144
|
|
141
145
|
# execute the bootstrap.bat file
|
@@ -79,7 +79,7 @@ CONFIG
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def start_chef
|
82
|
-
start_chef = "SET PATH=%PATH%;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\n"
|
82
|
+
start_chef = "SET \"PATH=%PATH%;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\"\n"
|
83
83
|
start_chef << "chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json -E #{bootstrap_environment}\n"
|
84
84
|
end
|
85
85
|
|
@@ -91,6 +91,7 @@ CONFIG
|
|
91
91
|
win_wget = <<-WGET
|
92
92
|
url = WScript.Arguments.Named("url")
|
93
93
|
path = WScript.Arguments.Named("path")
|
94
|
+
proxy = null
|
94
95
|
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
|
95
96
|
Set wshShell = CreateObject( "WScript.Shell" )
|
96
97
|
Set objUserVariables = wshShell.Environment("USER")
|
@@ -100,11 +101,17 @@ Set objUserVariables = wshShell.Environment("USER")
|
|
100
101
|
On Error Resume Next
|
101
102
|
|
102
103
|
If NOT (objUserVariables("HTTP_PROXY") = "") Then
|
103
|
-
|
104
|
+
proxy = objUserVariables("HTTP_PROXY")
|
104
105
|
|
105
106
|
'fall back to named arg
|
106
107
|
ElseIf NOT (WScript.Arguments.Named("proxy") = "") Then
|
107
|
-
|
108
|
+
proxy = WScript.Arguments.Named("proxy")
|
109
|
+
End If
|
110
|
+
|
111
|
+
If NOT isNull(proxy) Then
|
112
|
+
'setProxy method is only available on ServerXMLHTTP 6.0+
|
113
|
+
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
|
114
|
+
objXMLHTTP.setProxy 2, proxy
|
108
115
|
End If
|
109
116
|
|
110
117
|
On Error Goto 0
|
data/lib/chef/knife/winrm.rb
CHANGED
@@ -41,6 +41,13 @@ class Chef
|
|
41
41
|
:description => "The attribute to use for opening the connection - default is fqdn",
|
42
42
|
:default => "fqdn"
|
43
43
|
|
44
|
+
option :returns,
|
45
|
+
:long => "--returns CODES",
|
46
|
+
:description => "A comma delimited list of return codes which indicate success",
|
47
|
+
:default => nil,
|
48
|
+
:proc => Proc.new { |codes|
|
49
|
+
Chef::Config[:knife][:returns] = codes.split(',').collect {|item| item.to_i} }
|
50
|
+
|
44
51
|
option :manual,
|
45
52
|
:short => "-m",
|
46
53
|
:long => "--manual-list",
|
@@ -90,8 +97,8 @@ class Chef
|
|
90
97
|
list.each do |item|
|
91
98
|
Chef::Log.debug("Adding #{item}")
|
92
99
|
session_opts = {}
|
93
|
-
session_opts[:user] = Chef::Config[:knife][:winrm_user] || config[:winrm_user]
|
94
|
-
session_opts[:password] = Chef::Config[:knife][:winrm_password]
|
100
|
+
session_opts[:user] = config[:winrm_user] = Chef::Config[:knife][:winrm_user] || config[:winrm_user]
|
101
|
+
session_opts[:password] = config[:winrm_password] = Chef::Config[:knife][:winrm_password] || config[:winrm_password]
|
95
102
|
session_opts[:port] = Chef::Config[:knife][:winrm_port] || config[:winrm_port]
|
96
103
|
session_opts[:keytab] = Chef::Config[:knife][:kerberos_keytab_file] if Chef::Config[:knife][:kerberos_keytab_file]
|
97
104
|
session_opts[:realm] = Chef::Config[:knife][:kerberos_realm] if Chef::Config[:knife][:kerberos_realm]
|
@@ -99,12 +106,24 @@ class Chef
|
|
99
106
|
session_opts[:ca_trust_path] = Chef::Config[:knife][:ca_trust_file] if Chef::Config[:knife][:ca_trust_file]
|
100
107
|
session_opts[:operation_timeout] = 1800 # 30 min OperationTimeout for long bootstraps fix for KNIFE_WINDOWS-8
|
101
108
|
|
109
|
+
## If you have a \\ in your name you need to use NTLM domain authentication
|
110
|
+
if session_opts[:user].split("\\").length.eql?(2)
|
111
|
+
session_opts[:basic_auth_only] = false
|
112
|
+
else
|
113
|
+
session_opts[:basic_auth_only] = true
|
114
|
+
end
|
115
|
+
|
102
116
|
if config.keys.any? {|k| k.to_s =~ /kerberos/ }
|
103
117
|
session_opts[:transport] = :kerberos
|
104
118
|
session_opts[:basic_auth_only] = false
|
105
119
|
else
|
106
120
|
session_opts[:transport] = (Chef::Config[:knife][:winrm_transport] || config[:winrm_transport]).to_sym
|
107
|
-
session_opts[:
|
121
|
+
session_opts[:disable_sspi] = true
|
122
|
+
if session_opts[:user] and
|
123
|
+
(not session_opts[:password])
|
124
|
+
session_opts[:password] = Chef::Config[:knife][:winrm_password] = config[:winrm_password] = get_password
|
125
|
+
|
126
|
+
end
|
108
127
|
end
|
109
128
|
|
110
129
|
session.use(item, session_opts)
|
@@ -189,6 +208,17 @@ class Chef
|
|
189
208
|
end
|
190
209
|
end
|
191
210
|
|
211
|
+
def check_for_errors!(exit_codes)
|
212
|
+
|
213
|
+
exit_codes.each do |host, value|
|
214
|
+
unless Chef::Config[:knife][:returns].include? value.to_i
|
215
|
+
@exit_code = 1
|
216
|
+
ui.error "Failed to execute command on #{host} return code #{value}"
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
192
222
|
def run
|
193
223
|
STDOUT.sync = STDERR.sync = true
|
194
224
|
|
@@ -202,7 +232,13 @@ class Chef
|
|
202
232
|
interactive
|
203
233
|
else
|
204
234
|
winrm_command(@name_args[1..-1].join(" "))
|
235
|
+
|
236
|
+
if config[:returns]
|
237
|
+
check_for_errors! session.exit_codes
|
238
|
+
end
|
239
|
+
|
205
240
|
session.close
|
241
|
+
exit @exit_code || 0
|
206
242
|
end
|
207
243
|
rescue WinRM::WinRMHTTPTransportError => e
|
208
244
|
case e.message
|
metadata
CHANGED
@@ -1,39 +1,37 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-windows
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.10.rc.1
|
5
|
+
prerelease: 7
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Seth Chisamore
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-03-15 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: em-winrm
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70110195009760 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.5.
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.5.4.rc.1
|
24
22
|
type: :runtime
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70110195009760
|
25
|
+
description: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
|
26
|
+
with nodes running Microsoft Windows
|
27
|
+
email:
|
28
28
|
- schisamo@opscode.com
|
29
29
|
executables: []
|
30
|
-
|
31
30
|
extensions: []
|
32
|
-
|
33
|
-
extra_rdoc_files:
|
31
|
+
extra_rdoc_files:
|
34
32
|
- README.rdoc
|
35
33
|
- LICENSE
|
36
|
-
files:
|
34
|
+
files:
|
37
35
|
- .gitignore
|
38
36
|
- CHANGELOG
|
39
37
|
- Gemfile
|
@@ -52,30 +50,27 @@ files:
|
|
52
50
|
- lib/knife-windows/version.rb
|
53
51
|
homepage: https://github.com/opscode/knife-windows
|
54
52
|
licenses: []
|
55
|
-
|
56
53
|
post_install_message:
|
57
54
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
55
|
+
require_paths:
|
60
56
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
58
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
66
62
|
version: 1.9.1
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
64
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version:
|
65
|
+
requirements:
|
66
|
+
- - ! '>'
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.1
|
73
69
|
requirements: []
|
74
|
-
|
75
70
|
rubyforge_project:
|
76
71
|
rubygems_version: 1.8.10
|
77
72
|
signing_key:
|
78
73
|
specification_version: 3
|
79
|
-
summary: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
|
74
|
+
summary: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
|
75
|
+
with nodes running Microsoft Windows
|
80
76
|
test_files: []
|
81
|
-
|