knife-windows 0.5.14 → 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,140 +1,140 @@
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
- == windows-shell
73
-
74
- This bootstrap template does the following:
75
-
76
- * Installs Ruby 1.8.7 via the {Ruby Installer for Windows}[http://rubyinstaller.org/] which also includes the latest version of RubyGems
77
- * Installs the RubyInstaller Development Kit (DevKit). The RubyInstaller Development Kit (DevKit) is a MSYS/MinGW based toolkit than enables you to build many of the native C/C++ extensions available for Ruby.
78
- * Installs required Windows-related gems from RubyGems.org
79
- * Installs latest Chef version from RubyGems.org including {Ohai}[https://rubygems.org/gems/ohai] and {Chef}[https://rubygems.org/gems/chef]. The Chef version is configurable using the *--bootstrap-version* option.
80
- * Writes the validation.pem per the local knife configuration.
81
- * Writes a default config file for Chef (C:\chef\client.rb) using values from the +knife.rb+.
82
- * Creates a JSON attributes file containing the specified run list and run Chef.
83
-
84
- This should be considered a legacy bootstrap template and will most likely be removed in a future version.
85
-
86
- = REQUIREMENTS/SETUP:
87
-
88
- == Ruby
89
-
90
- Ruby 1.9.1+ is needed.
91
-
92
- == Chef Version
93
-
94
- 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].
95
-
96
- == Nodes
97
-
98
- *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.
99
-
100
- 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]:
101
-
102
- C:\Users\Administrator> winrm quickconfig -q
103
-
104
- 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:
105
-
106
- C:\Users\Administrator> winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
107
-
108
- Bootstrap commands can take longer than the WinRM default 60 seconds to complete, bump to 30 minutes:
109
-
110
- C:\Users\Administrator> winrm set winrm/config @{MaxTimeoutms="1800000"}
111
-
112
- 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.
113
-
114
- For development and testing purposes, unencrypted traffic with Basic authentication can make things easier:
115
-
116
- C:\Users\Administrator> winrm set winrm/config/service @{AllowUnencrypted="true"}
117
- C:\Users\Administrator> winrm set winrm/config/service/auth @{Basic="true"}
118
-
119
- = CONTRIBUTING:
120
-
121
- Please file bugs against the KNIFE_WINDOWS project at http://tickets.opscode.com/browse/knife
122
-
123
- More information on the contribution process for Opscode projects can be found at: http://wiki.opscode.com/display/chef/How+to+Contribute
124
- = LICENSE:
125
-
126
- Author:: Seth Chisamore (<schisamo@opscode.com>)
127
- Copyright:: Copyright (c) 2011 Opscode, Inc.
128
- License:: Apache License, Version 2.0
129
-
130
- Licensed under the Apache License, Version 2.0 (the "License");
131
- you may not use this file except in compliance with the License.
132
- You may obtain a copy of the License at
133
-
134
- http://www.apache.org/licenses/LICENSE-2.0
135
-
136
- Unless required by applicable law or agreed to in writing, software
137
- distributed under the License is distributed on an "AS IS" BASIS,
138
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139
- See the License for the specific language governing permissions and
140
- limitations under the License.
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
+ == windows-shell
73
+
74
+ This bootstrap template does the following:
75
+
76
+ * Installs Ruby 1.8.7 via the {Ruby Installer for Windows}[http://rubyinstaller.org/] which also includes the latest version of RubyGems
77
+ * Installs the RubyInstaller Development Kit (DevKit). The RubyInstaller Development Kit (DevKit) is a MSYS/MinGW based toolkit than enables you to build many of the native C/C++ extensions available for Ruby.
78
+ * Installs required Windows-related gems from RubyGems.org
79
+ * Installs latest Chef version from RubyGems.org including {Ohai}[https://rubygems.org/gems/ohai] and {Chef}[https://rubygems.org/gems/chef]. The Chef version is configurable using the *--bootstrap-version* option.
80
+ * Writes the validation.pem per the local knife configuration.
81
+ * Writes a default config file for Chef (C:\chef\client.rb) using values from the +knife.rb+.
82
+ * Creates a JSON attributes file containing the specified run list and run Chef.
83
+
84
+ This should be considered a legacy bootstrap template and will most likely be removed in a future version.
85
+
86
+ = REQUIREMENTS/SETUP:
87
+
88
+ == Ruby
89
+
90
+ Ruby 1.9.1+ is needed.
91
+
92
+ == Chef Version
93
+
94
+ 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].
95
+
96
+ == Nodes
97
+
98
+ *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.
99
+
100
+ 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]:
101
+
102
+ C:\Users\Administrator> winrm quickconfig -q
103
+
104
+ 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:
105
+
106
+ C:\Users\Administrator> winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
107
+
108
+ Bootstrap commands can take longer than the WinRM default 60 seconds to complete, bump to 30 minutes:
109
+
110
+ C:\Users\Administrator> winrm set winrm/config @{MaxTimeoutms="1800000"}
111
+
112
+ 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.
113
+
114
+ For development and testing purposes, unencrypted traffic with Basic authentication can make things easier:
115
+
116
+ C:\Users\Administrator> winrm set winrm/config/service @{AllowUnencrypted="true"}
117
+ C:\Users\Administrator> winrm set winrm/config/service/auth @{Basic="true"}
118
+
119
+ = CONTRIBUTING:
120
+
121
+ Please file bugs against the KNIFE_WINDOWS project at http://tickets.opscode.com/browse/knife
122
+
123
+ More information on the contribution process for Opscode projects can be found at: http://wiki.opscode.com/display/chef/How+to+Contribute
124
+ = LICENSE:
125
+
126
+ Author:: Seth Chisamore (<schisamo@opscode.com>)
127
+ Copyright:: Copyright (c) 2011 Opscode, Inc.
128
+ License:: Apache License, Version 2.0
129
+
130
+ Licensed under the Apache License, Version 2.0 (the "License");
131
+ you may not use this file except in compliance with the License.
132
+ You may obtain a copy of the License at
133
+
134
+ http://www.apache.org/licenses/LICENSE-2.0
135
+
136
+ Unless required by applicable law or agreed to in writing, software
137
+ distributed under the License is distributed on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139
+ See the License for the specific language governing permissions and
140
+ limitations under the License.
data/Rakefile CHANGED
@@ -1,16 +1,16 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- begin
5
- require 'rspec/core/rake_task'
6
-
7
- task :default => :spec
8
-
9
- desc "Run all specs in spec directory"
10
- RSpec::Core::RakeTask.new(:spec) do |t|
11
- t.pattern = 'spec/**/*_spec.rb'
12
- end
13
-
14
- rescue LoadError
15
- STDERR.puts "\n*** RSpec not available. (sudo) gem install rspec to run unit tests. ***\n\n"
16
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+
7
+ task :default => :spec
8
+
9
+ desc "Run all specs in spec directory"
10
+ RSpec::Core::RakeTask.new(:spec) do |t|
11
+ t.pattern = 'spec/**/*_spec.rb'
12
+ end
13
+
14
+ rescue LoadError
15
+ STDERR.puts "\n*** RSpec not available. (sudo) gem install rspec to run unit tests. ***\n\n"
16
+ end
@@ -1,20 +1,20 @@
1
- Feature: Ensure that the help works as designed
2
- In order to test the help via CLI
3
- As an Operator
4
- I want to run the CLI with different arguments
5
-
6
- Scenario: Running the windows sub-command shows available commands
7
- When I run `knife windows`
8
- And the output should contain "Available windows subcommands: (for details, knife SUB-COMMAND --help)\n\n** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
9
-
10
- Scenario: Running the windows sub-command shows available commands
11
- When I run `knife windows --help`
12
- And the output should contain "Available windows subcommands: (for details, knife SUB-COMMAND --help)\n\n** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
13
-
14
- Scenario: Running the windows sub-command shows available commands
15
- When I run `knife windows help`
16
- And the output should contain "Available windows subcommands: (for details, knife SUB-COMMAND --help)\n\n** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
17
-
18
- Scenario: Running the knife command shows available windows command"
19
- When I run `knife`
20
- And the output should contain "** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
1
+ Feature: Ensure that the help works as designed
2
+ In order to test the help via CLI
3
+ As an Operator
4
+ I want to run the CLI with different arguments
5
+
6
+ Scenario: Running the windows sub-command shows available commands
7
+ When I run `knife windows`
8
+ And the output should contain "Available windows subcommands: (for details, knife SUB-COMMAND --help)\n\n** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
9
+
10
+ Scenario: Running the windows sub-command shows available commands
11
+ When I run `knife windows --help`
12
+ And the output should contain "Available windows subcommands: (for details, knife SUB-COMMAND --help)\n\n** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
13
+
14
+ Scenario: Running the windows sub-command shows available commands
15
+ When I run `knife windows help`
16
+ And the output should contain "Available windows subcommands: (for details, knife SUB-COMMAND --help)\n\n** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
17
+
18
+ Scenario: Running the knife command shows available windows command"
19
+ When I run `knife`
20
+ And the output should contain "** WINDOWS COMMANDS **\nknife bootstrap windows winrm FQDN (options)\nknife bootstrap windows ssh FQDN (options)\nknife winrm QUERY COMMAND (options)"
@@ -1,5 +1,5 @@
1
- require 'aruba/cucumber'
2
-
3
- Before do
4
- @aruba_timeout_seconds = 5
5
- end
1
+ require 'aruba/cucumber'
2
+
3
+ Before do
4
+ @aruba_timeout_seconds = 5
5
+ end
@@ -1,24 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "knife-windows/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "knife-windows"
7
- s.version = Knife::Windows::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.has_rdoc = true
10
- s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
11
- s.authors = ["Seth Chisamore"]
12
- s.email = ["schisamo@opscode.com"]
13
- s.homepage = "https://github.com/opscode/knife-windows"
14
- s.summary = %q{Plugin that adds functionality to Chef's Knife CLI for configuring/interacting with nodes running Microsoft Windows}
15
- s.description = s.summary
16
-
17
- s.required_ruby_version = ">= 1.9.1"
18
- s.add_dependency "em-winrm", "= 0.5.4"
19
-
20
- s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
- s.require_paths = ["lib"]
24
- end
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "knife-windows/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "knife-windows"
7
+ s.version = Knife::Windows::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.has_rdoc = true
10
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
11
+ s.authors = ["Seth Chisamore"]
12
+ s.email = ["schisamo@opscode.com"]
13
+ s.homepage = "https://github.com/opscode/knife-windows"
14
+ s.summary = %q{Plugin that adds functionality to Chef's Knife CLI for configuring/interacting with nodes running Microsoft Windows}
15
+ s.description = s.summary
16
+
17
+ s.required_ruby_version = ">= 1.9.1"
18
+ s.add_dependency "em-winrm", "~> 0.5", ">= 0.5.4"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
@@ -1,211 +1,222 @@
1
- @rem
2
- @rem Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- @rem Copyright:: Copyright (c) 2011 Opscode, Inc.
4
- @rem License:: Apache License, Version 2.0
5
- @rem
6
- @rem Licensed under the Apache License, Version 2.0 (the "License");
7
- @rem you may not use this file except in compliance with the License.
8
- @rem You may obtain a copy of the License at
9
- @rem
10
- @rem http://www.apache.org/licenses/LICENSE-2.0
11
- @rem
12
- @rem Unless required by applicable law or agreed to in writing, software
13
- @rem distributed under the License is distributed on an "AS IS" BASIS,
14
- @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- @rem See the License for the specific language governing permissions and
16
- @rem limitations under the License.
17
- @rem
18
-
19
- @rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the
20
- @rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when
21
- @rem the line is read. See help for the /E switch from cmd.exe /? .
22
- @setlocal ENABLEDELAYEDEXPANSION
23
-
24
- <%= "SETX HTTP_PROXY \"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] %>
25
-
26
- @set BOOTSTRAP_DIRECTORY=<%= bootstrap_directory %>
27
- @echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"...
28
- @if NOT EXIST %BOOTSTRAP_DIRECTORY% (
29
- @echo Existing directory not found, creating.
30
- @mkdir %BOOTSTRAP_DIRECTORY%
31
- ) else (
32
- @echo Existing directory found, skipping creation.
33
- )
34
-
35
- > <%= bootstrap_directory %>\wget.vbs (
36
- <%= win_wget %>
37
- )
38
-
39
- > <%= bootstrap_directory %>\wget.ps1 (
40
- <%= win_wget_ps %>
41
- )
42
-
43
- @rem Determine the version and the architecture
44
-
45
- @FOR /F "tokens=1-8 delims=.[] " %%A IN ('ver') DO (
46
- @set WinMajor=%%D
47
- @set WinMinor=%%E
48
- @set WinBuild=%%F
49
- )
50
-
51
- @echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild%
52
-
53
- @set LATEST_OS_VERSION_MAJOR=6
54
- @set LATEST_OS_VERSION_MINOR=3
55
-
56
- @if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown
57
- @if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR% (
58
- @if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown
59
- )
60
-
61
- goto Version%WinMajor%.%WinMinor%
62
-
63
- :VersionUnknown
64
- @rem If this is an unknown version of windows set the default
65
- @set MACHINE_OS=2008r2
66
- @echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS%
67
- goto architecture_select
68
-
69
- :Version6.0
70
- @set MACHINE_OS=2008
71
- goto architecture_select
72
-
73
- :Version5.2
74
- @set MACHINE_OS=2003r2
75
- goto architecture_select
76
-
77
- :Version6.1
78
- @set MACHINE_OS=2008r2
79
- goto architecture_select
80
-
81
- :Version6.2
82
- @set MACHINE_OS=2012
83
- goto architecture_select
84
-
85
- @rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012
86
- :Version6.3
87
- goto Version6.2
88
-
89
- :architecture_select
90
- goto Architecture%PROCESSOR_ARCHITEW6432%
91
-
92
- :Architecture
93
- goto Architecture%PROCESSOR_ARCHITECTURE%
94
-
95
- @rem If this is an unknown architecture set the default
96
- @set MACHINE_ARCH=i686
97
- goto install
98
-
99
- :Architecturex86
100
- @set MACHINE_ARCH=i686
101
- goto install
102
-
103
- :Architectureamd64
104
- @set MACHINE_ARCH=x86_64
105
- goto install
106
-
107
- :install
108
- @rem Install Chef using chef-client MSI installer
109
-
110
- <% url="https://www.opscode.com/chef/download?p=windows&pv=%MACHINE_OS%&m=%MACHINE_ARCH%" -%>
111
- <% url += "&v=#{@config[:bootstrap_version]}" if @config.key? :bootstrap_version -%>
112
- @set "REMOTE_SOURCE_MSI_URL=<%= url %>"
113
- @set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>"
114
- @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\chef-client-msi%RANDOM%.log"
115
- @set "FALLBACK_QUERY_STRING=&DownloadContext=PowerShell"
116
-
117
- @rem Clear any pre-existing downloads
118
- @echo Checking for existing downloaded package at "%LOCAL_DESTINATION_MSI_PATH%"
119
- @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
120
- @echo Found existing downloaded package, deleting.
121
- @del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
122
- @if ERRORLEVEL 1 (
123
- echo Warning: Failed to delete pre-existing package with status code !ERRORLEVEL! > "&2"
124
- )
125
- ) else (
126
- echo No existing downloaded packages to delete.
127
- )
128
-
129
- @rem If there's somehow a name collision, remove pre-existing log
130
- @if EXIST "%CHEF_CLIENT_MSI_LOG_PATH%" del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
131
-
132
- @echo Attempting to download client package using cscript...
133
- cscript /nologo <%= bootstrap_directory %>\wget.vbs /url:"%REMOTE_SOURCE_MSI_URL%" /path:"%LOCAL_DESTINATION_MSI_PATH%"
134
-
135
- @rem Work around issues found in Windows Server 2012 around job objects not respecting WSMAN memory quotas
136
- @rem that cause the MSI download process to exceed the quota even when it is increased by administrators.
137
- @rem Retry the download using a more memory-efficient mechanism that only works if PowerShell is available.
138
- @set DOWNLOAD_ERROR_STATUS=!ERRORLEVEL!
139
- @if ERRORLEVEL 1 (
140
- @echo Failed cscript download with status code !DOWNLOAD_ERROR_STATUS! > "&2"
141
- @if !DOWNLOAD_ERROR_STATUS!==0 set DOWNLOAD_ERROR_STATUS=2
142
- ) else (
143
- @rem Sometimes the error level is not set even when the download failed,
144
- @rem so check for the file to be sure it is there -- if it's not, we'll retry
145
- @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
146
- echo Failed download: download completed, but downloaded file not found > "&2"
147
- set DOWNLOAD_ERROR_STATUS=2
148
- ) else (
149
- echo Download via cscript succeeded.
150
- )
151
- )
152
-
153
- @if NOT %DOWNLOAD_ERROR_STATUS%==0 (
154
- @echo Warning: Failed to download "%REMOTE_SOURCE_MSI_URL%" to "%LOCAL_DESTINATION_MSI_PATH%"
155
- @echo Warning: Retrying download with PowerShell if available...
156
-
157
- @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
158
-
159
- @set powershell_download=powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -command "& '<%= bootstrap_directory %>\wget.ps1' '%REMOTE_SOURCE_MSI_URL%%FALLBACK_QUERY_STRING%' '%LOCAL_DESTINATION_MSI_PATH%'"
160
- @echo !powershell_download!
161
- @call !powershell_download!
162
- @if NOT ERRORLEVEL 1 (
163
- echo Download via PowerShell succeeded.
164
- ) else (
165
- echo Failed to download "%REMOTE_SOURCE_MSI_URL%" with status code !ERRORLEVEL!. > "&2"
166
- echo Exiting without bootstrapping due to download failure. > "&2"
167
- exit /b 1
168
- )
169
- )
170
-
171
- @echo Installing downloaded client package...
172
-
173
- <%= install_chef %>
174
-
175
- @if ERRORLEVEL 1 (
176
- echo Chef-client package failed to install with status code !ERRORLEVEL!. > "&2"
177
- echo See installation log for additional detail: %CHEF_CLIENT_MSI_LOG_PATH%. > "&2"
178
- ) else (
179
- @echo Installation completed successfully
180
- del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
181
- )
182
-
183
- @endlocal
184
-
185
- @echo off
186
- echo Writing validation key...
187
-
188
- > <%= bootstrap_directory %>\validation.pem (
189
- <%= validation_key %>
190
- )
191
-
192
- echo Validation key written.
193
- @echo on
194
-
195
- <% if @config[:encrypted_data_bag_secret] -%>
196
- > <%= bootstrap_directory %>\encrypted_data_bag_secret (
197
- <%= encrypted_data_bag_secret %>
198
- )
199
- <% end -%>
200
-
201
- > <%= bootstrap_directory %>\client.rb (
202
- <%= config_content %>
203
- )
204
-
205
- > <%= bootstrap_directory %>\first-boot.json (
206
- <%= first_boot %>
207
- )
208
-
209
- @echo Starting chef to bootstrap the node...
210
- <%= start_chef %>
211
-
1
+ @rem
2
+ @rem Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ @rem Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ @rem License:: Apache License, Version 2.0
5
+ @rem
6
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
7
+ @rem you may not use this file except in compliance with the License.
8
+ @rem You may obtain a copy of the License at
9
+ @rem
10
+ @rem http://www.apache.org/licenses/LICENSE-2.0
11
+ @rem
12
+ @rem Unless required by applicable law or agreed to in writing, software
13
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
14
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ @rem See the License for the specific language governing permissions and
16
+ @rem limitations under the License.
17
+ @rem
18
+
19
+ @rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the
20
+ @rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when
21
+ @rem the line is read. See help for the /E switch from cmd.exe /? .
22
+ @setlocal ENABLEDELAYEDEXPANSION
23
+
24
+ <%= "SETX HTTP_PROXY \"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] %>
25
+
26
+ @set BOOTSTRAP_DIRECTORY=<%= bootstrap_directory %>
27
+ @echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"...
28
+ @if NOT EXIST %BOOTSTRAP_DIRECTORY% (
29
+ @echo Existing directory not found, creating.
30
+ @mkdir %BOOTSTRAP_DIRECTORY%
31
+ ) else (
32
+ @echo Existing directory found, skipping creation.
33
+ )
34
+
35
+ > <%= bootstrap_directory %>\wget.vbs (
36
+ <%= win_wget %>
37
+ )
38
+
39
+ > <%= bootstrap_directory %>\wget.ps1 (
40
+ <%= win_wget_ps %>
41
+ )
42
+
43
+ @rem Determine the version and the architecture
44
+
45
+ @FOR /F "usebackq tokens=1-8 delims=.[] " %%A IN (`ver`) DO (
46
+ @set WinMajor=%%D
47
+ @set WinMinor=%%E
48
+ @set WinBuild=%%F
49
+ )
50
+
51
+ @echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild%
52
+
53
+ @set LATEST_OS_VERSION_MAJOR=6
54
+ @set LATEST_OS_VERSION_MINOR=3
55
+
56
+ @if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown
57
+ @if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR% (
58
+ @if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown
59
+ )
60
+
61
+ goto Version%WinMajor%.%WinMinor%
62
+
63
+ :VersionUnknown
64
+ @rem If this is an unknown version of windows set the default
65
+ @set MACHINE_OS=2008r2
66
+ @echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS%
67
+ goto architecture_select
68
+
69
+ :Version6.0
70
+ @set MACHINE_OS=2008
71
+ goto architecture_select
72
+
73
+ :Version5.2
74
+ @set MACHINE_OS=2003r2
75
+ goto architecture_select
76
+
77
+ :Version6.1
78
+ @set MACHINE_OS=2008r2
79
+ goto architecture_select
80
+
81
+ :Version6.2
82
+ @set MACHINE_OS=2012
83
+ goto architecture_select
84
+
85
+ @rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012
86
+ :Version6.3
87
+ goto Version6.2
88
+
89
+ :architecture_select
90
+ goto Architecture%PROCESSOR_ARCHITEW6432%
91
+
92
+ :Architecture
93
+ goto Architecture%PROCESSOR_ARCHITECTURE%
94
+
95
+ @rem If this is an unknown architecture set the default
96
+ @set MACHINE_ARCH=i686
97
+ goto install
98
+
99
+ :Architecturex86
100
+ @set MACHINE_ARCH=i686
101
+ goto install
102
+
103
+ :Architectureamd64
104
+ @set MACHINE_ARCH=x86_64
105
+ goto install
106
+
107
+ :install
108
+ @rem Install Chef using chef-client MSI installer
109
+
110
+ <% url="https://www.opscode.com/chef/download?p=windows&pv=%MACHINE_OS%&m=%MACHINE_ARCH%" -%>
111
+ <% url += "&v=#{@config[:bootstrap_version]}" if @config.key? :bootstrap_version -%>
112
+ @set "REMOTE_SOURCE_MSI_URL=<%= url %>"
113
+ @set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>"
114
+ @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\chef-client-msi%RANDOM%.log"
115
+ @set "FALLBACK_QUERY_STRING=&DownloadContext=PowerShell"
116
+
117
+ @rem Clear any pre-existing downloads
118
+ @echo Checking for existing downloaded package at "%LOCAL_DESTINATION_MSI_PATH%"
119
+ @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
120
+ @echo Found existing downloaded package, deleting.
121
+ @del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
122
+ @if ERRORLEVEL 1 (
123
+ echo Warning: Failed to delete pre-existing package with status code !ERRORLEVEL! > "&2"
124
+ )
125
+ ) else (
126
+ echo No existing downloaded packages to delete.
127
+ )
128
+
129
+ @rem If there is somehow a name collision, remove pre-existing log
130
+ @if EXIST "%CHEF_CLIENT_MSI_LOG_PATH%" del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
131
+
132
+ @echo Attempting to download client package using cscript...
133
+ cscript /nologo <%= bootstrap_directory %>\wget.vbs /url:"%REMOTE_SOURCE_MSI_URL%" /path:"%LOCAL_DESTINATION_MSI_PATH%"
134
+
135
+ @rem Work around issues found in Windows Server 2012 around job objects not respecting WSMAN memory quotas
136
+ @rem that cause the MSI download process to exceed the quota even when it is increased by administrators.
137
+ @rem Retry the download using a more memory-efficient mechanism that only works if PowerShell is available.
138
+ @set DOWNLOAD_ERROR_STATUS=!ERRORLEVEL!
139
+ @if ERRORLEVEL 1 (
140
+ @echo Failed cscript download with status code !DOWNLOAD_ERROR_STATUS! > "&2"
141
+ @if !DOWNLOAD_ERROR_STATUS!==0 set DOWNLOAD_ERROR_STATUS=2
142
+ ) else (
143
+ @rem Sometimes the error level is not set even when the download failed,
144
+ @rem so check for the file to be sure it is there -- if it is not, we will retry
145
+ @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" (
146
+ echo Failed download: download completed, but downloaded file not found > "&2"
147
+ set DOWNLOAD_ERROR_STATUS=2
148
+ ) else (
149
+ echo Download via cscript succeeded.
150
+ )
151
+ )
152
+
153
+ @if NOT %DOWNLOAD_ERROR_STATUS%==0 (
154
+ @echo Warning: Failed to download "%REMOTE_SOURCE_MSI_URL%" to "%LOCAL_DESTINATION_MSI_PATH%"
155
+ @echo Warning: Retrying download with PowerShell if available...
156
+
157
+ @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" del /f /q "%LOCAL_DESTINATION_MSI_PATH%"
158
+
159
+ @set powershell_download=powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File <%= bootstrap_directory %>\wget.ps1 "%REMOTE_SOURCE_MSI_URL%%FALLBACK_QUERY_STRING%" "%LOCAL_DESTINATION_MSI_PATH%"
160
+ @echo !powershell_download!
161
+ @call !powershell_download!
162
+ @if NOT ERRORLEVEL 1 (
163
+ echo Download via PowerShell succeeded.
164
+ ) else (
165
+ echo Failed to download "%REMOTE_SOURCE_MSI_URL%" with status code !ERRORLEVEL!. > "&2"
166
+ echo Exiting without bootstrapping due to download failure. > "&2"
167
+ exit /b 1
168
+ )
169
+ )
170
+
171
+ @echo Installing downloaded client package...
172
+
173
+ <%= install_chef %>
174
+
175
+ @if ERRORLEVEL 1 (
176
+ echo Chef-client package failed to install with status code !ERRORLEVEL!. > "&2"
177
+ echo See installation log for additional detail: %CHEF_CLIENT_MSI_LOG_PATH%. > "&2"
178
+ ) else (
179
+ @echo Installation completed successfully
180
+ del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%"
181
+ )
182
+
183
+ @endlocal
184
+
185
+ @echo off
186
+ echo Writing validation key...
187
+
188
+ > <%= bootstrap_directory %>\validation.pem (
189
+ <%= validation_key %>
190
+ )
191
+
192
+ echo Validation key written.
193
+ @echo on
194
+
195
+ <% if @config[:encrypted_data_bag_secret] -%>
196
+ > <%= bootstrap_directory %>\encrypted_data_bag_secret (
197
+ <%= encrypted_data_bag_secret %>
198
+ )
199
+ <% end -%>
200
+
201
+ <%# Generate Ohai Hints -%>
202
+ <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
203
+ mkdir <%= bootstrap_directory %>\ohai\hints
204
+
205
+ <% @chef_config[:knife][:hints].each do |name, hash| -%>
206
+ > <%= bootstrap_directory %>\ohai\hints\<%= name %>.json (
207
+ <%= escape_and_echo(hash.to_json) %>
208
+ )
209
+ <% end -%>
210
+ <% end -%>
211
+
212
+ > <%= bootstrap_directory %>\client.rb (
213
+ <%= config_content %>
214
+ )
215
+
216
+ > <%= bootstrap_directory %>\first-boot.json (
217
+ <%= first_boot %>
218
+ )
219
+
220
+ @echo Starting chef to bootstrap the node...
221
+ <%= start_chef %>
222
+