knife-windows 0.6.0 → 0.8.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2UyYTQ5NDQwMTQ2Yzc2MTVkZDI3OGFiMTVjMjEyMmIxMmUxMWVkMw==
4
+ ODE4MTk3MDE3NGMxZTEyZWNkYjk5ODg1Y2Q2ZDg2YTNkNTQ5M2M1MA==
5
5
  data.tar.gz: !binary |-
6
- Nzk5OTk2NmYwYzBiNjQ3NGZiZmYyMjAxOGNjYmE1OWVhYzg4M2NiMw==
6
+ ZjFlZGMzMWZmZDNiZWVkOWQ5MTEzYTM1OTVmMjg0ZmRlZDlhZDgyZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzdlNDUwY2QyMGIwYzAzZmRlYjY0YmM4YjkxMmZjOGZkYjM0Yzg2YmQ5MWNh
10
- NDkwOGFlODhiZDRlZDc1NjZjMjY3YTA4YTRiNjJkMDQ5YmFmY2I1MDVmZTNi
11
- YTUyZGQ3M2Q4Njk4OWM0NGVhMDNhMTdlOTlmMjJjZjI4OGM0Y2M=
9
+ ODRlYmEzMmQ2Y2QxZGU5M2I2MTdiNjAwMjg5NmNiZDdlOTY1MjBkNDExYjY0
10
+ OGRjODhhMmMzNDg1NTRhYjI3YTRmNDkzNTBmMTVlNWZiNTk2MDRkNTNiZjdh
11
+ Mjg0YTNhZDYwOGUwM2JlMTFjNTYzZDg4NmQ2OGIxNzkzMTgwZjI=
12
12
  data.tar.gz: !binary |-
13
- MDgzZWFlNzQ3OWI3MjNkOWEyZmNlNmYyYTM4NTA0ZjYzOTJmZjc4MTQwMGVi
14
- ZWZkYTY2YmE5MmNhNThiYmY5MTZmMWM3NmM5Y2M2NmY3NGFlOTJhM2ExYjU1
15
- NTBhZTUxYjVmNzEyYmY1OTRmYjA3MWIyNDhkYmNhNTg2ODYzMjY=
13
+ ZDIyNmIxNjk0ZTc0NTg0NmQ2ZGM3ZTY2MGFlY2UzM2VhNWM2NjZhNWM1MzNm
14
+ MjI3MDE4YWQ5ODYwN2QzYzExNTEzZmJiNmJjNzdhZTc0ZmI1ZTFmOTQ0NDQy
15
+ NGNjNTVlMjMwOWU4Mzk3NjI3MTIxMjM2MmQ3YjNmYzA3MjNiOTA=
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --color
2
- -fs
3
-
1
+ --color
2
+ -fdocumentation
3
+
data/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # knife-windows Change Log
2
2
 
3
3
  ## Unreleased changes
4
+ None.
4
5
 
5
- None
6
+ ## Latest release: 0.8.0
7
+ * Update winrm-s dependency along with em-winrm and winrm dependencies
8
+ * Return failure codes from knife winrm even when `returns` is not set
9
+ * Support Windows negotiate authentication protocol when running knife on Windows
6
10
 
7
- ## Last Release: 0.6.0 (05/08/2014)
11
+ ## Release: 0.6.0 (05/08/2014)
8
12
 
9
13
  * [KNIFE-386](https://tickets.opscode.com/browse/KNIFE-386) Wait for a valid command response before bootstrapping over WinRM
10
14
  * [KNIFE-394](https://tickets.opscode.com/browse/KNIFE-394) Update em-winrm dependency
data/DOC_CHANGES.md CHANGED
@@ -6,37 +6,32 @@ Example Doc Change:
6
6
  Description of the required change.
7
7
  -->
8
8
 
9
- # knife-windows 0.6.0 doc changes:
10
-
11
- ### `--auth-timeout` option for bootstrap
12
- The `knife windows bootstrap` command has a new `--auth-timeout` option that
13
- takes a number of minutes as an argument. After the command has detected that
14
- the node to be bootstrapped has opened a port for the desired transport (e.g.
15
- WinRM), the command then tries to successfully execute a remote test command
16
- on the system to verify authentication and will retry for the number of minutes specified in the
17
- `--auth-timeout` option if an authentication error is received. This is
18
- particularly useful for nodes hosted by cloud providers that may open up ports before user
19
- identities that can be authenticated are configured on the system, or if the
20
- authentication subsystem's readiness lags that of transport readiness.
21
-
22
- If the `--auth-timeout` option is not specified, the default retry period is
23
- 25 minutes.
24
-
25
- This value is currently only honored when bootstrapping using the WinRM
26
- transport and is ignored when bootstrapping via ssh.
27
-
28
- ### New configuration option for `knife winrm`: `:suppress_auth_failure`
29
- The option `:suppress_auth_failure` may be configured in `knife.rb` to alter
30
- the behavior of the `knife winrm` subcommand's behavior when authentication
31
- fails:
32
-
33
- * When this option is not specified (the default case) or is configured as `false`, the `knife winrm`
34
- subcommand will return a process exit code of `100` if the command is able to
35
- connect to the WinRM transport on the remote system but fails to authenticate.
36
- * When this option is set to `true`, the exit status in the authentication
37
- failure case is `0`.
38
-
39
- The default behavior is retained for compatibility reasons. The ability to
40
- override it via the `:suppress_auth_failure` option is useful for automation that uses the `knife winrm` subcommand
41
- and needs to implement customized retry behavior when authentication fails.
9
+ # knife-windows 0.8.0 doc changes
10
+
11
+ ### Negotiate / NTLM authentication support
12
+ If `knife` is executed from a Windows system, it is no longer necessary to make
13
+ additional configuration of the WinRM listener on the remote node to enable
14
+ successful authentication from the workstation. It is sufficient to have a WinRM
15
+ listener on the remote node configured according to the operating system's `winrm
16
+ quickconfig` command default configuration because `knife-windows` now
17
+ supports the Windows negotiate protocol including NTLM authentication, which
18
+ matches the authentication requirements for the default WinRM listener configuration.
19
+
20
+ If `knife` is executed on a non-Windows system, certificate authentication or Kerberos
21
+ should be used instead via the `kerberos_service` and related options of the subcommands.
22
+
23
+ **NOTE**: In order to use NTLM / Negotiate to authenticate as the user
24
+ specified by the `--winrm-user` (`-x`) option, you must include the user's
25
+ Windows domain when specifying the user name using the format `domain\user`
26
+ where the backslash ('`\`') character separates the user from the domain. If
27
+ an account local to the node is being used to access, `.` may be used as the domain:
28
+
29
+ knife bootstrap windows winrm web1.cloudapp.net -r 'server::web' -x 'proddomain\webuser' -P 'super_secret_password'
30
+ knife bootstrap windows winrm db1.cloudapp.net -r 'server::db' -x '.\localadmin' -P 'super_secret_password'
31
+
32
+ For development and testing purposes, unencrypted traffic with Basic authentication can make it easier to test connectivity:
33
+
34
+ winrm set winrm/config/service @{AllowUnencrypted="true"}
35
+ winrm set winrm/config/service/auth @{Basic="true"}
36
+
42
37
 
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem "rspec"
7
+ gem "rspec", '~> 3.0'
8
8
  gem "ruby-wmi"
9
9
  gem "chef"
10
10
  gem 'rake'
data/README.md ADDED
@@ -0,0 +1,161 @@
1
+ Knife Windows Plugin
2
+ ====================
3
+
4
+ This plugin adds additional functionality to the Chef Knife CLI tool for
5
+ configuring/interacting with nodes running Microsoft Windows. The subcommands
6
+ should function on any system running Ruby 1.9.1+ but nodes being configured
7
+ via these subcommands require Windows Remote Management (WinRM) 1.0+.WinRM
8
+ allows you to call native objects in Windows. This includes, but is not
9
+ limited to, running batch scripts, powershell scripts and fetching WMI
10
+ variables. For more information on WinRM, please visit
11
+ [Microsoft's WinRM site](http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx).
12
+ You will want to familiarize yourself with (certain key aspects) of WinRM
13
+ because you will be writing scripts / running commands with this tool to get
14
+ you from specific point A to specific point B.
15
+
16
+ WinRM is built into Windows 7 and Windows Server 2008+. It can also be easily installed on older version of Windows, including:
17
+
18
+ * Windows Server 2003
19
+ * Windows Vista
20
+
21
+ More information can be found on [Microsoft Support article 968930](http://support.microsoft.com/?kbid=968930).
22
+
23
+ ## Subcommands
24
+
25
+ This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag
26
+
27
+ ### knife winrm
28
+
29
+ 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](http://wiki.opscode.com/display/chef/Search); you could could find the uptime of all your web servers using the command:
30
+
31
+ knife winrm "role:web" "net stats srv" -x Administrator -P 'super_secret_password'
32
+
33
+ Or force a chef run:
34
+
35
+ knife winrm 'ec2-50-xx-xx-124.compute-1.amazonaws.com' 'chef-client -c c:/chef/client.rb' -m -x Administrator -P 'super_secret_password'
36
+ ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:49 +0000] INFO: Starting Chef Run (Version 0.9.12)
37
+ ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:50 +0000] WARN: Node ip-0A502FFB has an empty run list.
38
+ ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Chef Run complete in 4.383966 seconds
39
+ ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: cleaning the checksum cache
40
+ ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Running report handlers
41
+ ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Report handlers complete
42
+
43
+ This subcommand operates in a manner similar to [knife ssh](http://wiki.opscode.com/display/chef/Knife#Knife-SSHSubcommand)...just leveraging the WinRM protocol for communication. It also include's `knife ssh`'s "[interactive session mode](http://wiki.opscode.com/display/chef/Knife#Knife-InteractiveMode)"
44
+
45
+ ### knife bootstrap windows winrm
46
+
47
+ Performs a Chef Bootstrap (via the WinRM protocol) on the target node. The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists. It is primarily intended for Chef Client systems that talk to a Chef server.
48
+
49
+ This subcommand operates in a manner similar to [knife bootstrap](http://wiki.opscode.com/display/chef/Knife+Bootstrap)...just leveraging the WinRM protocol for communication. An initial run_list for the node can also be passed to the subcommand. Example usage:
50
+
51
+ knife bootstrap windows winrm ec2-50-xx-xx-124.compute-1.amazonaws.com -r 'role[webserver],role[production]' -x Administrator -P 'super_secret_password'
52
+
53
+ ### knife bootstrap windows ssh
54
+
55
+ Performs a Chef Bootstrap (via the SSH protocol) on the target node. The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists. It is primarily intended for Chef Client systems that talk to a Chef server.
56
+
57
+ This subcommand assumes the SSH session will use the Windows native cmd.exe command shell vs a bash shell through an emulated cygwin layer. Most popular Windows based SSHd daemons like [freeSSHd](http://www.freesshd.com/) and [WinSSHD](http://www.bitvise.com/winsshd) behave this way.
58
+
59
+ An initial run_list for the node can also be passed to the subcommand. Example usage:
60
+
61
+ knife bootstrap windows ssh ec2-50-xx-xx-124.compute-1.amazonaws.com -r 'role[webserver],role[production]' -x Administrator -i ~/.ssh/id_rsa
62
+
63
+ ## BOOTSTRAP TEMPLATES:
64
+
65
+ This gem provides the bootstrap template `windows-chef-client-msi`.
66
+
67
+ ### windows-chef-client-msi
68
+
69
+ This bootstrap template does the following:
70
+
71
+ * Installs the latest version of Chef (and all dependencies) using the `chef-client` msi.
72
+ * Writes the validation.pem per the local knife configuration.
73
+ * Writes a default config file for Chef (`C:\chef\client.rb`) using values from the `knife.rb`.
74
+ * Creates a JSON attributes file containing the specified run list and run Chef.
75
+
76
+ This is the default bootstrap template used by both the `windows bootstrap` subcommands.
77
+
78
+ ## REQUIREMENTS/SETUP:
79
+
80
+ ### Ruby
81
+
82
+ Ruby 1.9.1+ is needed.
83
+
84
+ ### Chef Version
85
+
86
+ Knife plugins require >= Chef 0.10. More details about Knife plugins can be [found on the Chef wiki](http://wiki.opscode.com/display/chef/Knife+Plugins).
87
+
88
+ ## Nodes
89
+
90
+ **NOTE**: Before any WinRM related knife subcommands will function correctly a node's WinRM installation must be configured correctly. The below settings should be added to your base server image (AMI) or passed in using some sort of user-data mechanism provided by your cloud provider.
91
+
92
+ A server running WinRM must also be configured properly to allow outside connections and the entire network path from the knife workstation to the server. The easiest way to accomplish this is to use [WinRM's quick configuration option](http://msdn.microsoft.com/en-us/library/aa384372(v=vs.85).aspx#quick_default_configuration):
93
+
94
+ winrm quickconfig -q
95
+
96
+ The Chef and Ohai gem installations (that occur during bootstrap) take more
97
+ memory than the default 150MB WinRM allocates per shell -- this can slow down
98
+ bootstrap. Optionally increase the memory limit to 300MB with the following command:
99
+
100
+ winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
101
+
102
+ Bootstrap commands can take longer than the WinRM default 60 seconds to
103
+ complete, optionally increase to 30 minutes if bootstrap terminates a command prematurely:
104
+
105
+ winrm set winrm/config @{MaxTimeoutms="1800000"}
106
+
107
+ WinRM supports both the HTTP and HTTPS transports and the following
108
+ authentication schemes: Kerberos, Digest, Certificate and Basic. The details
109
+ of these authentication transports are outside of the scope of this README but
110
+ details can be found on the
111
+ [WinRM configuration guide](http://msdn.microsoft.com/en-us/library/aa384372(v=vs.85).aspx).
112
+ Currently, this plugin support Kerberos and Basic authentication schemes on
113
+ all platform versions. The negotiate protocol which allows NTLM is fully
114
+ supported when `knife windows bootstrap` is executed on a Windows system; if
115
+ it is executed on a non-Windows system, certificate authentication or Kerberos
116
+ should be used instead via the `:kerberos_service` and related options of the subcommands.
117
+
118
+ **NOTE**: In order to use NTLM / Negotiate to authenticate as the user
119
+ specified by the `--winrm-user` (`-x`) option, you must include the user's
120
+ Windows domain when specifying the user name using the format `domain\user`
121
+ where the backslash ('`\`') character separates the user from the domain. If
122
+ an account local to the node is being used to access, `.` may be used as the domain:
123
+
124
+ knife bootstrap windows winrm web1.cloudapp.net -r 'server::web' -x 'proddomain\webuser' -P 'super_secret_password'
125
+ knife bootstrap windows winrm db1.cloudapp.net -r 'server::db' -x '.\localadmin' -P 'super_secret_password'
126
+
127
+ For development and testing purposes, unencrypted traffic with Basic authentication can make it easier to test connectivity:
128
+
129
+ winrm set winrm/config/service @{AllowUnencrypted="true"}
130
+ winrm set winrm/config/service/auth @{Basic="true"}
131
+
132
+ ## Troubleshooting
133
+
134
+ * When I run the winrm command I get: "Error: Invalid use of command line. Type "winrm -?" for help."
135
+ You're running the winrm command from PowerShell and you need to put the key/value pair in single quotes. For example:
136
+
137
+ winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
138
+
139
+ ## CONTRIBUTING:
140
+
141
+ Please file bugs against the KNIFE_WINDOWS project at https://github.com/opscode/knife-windows/issues.
142
+
143
+ More information on the contribution process for Opscode projects can be found in the [Chef Contributions document](http://docs.opscode.com/community_contributions.html).
144
+
145
+ # LICENSE:
146
+
147
+ Author:: Seth Chisamore (<schisamo@opscode.com>)
148
+ Copyright:: Copyright (c) 2014 Opscode, Inc.
149
+ License:: Apache License, Version 2.0
150
+
151
+ Licensed under the Apache License, Version 2.0 (the "License");
152
+ you may not use this file except in compliance with the License.
153
+ You may obtain a copy of the License at
154
+
155
+ http://www.apache.org/licenses/LICENSE-2.0
156
+
157
+ Unless required by applicable law or agreed to in writing, software
158
+ distributed under the License is distributed on an "AS IS" BASIS,
159
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
160
+ See the License for the specific language governing permissions and
161
+ limitations under the License.
data/RELEASE_NOTES.md CHANGED
@@ -6,35 +6,49 @@ Example Note:
6
6
  ## Example Heading
7
7
  Details about the thing that changed that needs to get included in the Release Notes in markdown.
8
8
  -->
9
- # knife-windows 0.6.0 release notes:
10
- This release of knife-windows addresses issues with reliability of winrm
11
- readiness detection during Windows bootstrap, exit codes in command execution
12
- scenarios, and gem dependencies.
9
+ # knife-windows 0.8.0 release notes:
10
+ This release of knife-windows enables the Windows negotiate protocol to be
11
+ used with the `winrm` and `bootstrap windows winrm` subcommands and also
12
+ contains bug fixes and dependency updates.
13
+
14
+ A thank you goes to contributor **Josh Mahowald** for contributing a fix for
15
+ [KNIFE-450](https://tickets.opscode.com/browse/KNIFE-450).
13
16
 
14
- Special thanks to **Okezie Eze** for the helpful bug report in KNIFE-386.
15
17
  Issues with `knife-windows` should be reported in the ticketing system at
16
- https://tickets.opscode.com/browse/KNIFE. Learn more about how you can
17
- contribute features and bug fixes to `knife-windows` at https://wiki.opscode.com/display/chef/How+to+Contribute.
18
+ https://github.com/opscode/knife-windows/issues. Learn more about how you can
19
+ contribute features and bug fixes to `knife-windows` in the [Chef Contributions document](http://docs.opscode.com/community_contributions.html).
20
+
21
+ ## Features added in knife-windows 0.8.0
18
22
 
19
- ## Features added in knife-windows 0.6.0
23
+ ### NTLM / Negotiate authentication for `winrm` and `bootstrap`
24
+ If `knife` is being used on a Windows workstation, it is no longer necessary
25
+ to use Kerberos or to use certificate authentication to authenticate securely
26
+ with a remote node in bootstrap or command execution scenarios. The `knife winrm` and `knife
27
+ windows bootstrap` commands now support the use of NTLM to authenticate to remote
28
+ nodes with the default WinRM listener configuration set by the operating
29
+ system's `winrm quickconfig` command.
20
30
 
21
- ### `--auth-timeout` option for bootstrap
22
- The `knife windows bootstrap` command has an `--auth-timeout` option that
23
- takes as an argument a number of minutes that specifies the time period during
24
- which to retry authentication attempts to WinRM when boostrapping a remote
25
- node via WinRM. By default, the value is 25 minutes. This retry behavior during bootstrap addresses issues that arise on
26
- some cloud providers where the authentication system is not ready until
27
- some time after WinRM is ready.
31
+ When specifying the user name on the command-line or configuration, the format `domain\username` must be used for
32
+ the negotiate protocol to be invoked. If the account is local to the node,
33
+ '`.`' may be used for the domain. See the README.md for further detail.
28
34
 
29
35
  ## knife-windows on RubyGems and Github
30
36
  https://rubygems.org/gems/knife-windows
31
37
  https://github.com/opscode/knife-windows
32
38
 
33
- ## Issues fixed in knife-windows 0.6.0
39
+ ## Issues fixed in knife-windows 0.8.0
34
40
  * [KNIFE-386](https://tickets.opscode.com/browse/KNIFE-386) Wait for a valid command response before bootstrapping over WinRM
35
41
  * [KNIFE-394](https://tickets.opscode.com/browse/KNIFE-394) Update em-winrm dependency
36
42
  * [KNIFE-450](https://tickets.opscode.com/browse/KNIFE-450) Set knife winrm command exit status on exception and command failure
37
43
 
38
- ## knife-windows breaking changes:
44
+ ## knife-windows breaking changes
45
+
46
+ ### Error status being returned from `winrm` and `bootstrap windows winrm` remote commands
39
47
 
40
- None.
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.
@@ -6,16 +6,16 @@ Gem::Specification.new do |s|
6
6
  s.name = "knife-windows"
7
7
  s.version = Knife::Windows::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.has_rdoc = true
10
- s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
11
9
  s.authors = ["Seth Chisamore"]
12
10
  s.email = ["schisamo@opscode.com"]
11
+ s.license = "Apache-2.0"
13
12
  s.homepage = "https://github.com/opscode/knife-windows"
14
13
  s.summary = %q{Plugin that adds functionality to Chef's Knife CLI for configuring/interacting with nodes running Microsoft Windows}
15
14
  s.description = s.summary
16
15
 
17
16
  s.required_ruby_version = ">= 1.9.1"
18
- s.add_dependency "em-winrm", "~> 0.5", ">= 0.5.4"
17
+ s.add_dependency "winrm-s", "0.2.0.rc.0"
18
+ s.add_dependency "em-winrm", "0.6.0.rc.0"
19
19
 
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -41,6 +41,7 @@ class Chef
41
41
  bootstrap
42
42
  end
43
43
 
44
+
44
45
  def run_command(command = '')
45
46
  winrm = Chef::Knife::Winrm.new
46
47
  winrm.name_args = [ server_name, command ]
@@ -54,7 +55,11 @@ class Chef
54
55
  winrm.config[:manual] = true
55
56
  winrm.config[:winrm_port] = locate_config_value(:winrm_port)
56
57
  winrm.config[:suppress_auth_failure] = true
57
- winrm.config[:returns] = nil
58
+
59
+ #If you turn off the return flag, then winrm.run won't atually check and
60
+ #return the error
61
+ #codes. Otherwise, it ignores the return value of the server call.
62
+ winrm.config[:returns] = "0"
58
63
  winrm.run
59
64
  end
60
65
 
@@ -44,9 +44,7 @@ class Chef
44
44
  option :returns,
45
45
  :long => "--returns CODES",
46
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} }
47
+ :default => "0"
50
48
 
51
49
  option :manual,
52
50
  :short => "-m",
@@ -55,6 +53,7 @@ class Chef
55
53
  :description => "QUERY is a space separated list of servers",
56
54
  :default => false
57
55
 
56
+
58
57
  def session
59
58
  session_opts = {}
60
59
  session_opts[:logger] = Chef::Log.logger if Chef::Log.level == :debug
@@ -75,6 +74,12 @@ class Chef
75
74
 
76
75
  end
77
76
 
77
+ def success_return_codes
78
+ #Redundant if the CLI options parsing occurs
79
+ return [0] unless config[:returns]
80
+ return config[:returns].split(',').collect {|item| item.to_i}
81
+ end
82
+
78
83
  # TODO: Copied from Knife::Core:GenericPresenter. Should be extracted
79
84
  def extract_nested_value(data, nested_value_spec)
80
85
  nested_value_spec.split(".").each do |attr|
@@ -96,6 +101,7 @@ class Chef
96
101
  end
97
102
 
98
103
  def configure_session
104
+
99
105
  list = case config[:manual]
100
106
  when true
101
107
  @name_args[0].split(" ")
@@ -147,7 +153,14 @@ class Chef
147
153
  session_opts[:basic_auth_only] = false
148
154
  else
149
155
  session_opts[:transport] = (Chef::Config[:knife][:winrm_transport] || config[:winrm_transport]).to_sym
150
- session_opts[:disable_sspi] = true
156
+ if Chef::Platform.windows? and session_opts[:transport] == :plaintext
157
+ # windows - force only encrypted communication
158
+ require 'winrm-s'
159
+ session_opts[:transport] = :sspinegotiate
160
+ session_opts[:disable_sspi] = false
161
+ else
162
+ session_opts[:disable_sspi] = true
163
+ end
151
164
  if session_opts[:user] and
152
165
  (not session_opts[:password])
153
166
  session_opts[:password] = Chef::Config[:knife][:winrm_password] = config[:winrm_password] = get_password
@@ -240,7 +253,7 @@ class Chef
240
253
  def check_for_errors!(exit_codes)
241
254
 
242
255
  exit_codes.each do |host, value|
243
- unless Chef::Config[:knife][:returns].include? value.to_i
256
+ unless success_return_codes.include? value.to_i
244
257
  @exit_code = 1
245
258
  ui.error "Failed to execute command on #{host} return code #{value}"
246
259
  end
@@ -249,6 +262,7 @@ class Chef
249
262
  end
250
263
 
251
264
  def run
265
+
252
266
  STDOUT.sync = STDERR.sync = true
253
267
 
254
268
  begin
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Windows
3
- VERSION = "0.6.0"
3
+ VERSION = "0.8.0.rc.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -69,23 +69,23 @@ describe 'Knife::Windows::Core msi download functionality for knife Windows winr
69
69
  # Stub the bootstrap context and prevent config related sections
70
70
  # from being populated, i.e. chef installation and first chef
71
71
  # run sections
72
- @mock_bootstrap_context.stub(:validation_key).and_return("echo.validation_key")
73
- @mock_bootstrap_context.stub(:encrypted_data_bag_secret).and_return("echo.encrypted_data_bag_secret")
74
- @mock_bootstrap_context.stub(:config_content).and_return("echo.config_content")
75
- @mock_bootstrap_context.stub(:start_chef).and_return("echo.echo start_chef_command")
76
- @mock_bootstrap_context.stub(:run_list).and_return("echo.run_list")
77
- @mock_bootstrap_context.stub(:install_chef).and_return("echo.echo install_chef_command")
72
+ allow(@mock_bootstrap_context).to receive(:validation_key).and_return("echo.validation_key")
73
+ allow(@mock_bootstrap_context).to receive(:encrypted_data_bag_secret).and_return("echo.encrypted_data_bag_secret")
74
+ allow(@mock_bootstrap_context).to receive(:config_content).and_return("echo.config_content")
75
+ allow(@mock_bootstrap_context).to receive(:start_chef).and_return("echo.echo start_chef_command")
76
+ allow(@mock_bootstrap_context).to receive(:run_list).and_return("echo.run_list")
77
+ allow(@mock_bootstrap_context).to receive(:install_chef).and_return("echo.echo install_chef_command")
78
78
 
79
79
  # Change the directories where bootstrap files will be created
80
- @mock_bootstrap_context.stub(:bootstrap_directory).and_return(@temp_directory.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR))
81
- @mock_bootstrap_context.stub(:local_download_path).and_return(@local_file_download_destination.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR))
80
+ allow(@mock_bootstrap_context).to receive(:bootstrap_directory).and_return(@temp_directory.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR))
81
+ allow(@mock_bootstrap_context).to receive(:local_download_path).and_return(@local_file_download_destination.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR))
82
82
 
83
83
  # Prevent password prompt during bootstrap process
84
84
  @mock_winrm = Chef::Knife::Winrm.new
85
- @mock_winrm.stub(:get_password).and_return(nil)
86
- Chef::Knife::Winrm.stub(:new).and_return(@mock_winrm)
85
+ allow(@mock_winrm).to receive(:get_password).and_return(nil)
86
+ allow(Chef::Knife::Winrm).to receive(:new).and_return(@mock_winrm)
87
87
 
88
- Chef::Knife::Core::WindowsBootstrapContext.stub(:new).and_return(@mock_bootstrap_context)
88
+ allow(Chef::Knife::Core::WindowsBootstrapContext).to receive(:new).and_return(@mock_bootstrap_context)
89
89
  end
90
90
 
91
91
  it "downloads the chef-client MSI during winrm bootstrap" do
@@ -93,18 +93,18 @@ describe 'Knife::Windows::Core msi download functionality for knife Windows winr
93
93
  clean_test_case
94
94
 
95
95
  winrm_bootstrapper = Chef::Knife::BootstrapWindowsWinrm.new([ "127.0.0.1" ])
96
- winrm_bootstrapper.stub(:wait_for_remote_response)
96
+ allow(winrm_bootstrapper).to receive(:wait_for_remote_response)
97
97
  winrm_bootstrapper.config[:template_file] = @template_file_path
98
98
 
99
99
  # Execute the commands locally that would normally be executed via WinRM
100
- winrm_bootstrapper.stub(:run_command) do |command|
100
+ allow(winrm_bootstrapper).to receive(:run_command) do |command|
101
101
  system(command)
102
102
  end
103
103
 
104
104
  winrm_bootstrapper.run
105
105
 
106
106
  # Download should succeed
107
- download_succeeded?.should == true
107
+ expect(download_succeeded?).to be true
108
108
  end
109
109
  end
110
110
 
data/spec/spec_helper.rb CHANGED
@@ -55,8 +55,6 @@ end
55
55
 
56
56
 
57
57
  RSpec.configure do |config|
58
- config.treat_symbols_as_metadata_keys_with_true_values = true
59
-
60
58
  config.filter_run_excluding :windows_only => true unless windows?
61
59
  config.filter_run_excluding :windows_2012_only => true unless windows2012?
62
60
  end
@@ -56,9 +56,9 @@ describe Chef::Knife::BootstrapWindowsWinrm do
56
56
  @knife.merge_configs
57
57
  @knife.config[:template_file] = TEMPLATE_FILE
58
58
  @stdout = StringIO.new
59
- @knife.ui.stub(:stdout).and_return(@stdout)
59
+ allow(@knife.ui).to receive(:stdout).and_return(@stdout)
60
60
  @stderr = StringIO.new
61
- @knife.ui.stub(:stderr).and_return(@stderr)
61
+ allow(@knife.ui).to receive(:stderr).and_return(@stderr)
62
62
  end
63
63
 
64
64
  describe "specifying no_proxy with various entries" do
@@ -77,14 +77,14 @@ describe Chef::Knife::BootstrapWindowsWinrm do
77
77
  let(:setting) { "api.opscode.com" }
78
78
 
79
79
  it "renders the client.rb with a single FQDN no_proxy entry" do
80
- rendered_template.should match(%r{.*no_proxy\s*\"api.opscode.com\".*})
80
+ expect(rendered_template).to match(%r{.*no_proxy\s*\"api.opscode.com\".*})
81
81
  end
82
82
  end
83
83
  context "via --bootstrap-no-proxy multiple" do
84
84
  let(:setting) { "api.opscode.com,172.16.10.*" }
85
85
 
86
86
  it "renders the client.rb with comma-separated FQDN and wildcard IP address no_proxy entries" do
87
- rendered_template.should match(%r{.*no_proxy\s*"api.opscode.com,172.16.10.\*".*})
87
+ expect(rendered_template).to match(%r{.*no_proxy\s*"api.opscode.com,172.16.10.\*".*})
88
88
  end
89
89
  end
90
90
  end
@@ -26,59 +26,80 @@ describe Chef::Knife::BootstrapWindowsWinrm do
26
26
 
27
27
  before do
28
28
  # Kernel.stub(:sleep).and_return 10
29
- bootstrap.stub(:sleep).and_return 10
29
+ allow(bootstrap).to receive(:sleep).and_return(10)
30
30
  end
31
31
 
32
32
  after do
33
33
  # Kernel.unstub(:sleep)
34
- bootstrap.stub(:sleep).and_return 10
34
+ allow(bootstrap).to receive(:sleep).and_return(10)
35
35
  end
36
36
 
37
- let (:bootstrap) { Chef::Knife::BootstrapWindowsWinrm.new }
37
+ let (:bootstrap) { Chef::Knife::BootstrapWindowsWinrm.new(['winrm', '-d', 'windows-chef-client-msi', '-x', 'Administrator', 'localhost']) }
38
+
38
39
  let(:initial_fail_count) { 4 }
39
40
  it 'should retry if a 401 is received from WinRM' do
40
41
  call_result_sequence = Array.new(initial_fail_count) {lambda {raise WinRM::WinRMHTTPTransportError, '401'}}
41
42
  call_result_sequence.push(0)
42
- bootstrap.stub(:run_command).and_return(*call_result_sequence)
43
+ allow(bootstrap).to receive(:run_command).and_return(*call_result_sequence)
43
44
 
44
- bootstrap.should_receive(:run_command).exactly(call_result_sequence.length).times
45
+ expect(bootstrap).to receive(:run_command).exactly(call_result_sequence.length).times
45
46
  bootstrap.send(:wait_for_remote_response, 2)
46
47
  end
47
48
 
48
49
  it 'should retry if something other than a 401 is received from WinRM' do
49
50
  call_result_sequence = Array.new(initial_fail_count) {lambda {raise WinRM::WinRMHTTPTransportError, '500'}}
50
51
  call_result_sequence.push(0)
51
- bootstrap.stub(:run_command).and_return(*call_result_sequence)
52
+ allow(bootstrap).to receive(:run_command).and_return(*call_result_sequence)
52
53
 
53
- bootstrap.should_receive(:run_command).exactly(call_result_sequence.length).times
54
+ expect(bootstrap).to receive(:run_command).exactly(call_result_sequence.length).times
54
55
  bootstrap.send(:wait_for_remote_response, 2)
55
56
  end
56
57
 
57
58
  it 'should have a wait timeout of 25 minutes by default' do
58
- bootstrap.stub(:run_command).and_raise WinRM::WinRMHTTPTransportError
59
- bootstrap.stub(:create_bootstrap_bat_command).and_raise SystemExit
60
- bootstrap.should_receive(:wait_for_remote_response).with(25)
61
- bootstrap.stub(:validate_name_args!).and_return(nil)
59
+ allow(bootstrap).to receive(:run_command).and_raise(WinRM::WinRMHTTPTransportError)
60
+ allow(bootstrap).to receive(:create_bootstrap_bat_command).and_raise(SystemExit)
61
+ expect(bootstrap).to receive(:wait_for_remote_response).with(25)
62
+ allow(bootstrap).to receive(:validate_name_args!).and_return(nil)
62
63
  bootstrap.config[:auth_timeout] = bootstrap.options[:auth_timeout][:default]
63
- expect { bootstrap.bootstrap }.to raise_error SystemExit
64
+ expect { bootstrap.bootstrap }.to raise_error(SystemExit)
64
65
  end
65
66
 
66
67
  it 'should keep retrying at 10s intervals if the timeout in minutes has not elapsed' do
67
68
  call_result_sequence = Array.new(initial_fail_count) {lambda {raise WinRM::WinRMHTTPTransportError, '500'}}
68
69
  call_result_sequence.push(0)
69
- bootstrap.stub(:run_command).and_return(*call_result_sequence)
70
+ allow(bootstrap).to receive(:run_command).and_return(*call_result_sequence)
70
71
 
71
- bootstrap.should_receive(:run_command).exactly(call_result_sequence.length).times
72
+ expect(bootstrap).to receive(:run_command).exactly(call_result_sequence.length).times
72
73
  bootstrap.send(:wait_for_remote_response, 2)
73
74
  end
74
75
 
76
+ it "should exit bootstrap with non-zero status if the bootstrap fails" do
77
+ command_status = 1
78
+
79
+ #Stub out calls to create the session and just get the exit codes back
80
+ winrm_mock = Chef::Knife::Winrm.new
81
+ allow(Chef::Knife::Winrm).to receive(:new).and_return(winrm_mock)
82
+ allow(winrm_mock).to receive(:configure_session)
83
+ allow(winrm_mock).to receive(:winrm_command)
84
+ session_mock = EventMachine::WinRM::Session.new
85
+ allow(EventMachine::WinRM::Session).to receive(:new).and_return(session_mock)
86
+ allow(session_mock).to receive(:exit_codes).and_return({"thishost" => command_status})
87
+
88
+ #Skip over templating stuff and checking with the remote end
89
+ allow(bootstrap).to receive(:create_bootstrap_bat_command)
90
+ allow(bootstrap).to receive(:wait_for_remote_response)
91
+
92
+ expect { bootstrap.run_with_pretty_exceptions }.to raise_error(SystemExit) { |e| expect(e.status).to eq(command_status) }
93
+ end
94
+
95
+
75
96
  it 'should stop retrying if more than 25 minutes has elapsed' do
76
97
  times = [ Time.new(2014, 4, 1, 22, 25), Time.new(2014, 4, 1, 22, 51), Time.new(2014, 4, 1, 22, 52) ]
77
- Time.stub(:now).and_return(*times)
98
+ allow(Time).to receive(:now).and_return(*times)
78
99
  run_command_result = lambda {raise WinRM::WinRMHTTPTransportError, '401'}
79
- bootstrap.stub(:validate_name_args!).and_return(nil)
80
- bootstrap.stub(:run_command).and_return(run_command_result)
81
- bootstrap.should_receive(:run_command).exactly(1).times
100
+ allow(bootstrap).to receive(:validate_name_args!).and_return(nil)
101
+ allow(bootstrap).to receive(:run_command).and_return(run_command_result)
102
+ expect(bootstrap).to receive(:run_command).exactly(1).times
82
103
  bootstrap.config[:auth_timeout] = bootstrap.options[:auth_timeout][:default]
83
104
  expect { bootstrap.bootstrap }.to raise_error RuntimeError
84
105
  end
@@ -51,15 +51,15 @@ describe Chef::Knife::Winrm do
51
51
  context "when there are some hosts found but they do not have an attribute to connect with" do
52
52
  before do
53
53
  @knife.config[:manual] = false
54
- @query.stub(:search).and_return([[@node_foo, @node_bar]])
54
+ allow(@query).to receive(:search).and_return([[@node_foo, @node_bar]])
55
55
  @node_foo.automatic_attrs[:fqdn] = nil
56
56
  @node_bar.automatic_attrs[:fqdn] = nil
57
- Chef::Search::Query.stub(:new).and_return(@query)
57
+ allow(Chef::Search::Query).to receive(:new).and_return(@query)
58
58
  end
59
59
 
60
60
  it "should raise a specific error (KNIFE-222)" do
61
- @knife.ui.should_receive(:fatal).with(/does not have the required attribute/)
62
- @knife.should_receive(:exit).with(10)
61
+ expect(@knife.ui).to receive(:fatal).with(/does not have the required attribute/)
62
+ expect(@knife).to receive(:exit).with(10)
63
63
  @knife.configure_session
64
64
  end
65
65
  end
@@ -67,13 +67,13 @@ describe Chef::Knife::Winrm do
67
67
  context "when there are nested attributes" do
68
68
  before do
69
69
  @knife.config[:manual] = false
70
- @query.stub(:search).and_return([[@node_foo, @node_bar]])
71
- Chef::Search::Query.stub(:new).and_return(@query)
70
+ allow(@query).to receive(:search).and_return([[@node_foo, @node_bar]])
71
+ allow(Chef::Search::Query).to receive(:new).and_return(@query)
72
72
  end
73
73
 
74
74
  it "should use nested attributes (KNIFE-276)" do
75
75
  @knife.config[:attribute] = "ec2.public_hostname"
76
- @knife.stub(:session_from_list)
76
+ allow(@knife).to receive(:session_from_list)
77
77
  @knife.configure_session
78
78
 
79
79
  end
@@ -92,60 +92,90 @@ describe Chef::Knife::Winrm do
92
92
  end
93
93
 
94
94
  it "should return with 0 if the command succeeds" do
95
- @winrm.stub(:winrm_command).and_return(0)
95
+ allow(@winrm).to receive(:winrm_command).and_return(0)
96
96
  exit_code = @winrm.run
97
- exit_code.should == 0
98
- end
99
-
100
- it "should exit the process with 0 if the command fails and returns config is not set" do
101
- @winrm.stub(:winrm_command).and_return(1)
102
- exit_code = @winrm.run
103
- exit_code.should == 0
97
+ expect(exit_code).to be_zero
104
98
  end
105
99
 
106
100
  it "should exit the process with non-zero status if the command fails and returns config is set to 0" do
107
101
  command_status = 1
108
- @winrm.config[:returns] = [0,53]
102
+ @winrm.config[:returns] = "0,53"
109
103
  Chef::Config[:knife][:returns] = [0,53]
110
- @winrm.stub(:winrm_command).and_return(command_status)
111
- EventMachine::WinRM::Session.any_instance.stub(:exit_codes).and_return({"thishost" => command_status})
112
- expect { @winrm.run_with_pretty_exceptions }.to raise_error(SystemExit) { |e| e.status.should == command_status }
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
+ expect { @winrm.run_with_pretty_exceptions }.to raise_error(SystemExit) { |e| expect(e.status).to eq(command_status) }
113
109
  end
114
110
 
115
111
  it "should exit the process with a zero status if the command returns an expected non-zero status" do
116
112
  command_status = 53
117
113
  Chef::Config[:knife][:returns] = [0,53]
118
- @winrm.stub(:winrm_command).and_return(command_status)
119
- EventMachine::WinRM::Session.any_instance.stub(:exit_codes).and_return({"thishost" => command_status})
114
+ allow(@winrm).to receive(:winrm_command).and_return(command_status)
115
+ session_mock = EventMachine::WinRM::Session.new
116
+ allow(EventMachine::WinRM::Session).to receive(:new).and_return(session_mock)
117
+ allow(session_mock).to receive(:exit_codes).and_return({"thishost" => command_status})
120
118
  exit_code = @winrm.run
121
- exit_code.should == 0
119
+ expect(exit_code).to be_zero
122
120
  end
123
121
 
124
122
  it "should exit the process with a zero status if the command returns an expected non-zero status" do
125
123
  command_status = 53
126
124
  Chef::Config[:knife][:returns] = [0,53]
127
- @winrm.stub(:winrm_command).and_return(command_status)
128
- EventMachine::WinRM::Session.any_instance.stub(:exit_codes).and_return({"thishost" => command_status})
125
+ allow(@winrm).to receive(:winrm_command).and_return(command_status)
126
+ session_mock = EventMachine::WinRM::Session.new
127
+ allow(EventMachine::WinRM::Session).to receive(:new).and_return(session_mock)
128
+ allow(session_mock).to receive(:exit_codes).and_return({"thishost" => command_status})
129
129
  exit_code = @winrm.run
130
- exit_code.should == 0
130
+ expect(exit_code).to be_zero
131
131
  end
132
132
 
133
133
  it "should exit the process with 100 if command execution raises an exception other than 401" do
134
- @winrm.stub(:winrm_command).and_raise(WinRM::WinRMHTTPTransportError, '500')
135
- expect { @winrm.run_with_pretty_exceptions }.to raise_error(SystemExit) { |e| e.status.should == 100 }
134
+ allow(@winrm).to receive(:winrm_command).and_raise(WinRM::WinRMHTTPTransportError, '500')
135
+ expect { @winrm.run_with_pretty_exceptions }.to raise_error(SystemExit) { |e| expect(e.status).to eq(100) }
136
136
  end
137
137
 
138
138
  it "should exit the process with 100 if command execution raises a 401" do
139
- @winrm.stub(:winrm_command).and_raise(WinRM::WinRMHTTPTransportError, '401')
140
- expect { @winrm.run_with_pretty_exceptions }.to raise_error(SystemExit) { |e| e.status.should == 100 }
139
+ allow(@winrm).to receive(:winrm_command).and_raise(WinRM::WinRMHTTPTransportError, '401')
140
+ expect { @winrm.run_with_pretty_exceptions }.to raise_error(SystemExit) { |e| expect(e.status).to eq(100) }
141
141
  end
142
142
 
143
143
  it "should exit the process with 0 if command execution raises a 401 and suppress_auth_failure is set to true" do
144
144
  @winrm.config[:suppress_auth_failure] = true
145
- @winrm.stub(:winrm_command).and_raise(WinRM::WinRMHTTPTransportError, '401')
145
+ allow(@winrm).to receive(:winrm_command).and_raise(WinRM::WinRMHTTPTransportError, '401')
146
146
  exit_code = @winrm.run_with_pretty_exceptions
147
- exit_code.should == 401
147
+ expect(exit_code).to eq(401)
148
+ end
149
+
150
+ context "validate sspinegotiate transport option" do
151
+ before do
152
+ Chef::Config[:knife] = {:winrm_transport => :plaintext}
153
+ allow(@winrm).to receive(:winrm_command).and_return(0)
154
+ end
155
+
156
+ it "should have winrm opts transport set to sspinegotiate for windows" do
157
+ allow(Chef::Platform).to receive(:windows?).and_return(true)
158
+ allow(@winrm).to receive(:require).with('winrm-s').and_return(true)
159
+
160
+ expect(@winrm.session).to receive(:use).with("localhost", {:user=>"testuser", :password=>"testpassword", :port=>nil, :operation_timeout=>1800, :basic_auth_only=>true, :transport=>:sspinegotiate, :disable_sspi=>false})
161
+ exit_code = @winrm.run
162
+ end
163
+
164
+ it "should have winrm monkey patched for windows" do
165
+ allow(Chef::Platform).to receive(:windows?).and_return(true)
166
+ expect(@winrm).to receive(:require).with('winrm-s')
167
+
168
+ exit_code = @winrm.run
169
+ end
170
+
171
+ it "should not have winrm opts transport set to sspinegotiate for unix" do
172
+ allow(Chef::Platform).to receive(:windows?).and_return(false)
173
+
174
+ expect(@winrm.session).to receive(:use).with("localhost", {:user=>"testuser", :password=>"testpassword", :port=>nil, :operation_timeout=>1800, :basic_auth_only=>true, :transport=>:plaintext, :disable_sspi=>true})
175
+ exit_code = @winrm.run
176
+ end
148
177
  end
178
+
149
179
  end
150
180
  end
151
181
  end
metadata CHANGED
@@ -1,44 +1,50 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-windows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0.rc.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: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: em-winrm
14
+ name: winrm-s
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '0.5'
20
- - - ! '>='
17
+ - - '='
21
18
  - !ruby/object:Gem::Version
22
- version: 0.5.4
19
+ version: 0.2.0.rc.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ~>
24
+ - - '='
28
25
  - !ruby/object:Gem::Version
29
- version: '0.5'
30
- - - ! '>='
26
+ version: 0.2.0.rc.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: em-winrm
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
31
32
  - !ruby/object:Gem::Version
32
- version: 0.5.4
33
+ version: 0.6.0.rc.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.6.0.rc.0
33
41
  description: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
34
42
  with nodes running Microsoft Windows
35
43
  email:
36
44
  - schisamo@opscode.com
37
45
  executables: []
38
46
  extensions: []
39
- extra_rdoc_files:
40
- - README.rdoc
41
- - LICENSE
47
+ extra_rdoc_files: []
42
48
  files:
43
49
  - .gitignore
44
50
  - .rspec
@@ -47,7 +53,7 @@ files:
47
53
  - DOC_CHANGES.md
48
54
  - Gemfile
49
55
  - LICENSE
50
- - README.rdoc
56
+ - README.md
51
57
  - RELEASE_NOTES.md
52
58
  - Rakefile
53
59
  - features/knife_help.feature
@@ -68,7 +74,8 @@ files:
68
74
  - spec/unit/knife/bootstrap_windows_winrm_spec.rb
69
75
  - spec/unit/knife/winrm_spec.rb
70
76
  homepage: https://github.com/opscode/knife-windows
71
- licenses: []
77
+ licenses:
78
+ - Apache-2.0
72
79
  metadata: {}
73
80
  post_install_message:
74
81
  rdoc_options: []
@@ -81,9 +88,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
88
  version: 1.9.1
82
89
  required_rubygems_version: !ruby/object:Gem::Requirement
83
90
  requirements:
84
- - - ! '>='
91
+ - - ! '>'
85
92
  - !ruby/object:Gem::Version
86
- version: '0'
93
+ version: 1.3.1
87
94
  requirements: []
88
95
  rubyforge_project:
89
96
  rubygems_version: 2.1.11
@@ -99,4 +106,4 @@ test_files:
99
106
  - spec/unit/knife/bootstrap_template_spec.rb
100
107
  - spec/unit/knife/bootstrap_windows_winrm_spec.rb
101
108
  - spec/unit/knife/winrm_spec.rb
102
- has_rdoc: true
109
+ has_rdoc:
data/README.rdoc DELETED
@@ -1,134 +0,0 @@
1
- = Knife Windows Plugin
2
-
3
- = DESCRIPTION:
4
-
5
- This plugin adds additional functionality to the Chef Knife CLI tool for configuring/interacting with nodes running Microsoft Windows. The subcommands should function on any system running Ruby 1.9.1+ but nodes being configured via these subcommands require Windows Remote Management (WinRM) 1.0+. WinRM allows you to call native objects in Windows. This includes, but is not limited to, running batch scripts, powershell scripts and fetching WMI variables. For more information on WinRM, please visit {Microsoft's WinRM site}[http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx]. You will want to familiarize yourself with (certain key aspects) of WinRM because you will be {writing scripts/running commands} with this tool to get you from (specific point A) to (specific point B).
6
-
7
- WinRM is built into Windows 7 and Windows Server 2008+. It can also be easily installed in older version of Windows, including:
8
-
9
- * Windows XP
10
- * Windows Server 2003
11
- * Windows Vista
12
-
13
- More information can be found on {Microsoft Support article 968930}[http://support.microsoft.com/?kbid=968930].
14
-
15
- This subcommands in this plugin have been tested and verified to work on Windows Server 2008 R2.
16
-
17
- = SUBCOMMANDS:
18
-
19
- This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a --+help+ flag
20
-
21
- == knife winrm
22
-
23
- 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}[http://wiki.opscode.com/display/chef/Search]; you could could find the uptime of all your web servers using the command:
24
-
25
- % knife winrm "role:web" "net stats srv" -x Administrator -P 'super_secret_password'
26
-
27
- Or force a chef run:
28
-
29
- % knife winrm 'ec2-50-xx-xx-124.compute-1.amazonaws.com' 'chef-client -c c:/chef/client.rb' -m -x Administrator -P 'super_secret_password'
30
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:49 +0000] INFO: Starting Chef Run (Version 0.9.12)
31
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:50 +0000] WARN: Node ip-0A502FFB has an empty run list.
32
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Chef Run complete in 4.383966 seconds
33
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: cleaning the checksum cache
34
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Running report handlers
35
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Report handlers complete
36
-
37
- This subcommand operates in a very similar manner as {knife ssh}[http://wiki.opscode.com/display/chef/Knife#Knife-SSHSubcommand]...just leveraging the WinRM protocol for communication. It also include's +knife+ +ssh+'s "{interactive session mode}[http://wiki.opscode.com/display/chef/Knife#Knife-InteractiveMode]"
38
-
39
- == knife bootstrap windows winrm
40
-
41
- Performs a Chef Bootstrap (via the WinRM protocol) on the target node. The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists. It is primarily intended for Chef Client systems that talk to a Chef server.
42
-
43
- This subcommand operates in a very similar manner as {knife bootstrap}[http://wiki.opscode.com/display/chef/Knife+Bootstrap]...just leveraging the WinRM protocol for communication. An initial run_list for the node can also be passed to the subcommand. Example usage:
44
-
45
- knife bootstrap windows winrm ec2-50-xx-xx-124.compute-1.amazonaws.com -r 'role[webserver],role[production]' -x Administrator -P 'super_secret_password'
46
-
47
- == knife bootstrap windows ssh
48
-
49
- Performs a Chef Bootstrap (via the SSH protocol) on the target node. The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists. It is primarily intended for Chef Client systems that talk to a Chef server.
50
-
51
- This subcommand assumes the SSH session will use Windows native cmd.exe command shell vs a bash shell through an emulated cygwin layer. Most popular Windows based SSHd daemons like {freeSSHd}[http://www.freesshd.com/] and {WinSSHD}[http://www.bitvise.com/winsshd] behave this way.
52
-
53
- An initial run_list for the node can also be passed to the subcommand. Example usage:
54
-
55
- knife bootstrap windows ssh ec2-50-xx-xx-124.compute-1.amazonaws.com -r 'role[webserver],role[production]' -x Administrator -i ~/.ssh/id_rsa
56
-
57
- = BOOTSTRAP TEMPLATES:
58
-
59
- This gem provides the following bootstrap templates:
60
-
61
- == windows-chef-client-msi
62
-
63
- This bootstrap template does the following:
64
-
65
- * Installs the latest version of Chef (and all dependencies) using the `chef-client` msi.
66
- * Writes the validation.pem per the local knife configuration.
67
- * Writes a default config file for Chef (C:\chef\client.rb) using values from the +knife.rb+.
68
- * Creates a JSON attributes file containing the specified run list and run Chef.
69
-
70
- This is the default bootstrap template used by both the +windows+ +bootstrap+ subcommands.
71
-
72
- = REQUIREMENTS/SETUP:
73
-
74
- == Ruby
75
-
76
- Ruby 1.9.1+ is needed.
77
-
78
- == Chef Version
79
-
80
- Knife plugins require >= Chef 0.10. More details about Knife plugins can be {found on the Chef wiki}[http://wiki.opscode.com/display/chef/Knife+Plugins].
81
-
82
- == Nodes
83
-
84
- *NOTE*: Before any WinRM related knife subcommands will function correctly a node's WinRM installation must be configured correctly. The below settings should be added to your base server image (AMI) or passed in using some sort of user-data mechanism provided by your cloud provider.
85
-
86
- A server running WinRM must also be configured properly to allow outside connections and the entire network path from the knife workstation to the server. The easiest way to accomplish this is to use {WinRM's quick configuration option}[http://msdn.microsoft.com/en-us/library/aa384372(v=vs.85).aspx#quick_default_configuration]:
87
-
88
- C:\Users\Administrator> winrm quickconfig -q
89
-
90
- The Chef and Ohai gem installations (that occur during bootstrap) take more memory than the default 150MB WinRM allocates per shell. Bump it up to 300MB with the following setting:
91
-
92
- C:\Users\Administrator> winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
93
-
94
- Bootstrap commands can take longer than the WinRM default 60 seconds to complete, bump to 30 minutes:
95
-
96
- C:\Users\Administrator> winrm set winrm/config @{MaxTimeoutms="1800000"}
97
-
98
- WinRM supports both the HTTP and HTTPS transports and the following authentication schemes: Kerberos, Digest, Certificate and Basic. The details of these authentication transports are outside of the scope of this README but details can be found on the {WinRM configuration guide}[http://msdn.microsoft.com/en-us/library/aa384372(v=vs.85).aspx]. Currently, this plugin support Kerberos and Basic authentication schemes.
99
-
100
- For development and testing purposes, unencrypted traffic with Basic authentication can make things easier:
101
-
102
- C:\Users\Administrator> winrm set winrm/config/service @{AllowUnencrypted="true"}
103
- C:\Users\Administrator> winrm set winrm/config/service/auth @{Basic="true"}
104
-
105
- === Troubleshooting
106
-
107
- #### When I run the winrm command I get: "Error: Invalid use of command line. Type "winrm -?" for help."
108
- - You're running the winrm command from powershell and you need to put the key/value pair in single quotes. For example:
109
- ```
110
- winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
111
- ```
112
-
113
- = CONTRIBUTING:
114
-
115
- Please file bugs against the KNIFE_WINDOWS project at http://tickets.opscode.com/browse/knife
116
-
117
- More information on the contribution process for Opscode projects can be found at: http://wiki.opscode.com/display/chef/How+to+Contribute
118
- = LICENSE:
119
-
120
- Author:: Seth Chisamore (<schisamo@opscode.com>)
121
- Copyright:: Copyright (c) 2011 Opscode, Inc.
122
- License:: Apache License, Version 2.0
123
-
124
- Licensed under the Apache License, Version 2.0 (the "License");
125
- you may not use this file except in compliance with the License.
126
- You may obtain a copy of the License at
127
-
128
- http://www.apache.org/licenses/LICENSE-2.0
129
-
130
- Unless required by applicable law or agreed to in writing, software
131
- distributed under the License is distributed on an "AS IS" BASIS,
132
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133
- See the License for the specific language governing permissions and
134
- limitations under the License.