knife-windows 1.0.0.rc.1 → 1.0.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -5
  3. data/.travis.yml +20 -20
  4. data/CHANGELOG.md +75 -74
  5. data/DOC_CHANGES.md +323 -323
  6. data/Gemfile +12 -12
  7. data/LICENSE +201 -201
  8. data/README.md +393 -292
  9. data/RELEASE_NOTES.md +79 -74
  10. data/Rakefile +21 -16
  11. data/appveyor.yml +42 -42
  12. data/ci.gemfile +15 -15
  13. data/features/knife_help.feature +20 -20
  14. data/features/support/env.rb +5 -5
  15. data/knife-windows.gemspec +28 -28
  16. data/lib/chef/knife/bootstrap/windows-chef-client-msi.erb +247 -241
  17. data/lib/chef/knife/bootstrap_windows_base.rb +388 -368
  18. data/lib/chef/knife/bootstrap_windows_ssh.rb +110 -110
  19. data/lib/chef/knife/bootstrap_windows_winrm.rb +102 -113
  20. data/lib/chef/knife/core/windows_bootstrap_context.rb +361 -362
  21. data/lib/chef/knife/knife_windows_base.rb +33 -0
  22. data/lib/chef/knife/windows_cert_generate.rb +155 -155
  23. data/lib/chef/knife/windows_cert_install.rb +68 -68
  24. data/lib/chef/knife/windows_helper.rb +36 -36
  25. data/lib/chef/knife/windows_listener_create.rb +107 -107
  26. data/lib/chef/knife/winrm.rb +212 -191
  27. data/lib/chef/knife/winrm_base.rb +118 -125
  28. data/lib/chef/knife/winrm_knife_base.rb +218 -201
  29. data/lib/chef/knife/winrm_session.rb +80 -71
  30. data/lib/chef/knife/winrm_shared_options.rb +47 -47
  31. data/lib/chef/knife/wsman_endpoint.rb +44 -44
  32. data/lib/chef/knife/wsman_test.rb +96 -96
  33. data/lib/knife-windows/path_helper.rb +234 -234
  34. data/lib/knife-windows/version.rb +6 -6
  35. data/spec/assets/win_template_rendered_with_bootstrap_install_command.txt +217 -0
  36. data/spec/assets/win_template_rendered_without_bootstrap_install_command.txt +329 -0
  37. data/spec/assets/win_template_unrendered.txt +246 -0
  38. data/spec/functional/bootstrap_download_spec.rb +216 -140
  39. data/spec/spec_helper.rb +87 -72
  40. data/spec/unit/knife/bootstrap_options_spec.rb +146 -146
  41. data/spec/unit/knife/bootstrap_template_spec.rb +92 -92
  42. data/spec/unit/knife/bootstrap_windows_winrm_spec.rb +240 -161
  43. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +151 -101
  44. data/spec/unit/knife/windows_cert_generate_spec.rb +90 -90
  45. data/spec/unit/knife/windows_cert_install_spec.rb +51 -51
  46. data/spec/unit/knife/windows_listener_create_spec.rb +76 -76
  47. data/spec/unit/knife/winrm_session_spec.rb +55 -46
  48. data/spec/unit/knife/winrm_spec.rb +504 -376
  49. data/spec/unit/knife/wsman_test_spec.rb +175 -175
  50. metadata +28 -8
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in knife-windows.gemspec
4
- gemspec
5
-
6
- group :test do
7
- gem "chef"
8
- gem "rspec", '~> 3.0'
9
- gem "ruby-wmi"
10
- gem "httpclient"
11
- gem 'rake'
12
- end
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in knife-windows.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem "chef"
8
+ gem "rspec", '~> 3.0'
9
+ gem "ruby-wmi"
10
+ gem "httpclient"
11
+ gem 'rake'
12
+ end
data/LICENSE CHANGED
@@ -1,201 +1,201 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md CHANGED
@@ -1,292 +1,393 @@
1
- Knife Windows Plugin
2
- ====================
3
- [![Build Status Master](https://travis-ci.org/chef/knife-windows.svg?branch=master)](https://travis-ci.org/chef/knife-windows)
4
- [![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/knife-windows?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/knife-windows/branch/master)
5
-
6
- This plugin adds additional functionality to the Chef Knife CLI tool for
7
- configuring/interacting with nodes running Microsoft Windows. The subcommands
8
- should function on any system running Ruby 1.9.3+ but nodes being configured
9
- via these subcommands require Windows Remote Management (WinRM) 1.0+.WinRM
10
- allows you to call native objects in Windows. This includes, but is not
11
- limited to, running PowerShell scripts, batch scripts, and fetching WMI
12
- variables. For more information on WinRM, please visit
13
- [Microsoft's WinRM site](http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx).
14
- You will want to familiarize yourself with (certain key aspects) of WinRM
15
- because you will be writing scripts / running commands with this tool to get
16
- you from specific point A to specific point B.
17
-
18
- WinRM is built into Windows 7 and Windows Server 2008+. It can also be easily installed on older version of Windows, including:
19
-
20
- * Windows Server 2003
21
- * Windows Vista
22
-
23
- More information can be found on [Microsoft Support article 968930](http://support.microsoft.com/?kbid=968930).
24
-
25
- ## Subcommands
26
-
27
- This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag
28
-
29
- ### knife winrm
30
-
31
- 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:
32
-
33
- knife winrm "role:web" "net stats srv" -x Administrator -P 'super_secret_password'
34
-
35
- Or force a chef run:
36
-
37
- 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'
38
- 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)
39
- 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.
40
- 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
41
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: cleaning the checksum cache
42
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Running report handlers
43
- ec2-50-xx-xx-124.compute-1.amazonaws.com [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Report handlers complete
44
-
45
- This subcommand operates in a manner similar to [knife ssh](https://docs.chef.io/knife_ssh.html)...just leveraging the WinRM protocol for communication. It also include's `knife ssh`'s "[interactive session mode](https://docs.chef.io/knife_ssh.html#options)"
46
-
47
- ### knife wsman test
48
-
49
- Connects to the remote WSMan/WinRM endpoint and verifies the remote node is listening. This is the equivalent of running Test-Wsman from PowerShell. Endpoints to test can be specified manually, or be driven by search and use many of the same connection options as knife winrm.
50
- To test a single node using the default WinRM port (5985)
51
-
52
- knife wsman test 192.168.1.10 -m
53
-
54
- or to test a single node with SSL enabled on the default port (5986)
55
-
56
- knife wsman test 192.168.1.10 -m --winrm-transport ssl
57
-
58
- or to test all windows nodes registered with your Chef Server organization
59
-
60
- knife wsman test platform:windows
61
-
62
-
63
- ### knife bootstrap windows winrm
64
-
65
- 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.
66
-
67
- This subcommand operates in a manner similar to [knife bootstrap](https://docs.chef.io/knife_bootstrap.html)...just leveraging the WinRM protocol for communication. An initial run_list for the node can also be passed to the subcommand. Example usage:
68
-
69
- knife bootstrap windows winrm ec2-50-xx-xx-124.compute-1.amazonaws.com -r 'role[webserver],role[production]' -x Administrator -P 'super_secret_password'
70
-
71
- ### Use SSL for WinRM communication
72
-
73
- By default, the `knife winrm` and `knife bootstrap windows winrm` subcommands use a plaintext transport,
74
- but they support an option `--winrm-transport` (or `-t`) with the argument
75
- `ssl` that allows the SSL to secure the WinRM payload. Here's an example:
76
-
77
- knife winrm -t ssl "role:web" "net stats srv" -x Administrator -P 'super_secret_password'
78
-
79
- Use of SSL is strongly recommended, particularly when invoking `knife-windows` on non-Windows platforms, since
80
- without SSL there are limited options for ensuring the privacy of the
81
- plaintext transport. See the section on [Platform authentication
82
- support](#platform-winrm-authentication-support).
83
-
84
- SSL will become the default transport in future revisions of
85
- `knife-windows`.
86
-
87
- ### knife bootstrap windows ssh
88
-
89
- 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.
90
-
91
- 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.
92
-
93
- An initial run_list for the node can also be passed to the subcommand. Example usage:
94
-
95
- knife bootstrap windows ssh ec2-50-xx-xx-124.compute-1.amazonaws.com -r 'role[webserver],role[production]' -x Administrator -i ~/.ssh/id_rsa
96
-
97
- ### knife windows cert generate
98
-
99
- Generates a certificate(x509) containing a public / private key pair for WinRM 'SSL' communication.
100
- The certificate will be generated in three different formats *.pfx, *.b64 and *.pem.
101
- The PKCS12(i.e *.pfx) contains both the public and private keys, usually used on the server. This will be added to WinRM Server's Certificate Store.
102
- The *.b64 is Base64 PKCS12 key pair. Contains both the public and private keys, for upload to the Cloud REST API. e.g. Azure.
103
- The *.pem is Base64 encoded public certificate only. Required by the client to connect to the server.
104
- This command also displays the thumbprint of the generated certificate.
105
-
106
- knife windows cert generate --cert-passphrase "strong_passphrase" --hostname "cloudapp.net" --output-file "~/server_cert.pfx"
107
- # This command will generate certificates at user's home directory with names server_cert.b64, server_cert.pfx and server_cert.pem.
108
-
109
- ### knife windows cert install
110
-
111
- This command only functions on Windows. It adds the specified certificate to its certificate store. This command must include a valid PKCS12(i.e *.pfx) certificate file path.
112
-
113
- knife windows cert install "~/server_cert.pfx" --cert-passphrase "strong_passphrase"
114
-
115
- ### knife windows listener create
116
- This command only functions on Windows. It creates the winrm listener for SSL communication(i.e HTTPS).
117
- This command can also install certificate which is specified using --cert-install option and use the installed certificate thumbprint to create winrm listener.
118
- --hostname option is optional. Default value for hostname is *.
119
-
120
- knife windows listener create --cert-passphrase "strong_passphrase" --hostname "*.cloudapp.net" --cert-install "~/server_cert.pfx"
121
-
122
- The command also allows you to use existing certificates from local store to create winrm listener. Use --cert-thumbprint option to specify the certificate thumbprint.
123
-
124
- knife windows listener create --cert-passphrase "strong_passphrase" --hostname "*.cloudapp.net" --cert-thumbprint "bf0fef0bb41be40ceb66a3b38813ca489fe99746"
125
-
126
- You can get the thumbprint for existing certificates in local store using the following PowerShell command:
127
-
128
- Get-ChildItem -path cert:\LocalMachine\My
129
-
130
- ## BOOTSTRAP TEMPLATES:
131
-
132
- This gem provides the bootstrap template `windows-chef-client-msi`.
133
-
134
- ### windows-chef-client-msi
135
-
136
- This bootstrap template does the following:
137
-
138
- * Installs the latest version of Chef (and all dependencies) using the `chef-client` msi.
139
- * Writes the validation.pem per the local knife configuration.
140
- * Writes a default config file for Chef (`C:\chef\client.rb`) using values from the `knife.rb`.
141
- * Creates a JSON attributes file containing the specified run list and run Chef.
142
-
143
- This is the default bootstrap template used by both of the `knife windows bootstrap winrm` and `knife windows bootstrap ssh` subcommands.
144
-
145
- ## REQUIREMENTS/SETUP:
146
-
147
- ### Ruby
148
-
149
- Ruby 1.9.3+ is needed.
150
-
151
- ### Chef Version
152
-
153
- This knife plugins requires >= Chef 11.0.0. More details about Knife plugins can be
154
- [found in the Chef documentation](https://docs.chef.io/plugin_knife.html).
155
-
156
- ## Nodes
157
-
158
- **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.
159
-
160
- 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):
161
-
162
- winrm quickconfig -q
163
-
164
- The Chef and Ohai gem installations (that occur during bootstrap) take more
165
- memory than the default 150MB WinRM allocates per shell on older versions of
166
- Windows (prior to Windows Server 2012) -- this can slow down
167
- bootstrap. Optionally increase the memory limit to 300MB with the following command:
168
-
169
- winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
170
-
171
- Bootstrap commands can take longer than the WinRM default 60 seconds to
172
- complete, optionally increase to 30 minutes if bootstrap terminates a command prematurely:
173
-
174
- winrm set winrm/config @{MaxTimeoutms="1800000"}
175
-
176
- WinRM supports both the HTTP and HTTPS transports and the following
177
- authentication schemes: Kerberos, Digest, Certificate and Basic. The details
178
- of these authentication transports are outside of the scope of this README but
179
- details can be found on the
180
- [WinRM configuration guide](http://msdn.microsoft.com/en-us/library/aa384372(v=vs.85).aspx).
181
-
182
- ## WinRM authentication
183
-
184
- The default authentication protocol for `knife-windows` subcommands that use
185
- WinRM is the Negotiate protocol. The following commands when executed on a
186
- Windows system show authentication for domain and local accounts respectively:
187
-
188
- knife bootstrap windows winrm web1.cloudapp.net -r 'server::web' -x 'proddomain\webuser' -P 'super_secret_password'
189
- knife bootstrap windows winrm db1.cloudapp.net -r 'server::db' -x 'localadmin' -P 'super_secret_password'
190
-
191
- The commands above are using the default plaintext transport for WinRM --
192
- the default of Negotiate authentication may not be fully supported on
193
- non-Windows systems using the plaintext transport. To work around this, the
194
- remote system can be configured with an SSL WinRM listener instead of a
195
- plaintext listener. Then the above commands should be modified to use the SSL
196
- transport as follows using the `-t` (or `--winrm-transport`) option with the
197
- `ssl` argument:
198
-
199
- knife bootstrap windows winrm -t ssl web1.cloudapp.net -r 'server::web' -x 'proddomain\webuser' -P 'super_secret_password'
200
- knife bootstrap windows winrm -t ssl db1.cloudapp.net -r 'server::db' -x 'localadmin' -P 'super_secret_password'
201
-
202
- The commands using SSL above will work from any operating system, not just Windows.
203
-
204
- ### Troubleshooting authentication
205
-
206
- For development and testing purposes, unencrypted traffic with Basic
207
- authentication can make it easier to test connectivity. The configuration for
208
- the remote system may be accomplished with the following commands:
209
-
210
- winrm set winrm/config/service @{AllowUnencrypted="true"}
211
- winrm set winrm/config/service/auth @{Basic="true"}
212
-
213
- To test connectivity via `knife-windows` from another system, the default
214
- authentication protocol of Negotiate must be overridden using the
215
- `--winrm-authentication-protocol` option with the desired protocol, in this
216
- case Basic:
217
-
218
- knife winrm -m web1.cloudapp.net --winrm-authentication-protocol basic ipconfig -x 'localadmin' -P 'super_secret_password'
219
-
220
- Note that when using Basic authentication, domain accounts may not be used for
221
- authentication; an account local to the remote system must be used.
222
-
223
- ### Platform WinRM authentication support
224
-
225
- `knife-windows` supports `Kerberos`, `Negotiate`, and `Basic` authentication
226
- for WinRM communication. However, some of these protocols
227
- may not work with `knife-windows` on non-Windows systems because
228
- `knife-windows` relies on operating system libraries such as GSSAPI to implement
229
- Windows authentication, and some versions of these libraries do not
230
- fully implement the protocols.
231
-
232
- The following table shows the authentication protocols that can be used with
233
- `knife-windows` depending on whether the knife workstation is a Windows
234
- system, the transport, and whether or not the target user is a domain user or
235
- local to the target Windows system.
236
-
237
- | Workstation OS / Account Scope | SSL | Plaintext |
238
- |--------------------------------|------------------------------|----------------------------|
239
- | Windows / Local | Kerberos, Negotiate* , Basic | Kerberos, Negotiate, Basic |
240
- | Windows / Domain | Kerberos, Negotiate | Kerberos, Negotiate |
241
- | Non-Windows / Local | Kerberos, [Negotiate*](https://github.com/chef/knife-windows/issues/176) Basic | Kerberos, Basic |
242
- | Non-Windows / Domain | Kerberos, Negotiate | Kerberos |
243
-
244
- > \* There is a known defect in the `knife winrm` and `knife bootstrap windows
245
- > winrm` subcommands invoked on any OS platform when authenticating with the Negotiate protocol over
246
- > the SSL transport. The defect is tracked by
247
- > [knife-windows issue #176](https://github.com/chef/knife-windows/issues/176): If the remote system is
248
- > domain-joined, local accounts may not be used to authenticate via Negotiate
249
- > over SSL -- only domain accounts will work. Local accounts will only
250
- > successfully authenticate if the system is not joined to a domain.
251
- >
252
- > This is generally not an issue for bootstrap scenarios, where the
253
- > system has yet to be joined to any domain, but can be a problem for remote
254
- > management cases after the system is domain joined. Workarounds include using
255
- > a domain account instead, or enabling Basic authentication on the remote
256
- > system (unencrypted communication **does not** need to be enabled to make
257
- > Basic authentication function over SSL).
258
-
259
- ## General troubleshooting
260
-
261
- * When I run the winrm command I get: "Error: Invalid use of command line. Type "winrm -?" for help."
262
- You're running the winrm command from PowerShell and you need to put the key/value pair in single quotes. For example:
263
-
264
- `winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'`
265
-
266
- * Windows 2008R2 and earlier versions require an extra configuration for MaxTimeoutms to avoid WinRM::WinRMHTTPTransportError: Bad HTTP response error while bootstrapping. It should be atleast 300000.
267
-
268
- `winrm set winrm/config @{MaxTimeoutms="300000"}`
269
-
270
- ## CONTRIBUTING:
271
-
272
- Please file bugs against the KNIFE_WINDOWS project at https://github.com/chef/knife-windows/issues.
273
-
274
- More information on the contribution process for Chef projects can be found in the [Chef Contributions document](http://docs.chef.io/community_contributions.html).
275
-
276
- # LICENSE:
277
-
278
- Author:: Seth Chisamore (<schisamo@chef.io>)
279
- Copyright:: Copyright (c) 2015 Chef Software, Inc.
280
- License:: Apache License, Version 2.0
281
-
282
- Licensed under the Apache License, Version 2.0 (the "License");
283
- you may not use this file except in compliance with the License.
284
- You may obtain a copy of the License at
285
-
286
- http://www.apache.org/licenses/LICENSE-2.0
287
-
288
- Unless required by applicable law or agreed to in writing, software
289
- distributed under the License is distributed on an "AS IS" BASIS,
290
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
291
- See the License for the specific language governing permissions and
292
- limitations under the License.
1
+ Knife Windows Plugin
2
+ ====================
3
+ [![Build Status Master](https://travis-ci.org/chef/knife-windows.svg?branch=master)](https://travis-ci.org/chef/knife-windows)
4
+ [![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/knife-windows?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/knife-windows/branch/master)
5
+
6
+ This plugin adds additional functionality to the Chef Knife CLI tool for
7
+ configuring / interacting with nodes running Microsoft Windows:
8
+
9
+ * Bootstrap of nodes via the [Windows Remote Management (WinRM)](http://msdn.microsoft.com/en-us/library/aa384426\(v=VS.85\).aspx) or SSH protocols
10
+ * Remote command execution using the WinRM protocol
11
+ * Utilities to configure WinRM SSL endpoints on managed nodes
12
+
13
+ ## Subcommands
14
+
15
+ This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag
16
+
17
+ ### knife winrm
18
+
19
+ 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
+
21
+ knife winrm "role:web" "net stats srv" -x Administrator -P 'super_secret_password'
22
+
23
+ Or force a chef run:
24
+
25
+ knife winrm "myserver.myorganization.net" "chef-client -c c:/chef/client.rb" -m -x Administrator -P "super_secret_password"
26
+ myserver.myorganization.net [Fri, 04 Mar 2011 22:00:49 +0000] INFO: Starting Chef Run (Version 0.9.12)
27
+ myserver.myorganization.net [Fri, 04 Mar 2011 22:00:50 +0000] WARN: Node ip-0A502FFB has an empty run list.
28
+ myserver.myorganization.net [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Chef Run complete in 4.383966 seconds
29
+ myserver.myorganization.net [Fri, 04 Mar 2011 22:00:53 +0000] INFO: cleaning the checksum cache
30
+ myserver.myorganization.net [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Running report handlers
31
+ myserver.myorganization.net [Fri, 04 Mar 2011 22:00:53 +0000] INFO: Report handlers complete
32
+
33
+ This subcommand operates in a manner similar to [knife ssh](https://docs.chef.io/knife_ssh.html)...just leveraging the WinRM protocol for communication. It also includes `knife ssh`'s "[interactive session mode](https://docs.chef.io/knife_ssh.html#options)"
34
+
35
+ ### knife bootstrap windows winrm
36
+
37
+ 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.
38
+
39
+ This subcommand operates in a manner similar to [knife bootstrap](https://docs.chef.io/knife_bootstrap.html)...just leveraging the WinRM protocol for communication. An initial run_list for the node can also be passed to the subcommand. Example usage:
40
+
41
+ knife bootstrap windows winrm myserver.myorganization.net -r 'role[webserver],role[production]' -x Administrator -P 'super_secret_password'
42
+
43
+ #### Tip: Use SSL for WinRM communication
44
+
45
+ By default, the `knife winrm` and `knife bootstrap windows winrm` subcommands use a plaintext transport,
46
+ but they support an option `--winrm-transport` (or `-t`) with the argument
47
+ `ssl` that allows the SSL to secure the WinRM payload. Here's an example:
48
+
49
+ knife winrm -t ssl "role:web" "net stats srv" -x Administrator -P "super_secret_password" -f ~/server_public_cert.crt
50
+
51
+ Use of SSL is strongly recommended, particularly when invoking `knife-windows` on non-Windows platforms, since
52
+ without SSL there are limited options for ensuring the privacy of the
53
+ plaintext transport. See the section on [Platform authentication
54
+ support](#platform-winrm-authentication-support).
55
+
56
+ SSL will become the default transport in future revisions of
57
+ `knife-windows`.
58
+
59
+ ### knife wsman test
60
+
61
+ Connects to the remote WSMan/WinRM endpoint and verifies the remote node is listening. This is the equivalent of running Test-Wsman from PowerShell. Endpoints to test can be specified manually, or be driven by search and use many of the same connection options as knife winrm.
62
+ To test a single node using the default WinRM port (5985)
63
+
64
+ knife wsman test 192.168.1.10 -m
65
+
66
+ or to test a single node with SSL enabled on the default port (5986)
67
+
68
+ knife wsman test 192.168.1.10 -m --winrm-transport ssl
69
+
70
+ or to test all windows nodes registered with your Chef Server organization
71
+
72
+ knife wsman test platform:windows
73
+
74
+ ### knife bootstrap windows ssh
75
+
76
+ 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.
77
+
78
+ 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.
79
+
80
+ An initial run_list for the node can also be passed to the subcommand. Example usage:
81
+
82
+ knife bootstrap windows ssh myserver.myorganization.net -r "role[webserver],role[production]" -x Administrator -i ~/.ssh/id_rsa
83
+
84
+ ### knife windows cert generate
85
+
86
+ Generates a certificate(x509) containing a public / private key pair for WinRM 'SSL' communication.
87
+ The certificate will be generated in three different formats *.pfx, *.b64 and *.pem.
88
+ The PKCS12(i.e *.pfx) contains both the public and private keys, usually used on the server. This will be added to WinRM Server's Certificate Store.
89
+ The *.b64 is Base64 PKCS12 key pair. Contains both the public and private keys, for upload to the Cloud REST API. e.g. Azure.
90
+ The *.pem is Base64 encoded public certificate only. Required by the client to connect to the server.
91
+ This command also displays the thumbprint of the generated certificate.
92
+
93
+ knife windows cert generate --cert-passphrase "strong_passphrase" --hostname "myserver.myorganization.net" --output-file "~/server_cert.pfx"
94
+ # This command will generate certificates in the user's home directory with names server_cert.b64, server_cert.pfx and server_cert.pem.
95
+
96
+ ### knife windows cert install
97
+
98
+ This command only functions on Windows. It adds the specified certificate to its certificate store. This command must include a valid PKCS12(i.e *.pfx) certificate file path.
99
+
100
+ knife windows cert install "~/server_cert.pfx" --cert-passphrase "strong_passphrase"
101
+
102
+ ### knife windows listener create
103
+ This command only functions on Windows. It creates the winrm listener for SSL communication(i.e HTTPS).
104
+ This command can also install certificate which is specified using --cert-install option and use the installed certificate thumbprint to create winrm listener.
105
+ --hostname option is optional. Default value for hostname is *.
106
+
107
+ knife windows listener create --cert-passphrase "strong_passphrase" --hostname "myserver.mydomain.net" --cert-install "~/server_cert.pfx"
108
+
109
+ The command also allows you to use existing certificates from local store to create winrm listener. Use --cert-thumbprint option to specify the certificate thumbprint.
110
+
111
+ knife windows listener create --cert-passphrase "strong_passphrase" --hostname "myserver.mydomain.net" --cert-thumbprint "bf0fef0bb41be40ceb66a3b38813ca489fe99746"
112
+
113
+ You can get the thumbprint for existing certificates in the local store using the following PowerShell command:
114
+
115
+ ls cert:\LocalMachine\My
116
+
117
+ ## Bootstrap template
118
+
119
+ This gem provides the bootstrap template `windows-chef-client-msi`,
120
+ which does the following:
121
+
122
+ * Installs the latest version of Chef Client (and all dependencies) using the `chef-client` msi.
123
+ * Writes the validation.pem per the local knife configuration.
124
+ * Writes a default config file for Chef (`C:\chef\client.rb`) using values from the `knife.rb`.
125
+ * Creates a JSON attributes file containing the specified run list and run Chef.
126
+
127
+ This template is used by both `knife windows bootstrap winrm` and `knife windows bootstrap ssh` subcommands.
128
+
129
+ ## Requirements / setup
130
+
131
+ ### Ruby
132
+
133
+ Ruby 1.9.3+ is required.
134
+
135
+ ### Chef version
136
+
137
+ This knife plugins requires >= Chef 11.0.0. More details about Knife plugins can be
138
+ [found in the Chef documentation](https://docs.chef.io/plugin_knife.html).
139
+
140
+ ## Nodes
141
+
142
+ ### WinRM versions
143
+
144
+ The node must be running Windows Remote Management (WinRM) 2.0+. WinRM
145
+ allows you to call native objects in Windows. This includes, but is not
146
+ limited to, running PowerShell scripts, batch scripts, and fetching WMI
147
+ data. For more information on WinRM, please visit
148
+ [Microsoft's WinRM site](http://msdn.microsoft.com/en-us/library/aa384426\(v=VS.85\).aspx).
149
+
150
+ WinRM is built into Windows 7 and Windows Server 2008+. It can also [be installed](https://support.microsoft.com/en-us/kb/968929) on older version of Windows, including:
151
+
152
+ * Windows Server 2003
153
+ * Windows Vista
154
+
155
+ ### WinRM configuration
156
+
157
+ **NOTE**: Before any WinRM related knife subcommands will function
158
+ a node's WinRM installation must be configured correctly.
159
+ The settings below must be added to your base server image or passed
160
+ in using some sort of user-data mechanism provided by your cloud
161
+ provider. Some cloud providers will set up the required WinRM
162
+ configuration through the cloud API for creating instances -- see
163
+ the documentation for the provider.
164
+
165
+ A server running WinRM must also be configured properly to allow
166
+ outside connections for 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):
167
+
168
+ winrm quickconfig -q
169
+
170
+ This will set up an WinRM listener using the HTTP (plaintext)
171
+ transport -- WinRM also supports the SSL transport for improved
172
+ robustness against information disclosure and other threats.
173
+
174
+ The chef-client installation and bootstrap may take more
175
+ memory than the default 150MB WinRM allocates per shell on older versions of
176
+ Windows (prior to Windows Server 2012) -- this can slow down
177
+ bootstrap or cause it to fail. The memory limit was increased to 1GB with Windows Management Framework 3
178
+ (and Server 2012). However, there is a bug in Windows Management Framework 3
179
+ (and Server 2012) which requires a [hotfix from Microsoft](https://support.microsoft.com/en-us/kb/2842230/en-us).
180
+ You can increase the memory limit to 1GB with the following PowerShell
181
+ command:
182
+
183
+ ```powershell
184
+ set-item wsman:\localhost\shell\maxmemorypershellmb 1024
185
+ ```
186
+
187
+ Bootstrap commands can take longer than the WinRM default 60 seconds to
188
+ complete, optionally increase to 30 minutes if bootstrap terminates a command prematurely:
189
+
190
+ ```powershell
191
+ set-item wsman:\localhost\MaxTimeoutms 300000
192
+ ```
193
+
194
+ Note that the `winrm` command itself supports the same configuration
195
+ capabilities as the PowerShell commands given above -- if you need to
196
+ configure WinRM without using PowerShell, use `winrm -?` to get help.
197
+
198
+ WinRM supports both the HTTP and HTTPS (SSL) transports and the following
199
+ authentication schemes: Kerberos, Digest, Certificate and Basic. The details
200
+ of these authentication transports are outside of the scope of this
201
+ README but details can be found on the
202
+ [WinRM configuration guide](http://msdn.microsoft.com/en-us/library/aa384372\(v=vs.85\).aspx).
203
+
204
+ #### Configure SSL on a Windows node
205
+
206
+ WinRM supports use of SSL to provide privacy and integrity of
207
+ communication using the protocol and to prevent spoofing attacks.
208
+
209
+ ##### Configure SSL using `knife`
210
+
211
+ `knife-windows` includes three commands to assist with SSL
212
+ configuration -- these commands support all versions of Windows and do
213
+ not rely on PowerShell:
214
+
215
+ * `knife windows cert generate`: creates a certificate that may be used
216
+ to configure an SSL WinRM listener
217
+
218
+ * `knife windows cert install`: Installs a certificate into the
219
+ Windows certificate store so it can be used to configure an SSL
220
+ WinRM listener.
221
+
222
+ * `knife windows listener create`: Creates a WinRM listener on a
223
+ Windows node -- it can use either a certificate already installed in
224
+ the Windows certificate store, or one created by other tools
225
+ including the `knife windows cert generate` command.
226
+
227
+ Here is an example that configures a listener on the node on which the
228
+ commands are executed:
229
+
230
+ knife windows cert generate --domain myorg.org --output-file $env:userprofile/winrmcerts/winrm-ssl
231
+ knife windows listener create --hostname *.myorg.org --cert-install $env:userprofile/winrmcerts/winrm-ssl.pfx
232
+
233
+ Note that the first command which generates the certificate for the
234
+ listener could be executed from any system that can run `knife` as
235
+ long as the certificate it generates is made available at a path at
236
+ which the second command can access it.
237
+
238
+ See previous sections for additional details of the `windows cert generate`, `windows cert install` and `windows listener create` subcommands.
239
+
240
+ ##### Configure SSL using *PowerShell 4.0 or later*
241
+ The following PowerShell commands may be used to create an SSL WinRM
242
+ listener with a self-signed certificate:
243
+
244
+ ```powershell
245
+ $cert = New-SelfSignedCertificate -Subject 'myserver.mydomain.org' -Type SSLServerAuthentication -FriendlyName WinRMCert
246
+ new-item -address * -force -path wsman:\localhost\listener -port 5986 -hostname ($cert.subject -split '=')[1] -transport https -certificatethumbprint $cert.Thumbprint
247
+ ```
248
+
249
+ Note that the first command which uses the `New-SelfSignedCertificate`
250
+ cmdlet is available only in PowerShell version 4.0 and later.
251
+
252
+ ##### Configure SSL using `winrm quickconfig`
253
+
254
+ The following command can configure an SSL WinRM listener if the
255
+ Windows certificate store's Local Machine store contains a certificate
256
+ that meets certain criteria that are most likely to be met if the
257
+ system is joined to a Windows Active Directory domain:
258
+
259
+ winrm quickconfig -transport:https -q
260
+
261
+ If the criteria are not met, an error message will follow with
262
+ guidance on the certificate requirements; you may need to obtain a
263
+ certificate from the appropriate source or use the PowerShell or
264
+ `knife` techniques given above to create the listener instead.
265
+
266
+ ##### Disabling peer verification
267
+ In the SSL examples above, the `-f` parameter was used to supply a
268
+ certificate that could validate the identity of the remote server.
269
+ For debugging purposes, this validation may be skipped if you have not
270
+ obtained a public certificate that can validate the server. Here is an
271
+ example:
272
+
273
+ knife winrm -m 192.168.0.6 -x "mydomain\myuser" -P $PASSWD -t ssl --winrm-ssl-verify-mode verify_none ipconfig
274
+
275
+ This option should be used carefully since disabling the verification of the
276
+ remote system's certificate can subject knife commands to spoofing attacks.
277
+
278
+ ## WinRM authentication
279
+
280
+ The default authentication protocol for `knife-windows` subcommands that use
281
+ WinRM is the Negotiate protocol. The following commands when executed on a
282
+ Windows system show authentication for domain and local accounts respectively:
283
+
284
+ knife bootstrap windows winrm web1.cloudapp.net -r "server::web" -x "proddomain\webuser" -P "super_secret_password"
285
+ knife bootstrap windows winrm db1.cloudapp.net -r "server::db" -x "localadmin" -P "super_secret_password"
286
+
287
+ The commands above are using the default plaintext transport for WinRM --
288
+ the default of Negotiate authentication may not be fully supported on
289
+ non-Windows systems using the plaintext transport. To work around this, the
290
+ remote system can be configured with an SSL WinRM listener instead of a
291
+ plaintext listener. Then the above commands should be modified to use the SSL
292
+ transport as follows using the `-t` (or `--winrm-transport`) option with the
293
+ `ssl` argument:
294
+
295
+ knife bootstrap windows winrm -t ssl web1.cloudapp.net -r "server::web" -x "proddomain\webuser" -P "super_secret_password" -f ~/mycert.crt
296
+ knife bootstrap windows winrm -t ssl db1.cloudapp.net -r "server::db" -x "localadmin" -P "super_secret_password" ~/mycert.crt
297
+
298
+ The commands using SSL above will work from any operating system, not
299
+ just Windows.
300
+
301
+ ### Troubleshooting authentication
302
+
303
+ For development and testing purposes, unencrypted traffic with Basic
304
+ authentication can make it easier to test connectivity. The configuration for
305
+ the remote system may be accomplished with the following PowerShell commands:
306
+
307
+ ```powershell
308
+ set-item wsman:\localhost\service\allowunencrypted $true
309
+ set-item wsman:\localhost\service\auth\basic $true
310
+ ```
311
+ To test connectivity via `knife-windows` from another system, the default
312
+ authentication protocol of Negotiate must be overridden using the
313
+ `--winrm-authentication-protocol` option with the desired protocol, in this
314
+ case Basic:
315
+
316
+ knife winrm -m web1.cloudapp.net --winrm-authentication-protocol basic ipconfig -x localadmin -P "super_secret_password"
317
+
318
+ Note that when using Basic authentication, domain accounts may not be used for
319
+ authentication; an account local to the remote system must be used.
320
+
321
+ ### Platform WinRM authentication support
322
+
323
+ `knife-windows` supports `Kerberos`, `Negotiate`, and `Basic` authentication
324
+ for WinRM communication. However, some of these protocols
325
+ may not work with `knife-windows` on non-Windows systems because
326
+ `knife-windows` relies on operating system libraries such as GSSAPI to implement
327
+ Windows authentication, and some versions of these libraries do not
328
+ fully implement the protocols.
329
+
330
+ The following table shows the authentication protocols that can be used with
331
+ `knife-windows` depending on whether the knife workstation is a Windows
332
+ system, the transport, and whether or not the target user is a domain user or
333
+ local to the target Windows system.
334
+
335
+ | Workstation OS / Account Scope | SSL | Plaintext |
336
+ |--------------------------------|------------------------------|----------------------------|
337
+ | Windows / Local | Kerberos, Negotiate* , Basic | Kerberos, Negotiate, Basic |
338
+ | Windows / Domain | Kerberos, Negotiate | Kerberos, Negotiate |
339
+ | Non-Windows / Local | Kerberos, [Negotiate*](https://github.com/chef/knife-windows/issues/176) Basic | Kerberos, Basic |
340
+ | Non-Windows / Domain | Kerberos, Negotiate | Kerberos |
341
+
342
+ > \* There is a known defect in the `knife winrm` and `knife bootstrap windows
343
+ > winrm` subcommands invoked on any OS platform when authenticating with the Negotiate protocol over
344
+ > the SSL transport. The defect is tracked by
345
+ > [knife-windows issue #176](https://github.com/chef/knife-windows/issues/176): If the remote system is
346
+ > domain-joined, local accounts may not be used to authenticate via Negotiate
347
+ > over SSL -- only domain accounts will work. Local accounts will only
348
+ > successfully authenticate if the system is not joined to a domain.
349
+ >
350
+ > This is generally not an issue for bootstrap scenarios, where the
351
+ > system has yet to be joined to any domain, but can be a problem for remote
352
+ > management cases after the system is domain joined. Workarounds include using
353
+ > a domain account instead, or enabling Basic authentication on the remote
354
+ > system (unencrypted communication **does not** need to be enabled to make
355
+ > Basic authentication function over SSL).
356
+
357
+ ## General troubleshooting
358
+
359
+ * Windows 2008R2 and earlier versions require an extra configuration
360
+ for MaxTimeoutms to avoid WinRM::WinRMHTTPTransportError: Bad HTTP
361
+ response error while bootstrapping. It should be at least 300000.
362
+
363
+ `set-item wsman:\\localhost\\MaxTimeoutms 300000`
364
+
365
+ * When I run the winrm command I get: "Error: Invalid use of command line. Type "winrm -?" for help."
366
+ You're running the winrm command from PowerShell and you need to put the key/value pair in single quotes. For example:
367
+
368
+ `winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}'`
369
+
370
+
371
+ ## CONTRIBUTING:
372
+
373
+ Please file bugs against the KNIFE_WINDOWS project at https://github.com/chef/knife-windows/issues.
374
+
375
+ More information on the contribution process for Chef projects can be found in the [Chef Contributions document](http://docs.chef.io/community_contributions.html).
376
+
377
+ # LICENSE:
378
+
379
+ Author:: Seth Chisamore (<schisamo@chef.io>)
380
+ Copyright:: Copyright (c) 2015 Chef Software, Inc.
381
+ License:: Apache License, Version 2.0
382
+
383
+ Licensed under the Apache License, Version 2.0 (the "License");
384
+ you may not use this file except in compliance with the License.
385
+ You may obtain a copy of the License at
386
+
387
+ http://www.apache.org/licenses/LICENSE-2.0
388
+
389
+ Unless required by applicable law or agreed to in writing, software
390
+ distributed under the License is distributed on an "AS IS" BASIS,
391
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
392
+ See the License for the specific language governing permissions and
393
+ limitations under the License.