knife-windows 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecb337e248b812ce32f26edcf172c27d14f3b65c
4
- data.tar.gz: 743d0ff57967c01fbd00be60c31ad4bc3aa7bb0c
3
+ metadata.gz: 5625bfb426520967ee2d9b753db05b7b6ddda38f
4
+ data.tar.gz: cef98f088ca495ebcae6933d16cf804301ec6259
5
5
  SHA512:
6
- metadata.gz: 3265ed321b53251c71fc81239b67903016eed4f19a8ee743e116ddf50aae225b257ca2ff9adaa80a9c0dfeb2d94a8dd8af75c35c371cf3bf590bd98938bb6571
7
- data.tar.gz: c67d95887c01fc68e71f743a49ca35ac450a0b1228ac1062721d8dc1b72fd0f7efcc81019748872ab633d4be03af5e41e66d8edc6d67e972bf332d75dd785df4
6
+ metadata.gz: 76723402071d410413a8df53644db66d177c99490597271769be060eed66df819c591da80c67af08a74c5d755f7d3ff39ae13103259b668c3bc3b380721c653a
7
+ data.tar.gz: 576edbb29512e8b7d79c592c9af8ecb59b75215df4c18595d54d39c34c77b9828519253d8cc16042fb050cb213bf13128d386de1834a3a7e34f396c51e8705da
@@ -2,7 +2,7 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 2.1
5
- - 2.2
5
+ - 2.3
6
6
 
7
7
  before_install:
8
8
  - gem install bundler
@@ -1,5 +1,9 @@
1
1
  # knife-windows Change Log
2
2
 
3
+ ## Release 1.7.0
4
+
5
+ * [knife-windows #400](https://github.com/chef/knife-windows/pull/400) Allow a custom codepage to be specified and passed to the cmd shell
6
+
3
7
  ## Release 1.6.0
4
8
 
5
9
  * [knife-windows #393](https://github.com/chef/knife-windows/pull/393) Add documentation of the --msi-url option
data/Gemfile CHANGED
@@ -10,5 +10,4 @@ group :test do
10
10
  gem "ruby-wmi"
11
11
  gem "httpclient"
12
12
  gem 'rake'
13
- gem "rack", "< 2.0" # 2.0 requires Ruby 2.2+
14
13
  end
data/README.md CHANGED
@@ -17,7 +17,7 @@ This plugin provides the following Knife subcommands. Specific command options c
17
17
 
18
18
  ### knife winrm
19
19
 
20
- The `winrm` subcommand allows you to invoke commands in parallel on a subset of the nodes in your infrastructure. The `winrm` subcommand uses the same syntax as the [search subcommand](https://docs.chef.io/knife_search.html); you could could find the uptime of all your web servers using the command:
20
+ The `winrm` subcommand allows you to invoke commands in parallel on a subset of the nodes in your infrastructure. The `winrm` subcommand uses the same syntax as the [search subcommand](https://docs.chef.io/knife_search.html); you could find the uptime of all your web servers using the command:
21
21
 
22
22
  knife winrm "role:web" "net stats srv" -x Administrator -P 'super_secret_password'
23
23
 
@@ -217,6 +217,10 @@ of these authentication transports are outside of the scope of this
217
217
  README but details can be found on the
218
218
  [WinRM configuration guide](http://msdn.microsoft.com/en-us/library/aa384372\(v=vs.85\).aspx).
219
219
 
220
+ ### Working with legacy Windows versions
221
+
222
+ If you are attempting to use `knife winrm` or `knife bootstrap windows winrm` with a version of windows that is older than server 2008 R2 or older than Windows 7 then you may need to alter the default UTF-8 codepage (65001) using the `--winrm-codepage` argument. You can use the codepage native to your locale but `437` is a safe codepage for older Windows versions.
223
+
220
224
  #### Configure SSL on a Windows node
221
225
 
222
226
  WinRM supports use of SSL to provide privacy and integrity of
@@ -11,10 +11,10 @@ environment:
11
11
  - ruby_version: "20"
12
12
  chef_version: "< 12"
13
13
 
14
- - ruby_version: "21"
14
+ - ruby_version: "23"
15
15
  chef_version: "~> 12.0"
16
16
 
17
- - ruby_version: "21"
17
+ - ruby_version: "23"
18
18
  chef_version: "master"
19
19
 
20
20
  clone_folder: c:\projects\knife-windows
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.description = s.summary
15
15
 
16
16
  s.required_ruby_version = ">= 1.9.1"
17
+ s.add_dependency "winrm", "~> 2.1"
17
18
  s.add_dependency "winrm-elevated", "~> 1.0"
18
19
 
19
20
  s.add_development_dependency 'pry'
@@ -116,6 +116,11 @@ class Chef
116
116
  :long => "--session-timeout Minutes",
117
117
  :description => "The timeout for the client for the maximum length of the WinRM session",
118
118
  :default => 30
119
+
120
+ option :winrm_codepage,
121
+ :long => "--winrm-codepage Codepage",
122
+ :description => "The codepage to use for the winrm cmd shell",
123
+ :default => 65001
119
124
  end
120
125
  end
121
126
  end
@@ -202,7 +202,8 @@ class Chef
202
202
  transport: resolve_winrm_transport,
203
203
  no_ssl_peer_verification: resolve_no_ssl_peer_verification,
204
204
  ssl_peer_fingerprint: resolve_ssl_peer_fingerprint,
205
- shell: locate_config_value(:winrm_shell)
205
+ shell: locate_config_value(:winrm_shell),
206
+ codepage: locate_config_value(:winrm_codepage)
206
207
  }
207
208
 
208
209
  if @session_opts[:user] and (not @session_opts[:password])
@@ -31,7 +31,8 @@ class Chef
31
31
  @host = options[:host]
32
32
  @port = options[:port]
33
33
  @user = options[:user]
34
- @shell = options[:shell]
34
+ @shell_args = [ options[:shell] ]
35
+ @shell_args << { codepage: options[:codepage] } if options[:shell] == :cmd
35
36
  url = "#{options[:host]}:#{options[:port]}/wsman"
36
37
  scheme = options[:transport] == :ssl ? 'https' : 'http'
37
38
  @endpoint = "#{scheme}://#{url}"
@@ -63,7 +64,7 @@ class Chef
63
64
 
64
65
  def relay_command(command)
65
66
  session_result = WinRM::Output.new
66
- @winrm_session.shell(@shell) do |shell|
67
+ @winrm_session.shell(*@shell_args) do |shell|
67
68
  shell.username = @user.split("\\").last if shell.respond_to?(:username)
68
69
  session_result = shell.run(command) do |stdout, stderr|
69
70
  print_data(@host, stdout) if stdout
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Windows
3
- VERSION = "1.6.0"
3
+ VERSION = "1.7.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -67,5 +67,29 @@ describe Chef::Knife::WinrmSession do
67
67
  expect(winrm_connection).to receive(:shell)
68
68
  subject.relay_command("cmd.exe echo 'hi'")
69
69
  end
70
+
71
+ context "cmd shell" do
72
+ before do
73
+ options[:shell] = :cmd
74
+ options[:codepage] = 65001
75
+ end
76
+
77
+ it "creates shell and sends codepage" do
78
+ expect(winrm_connection).to receive(:shell).with(:cmd, hash_including(codepage: 65001))
79
+ subject.relay_command("cmd.exe echo 'hi'")
80
+ end
81
+ end
82
+
83
+ context "powershell shell" do
84
+ before do
85
+ options[:shell] = :powershell
86
+ options[:codepage] = 65001
87
+ end
88
+
89
+ it "does not send codepage to shell" do
90
+ expect(winrm_connection).to receive(:shell).with(:powershell)
91
+ subject.relay_command("cmd.exe echo 'hi'")
92
+ end
93
+ end
70
94
  end
71
95
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-windows
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.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: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: winrm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: winrm-elevated
15
29
  requirement: !ruby/object:Gem::Requirement