knife-cloud 1.0.1 → 1.1.0.rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +15 -3
- data/README.md +16 -15
- data/ci.gemfile +18 -0
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_options.rb +58 -12
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb +12 -0
- data/lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb +1 -2
- data/lib/knife-cloud/version.rb +1 -1
- data/lib/test/templates/chef-full-chef-zero.erb +3 -4
- data/spec/unit/bootstrap_protocol_spec.rb +22 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 788ed3dc24ee8ce5785af0a5adfbfdfff4cc2e84
|
4
|
+
data.tar.gz: 013964ef1d9e20da5a1a8490d5021c6d1ba2df99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d59fbde18cb34fb0727c102fd4ef00d401cfb2cb742d62e4d68185f80dee660623675d6d737b52de975fc7ec0416cc23780366e200992aa13333f3ec4392da
|
7
|
+
data.tar.gz: 5b80aa2d77ba13b576001a46c7edcbf4a9e3db7f4aeba058eadbe2a7c24bc76c8c13f9e77b4cfa7052f67942dd70442cc843135c366e3adfb4214928e65221c5
|
data/.travis.yml
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
rvm:
|
2
|
-
# - 1.8.7
|
3
|
-
- 1.9.2
|
4
2
|
- 1.9.3
|
5
3
|
- 2.0.0
|
6
4
|
|
7
|
-
|
5
|
+
gemfile: ci.gemfile
|
6
|
+
|
7
|
+
env:
|
8
|
+
- CHEF_VERSION="master"
|
9
|
+
- CHEF_VERSION="~> 12.0"
|
10
|
+
- CHEF_VERSION="< 12"
|
11
|
+
|
12
|
+
matrix:
|
13
|
+
exclude:
|
14
|
+
- rvm: 1.9.3
|
15
|
+
env: CHEF_VERSION="master"
|
16
|
+
- rvm: 1.9.3
|
17
|
+
env: CHEF_VERSION="~> 12.0"
|
18
|
+
|
19
|
+
script: bundle exec rake spec
|
data/README.md
CHANGED
@@ -1,31 +1,32 @@
|
|
1
|
-
Knife Cloud
|
2
|
-
===============
|
1
|
+
# Knife Cloud
|
3
2
|
|
4
3
|
[][travis]
|
5
4
|
[][codeclimate]
|
6
5
|
|
7
|
-
[travis]: https://travis-ci.org/
|
8
|
-
[codeclimate]: https://codeclimate.com/github/
|
6
|
+
[travis]: https://travis-ci.org/chef/knife-cloud
|
7
|
+
[codeclimate]: https://codeclimate.com/github/chef/knife-cloud
|
9
8
|
|
10
9
|
## Description
|
11
10
|
|
12
|
-
|
13
|
-
infrastructure with Chef. For more information about knife and Chef visit https://
|
11
|
+
`knife-cloud` is a library for implementing knife plugins that integrate cloud
|
12
|
+
infrastructure with Chef. For more information about knife and Chef visit https://chef.io/chef.
|
14
13
|
|
15
14
|
## Purpose
|
16
15
|
|
17
|
-
The knife-cloud library has been designed to integrate the common tasks of all knife plugins. As a developer of a knife plugin, you will not have to worry about writing generic code in your plugin, eg: the Chef bootstrap code or SSH / WinRM connection code.
|
16
|
+
The knife-cloud library has been designed to integrate the common tasks of all knife plugins. As a developer of a knife plugin, you will not have to worry about writing generic code in your plugin, eg: the Chef bootstrap code or SSH / WinRM connection code.
|
18
17
|
|
19
18
|
## Installation
|
20
19
|
|
21
20
|
This library is distributed as a Ruby Gem. To install it, run:
|
22
21
|
|
23
22
|
$ gem install knife-cloud
|
23
|
+
$ # OR
|
24
|
+
$ chef exec gem install knife-cloud
|
24
25
|
|
25
26
|
Depending on your system's configuration, you may need to run this command with root privileges.
|
26
27
|
Alternatively, you can build the gem from the knife-cloud source code.
|
27
28
|
|
28
|
-
$ git clone https://github.com/
|
29
|
+
$ git clone https://github.com/chef/knife-cloud
|
29
30
|
$ cd knife-cloud
|
30
31
|
$ rake gem
|
31
32
|
$ gem install knife-cloud-x.y.z.gem
|
@@ -33,7 +34,7 @@ Alternatively, you can build the gem from the knife-cloud source code.
|
|
33
34
|
## Writing your custom plugin
|
34
35
|
|
35
36
|
General documentation of how to develop a knife plugin can be found in
|
36
|
-
[Chef documentation](http://docs.
|
37
|
+
[Chef documentation](http://docs.chef.io/plugin_knife_custom.html). Use of
|
37
38
|
the `knife-cloud` gem to implement the plugin automates many aspects of the
|
38
39
|
process.
|
39
40
|
|
@@ -97,7 +98,7 @@ Create a new ruby project, say knife-myplugin. Its code structure will look like
|
|
97
98
|
myplugin_server_delete.rb
|
98
99
|
myplugin_server_list.rb
|
99
100
|
myplugin_flavor_list.rb
|
100
|
-
|
101
|
+
|
101
102
|
### Service
|
102
103
|
|
103
104
|
- myplugin_service.rb
|
@@ -113,7 +114,7 @@ Example Code:
|
|
113
114
|
class Knife
|
114
115
|
class Cloud
|
115
116
|
class MypluginService < FogService
|
116
|
-
|
117
|
+
|
117
118
|
def initialize(options = {})
|
118
119
|
# TODO - Add cloud specific auth params to be passed to fog connection. See knife-openstack for real life example.
|
119
120
|
super(options.merge({
|
@@ -184,7 +185,7 @@ This class will inherit from the Chef::Knife::Cloud::ServerCreateCommand class.
|
|
184
185
|
include MypluginServiceOptions
|
185
186
|
|
186
187
|
banner "knife myplugin server create (options)"
|
187
|
-
|
188
|
+
|
188
189
|
end
|
189
190
|
end
|
190
191
|
end
|
@@ -269,7 +270,7 @@ Following is the code template for the above methods
|
|
269
270
|
def validate_params!
|
270
271
|
super
|
271
272
|
errors = []
|
272
|
-
|
273
|
+
|
273
274
|
# TODO - Add your validation here for any create server parameters and populate errors [] with error message strings.
|
274
275
|
|
275
276
|
# errors << "your error message" if some_param_undefined
|
@@ -277,7 +278,7 @@ Following is the code template for the above methods
|
|
277
278
|
error_message = ""
|
278
279
|
raise CloudExceptions::ValidationError, error_message if errors.each{|e| ui.error(e); error_message = "#{error_message} #{e}."}.any?
|
279
280
|
end
|
280
|
-
|
281
|
+
|
281
282
|
### Server Delete Command
|
282
283
|
|
283
284
|
- myplugin_server_delete.rb
|
@@ -404,7 +405,7 @@ Example -
|
|
404
405
|
|
405
406
|
## License
|
406
407
|
|
407
|
-
Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
408
|
+
Copyright:: Copyright (c) 2014-2015 Chef Software, Inc.
|
408
409
|
|
409
410
|
License:: Apache License, Version 2.0
|
410
411
|
|
data/ci.gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in knife-cloud.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
if ENV['CHEF_VERSION'] == 'master'
|
7
|
+
gem 'chef', github: 'chef/chef'
|
8
|
+
elsif ENV['CHEF_VERSION'] == '< 12'
|
9
|
+
gem 'ohai', '7.4.1'
|
10
|
+
gem 'chef', ENV['CHEF_VERSION']
|
11
|
+
else
|
12
|
+
gem 'chef', ENV['CHEF_VERSION']
|
13
|
+
end
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'rake'
|
17
|
+
gem 'knife-windows'
|
18
|
+
end
|
@@ -104,7 +104,16 @@ class Chef
|
|
104
104
|
option :distro,
|
105
105
|
:short => "-d DISTRO",
|
106
106
|
:long => "--distro DISTRO",
|
107
|
-
:description => "Bootstrap a distro using a template"
|
107
|
+
:description => "Bootstrap a distro using a template. [DEPRECATED] Use -t / --template option instead.",
|
108
|
+
:proc => Proc.new { |t|
|
109
|
+
Chef::Log.warn("[DEPRECATED] -d / --distro option is deprecated. Use -t / --template option instead.")
|
110
|
+
Chef::Config[:knife][:bootstrap_template] = t
|
111
|
+
}
|
112
|
+
|
113
|
+
option :bootstrap_template,
|
114
|
+
:short => "-t TEMPLATE",
|
115
|
+
:long => "--bootstrap-template TEMPLATE",
|
116
|
+
:description => "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
|
108
117
|
|
109
118
|
option :use_sudo,
|
110
119
|
:long => "--sudo",
|
@@ -118,9 +127,11 @@ class Chef
|
|
118
127
|
|
119
128
|
option :template_file,
|
120
129
|
:long => "--template-file TEMPLATE",
|
121
|
-
:description => "Full path to location of template to use",
|
122
|
-
:proc
|
123
|
-
|
130
|
+
:description => "Full path to location of template to use. [DEPRECATED] Use -t / --bootstrap-template option instead.",
|
131
|
+
:proc => Proc.new { |v|
|
132
|
+
Chef::Log.warn("[DEPRECATED] --template-file option is deprecated. Use -t / --bootstrap-template option instead.")
|
133
|
+
v
|
134
|
+
}
|
124
135
|
|
125
136
|
option :run_list,
|
126
137
|
:short => "-r RUN_LIST",
|
@@ -164,6 +175,31 @@ class Chef
|
|
164
175
|
:description => "URL to a custom installation script",
|
165
176
|
:proc => Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u }
|
166
177
|
|
178
|
+
option :bootstrap_curl_options,
|
179
|
+
:long => "--bootstrap-curl-options OPTIONS",
|
180
|
+
:description => "Add options to curl when install chef-client",
|
181
|
+
:proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co }
|
182
|
+
|
183
|
+
option :auth_timeout,
|
184
|
+
:long => "--auth-timeout MINUTES",
|
185
|
+
:description => "The maximum time in minutes to wait to for authentication over the transport to the node to succeed. The default value is 25 minutes.",
|
186
|
+
:default => 25
|
187
|
+
|
188
|
+
option :node_ssl_verify_mode,
|
189
|
+
:long => "--node-ssl-verify-mode [peer|none]",
|
190
|
+
:description => "Whether or not to verify the SSL cert for all HTTPS requests.",
|
191
|
+
:proc => Proc.new { |v|
|
192
|
+
valid_values = ["none", "peer"]
|
193
|
+
unless valid_values.include?(v)
|
194
|
+
raise "Invalid value '#{v}' for --node-ssl-verify-mode. Valid values are: #{valid_values.join(", ")}"
|
195
|
+
end
|
196
|
+
}
|
197
|
+
|
198
|
+
option :node_verify_api_cert,
|
199
|
+
:long => "--[no-]node-verify-api-cert",
|
200
|
+
:description => "Verify the SSL cert for HTTPS requests to the Chef server API.",
|
201
|
+
:boolean => true
|
202
|
+
|
167
203
|
option :bootstrap_install_command,
|
168
204
|
:long => "--bootstrap-install-command COMMANDS",
|
169
205
|
:description => "Custom command to install chef-client",
|
@@ -174,15 +210,25 @@ class Chef
|
|
174
210
|
:description => "Add options to wget when installing chef-client",
|
175
211
|
:proc => Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo }
|
176
212
|
|
177
|
-
option :
|
178
|
-
:long =>
|
179
|
-
:description =>
|
180
|
-
|
213
|
+
option :bootstrap_vault_file,
|
214
|
+
:long => '--bootstrap-vault-file VAULT_FILE',
|
215
|
+
:description => 'A JSON file with a list of vault(s) and item(s) to be updated'
|
216
|
+
|
217
|
+
option :bootstrap_vault_json,
|
218
|
+
:long => '--bootstrap-vault-json VAULT_JSON',
|
219
|
+
:description => 'A JSON string with the vault(s) and item(s) to be updated'
|
220
|
+
|
221
|
+
option :bootstrap_vault_item,
|
222
|
+
:long => '--bootstrap-vault-item VAULT_ITEM',
|
223
|
+
:description => 'A single vault and item to update as "vault:item"',
|
224
|
+
:proc => Proc.new { |i|
|
225
|
+
(vault, item) = i.split(/:/)
|
226
|
+
Chef::Config[:knife][:bootstrap_vault_item] ||= {}
|
227
|
+
Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
|
228
|
+
Chef::Config[:knife][:bootstrap_vault_item][vault].push(item)
|
229
|
+
Chef::Config[:knife][:bootstrap_vault_item]
|
230
|
+
}
|
181
231
|
|
182
|
-
option :auth_timeout,
|
183
|
-
:long => "--auth-timeout MINUTES",
|
184
|
-
:description => "The maximum time in minutes to wait to for authentication over the transport to the node to succeed. The default value is 25 minutes.",
|
185
|
-
:default => 25
|
186
232
|
end
|
187
233
|
end
|
188
234
|
end # module ends
|
@@ -61,6 +61,18 @@ class Chef
|
|
61
61
|
bootstrap.config[:secret] = locate_config_value(:secret)
|
62
62
|
bootstrap.config[:secret_file] = locate_config_value(:secret_file)
|
63
63
|
bootstrap.config[:template_file] = locate_config_value(:template_file)
|
64
|
+
bootstrap.config[:bootstrap_template] = locate_config_value(:bootstrap_template)
|
65
|
+
bootstrap.config[:node_ssl_verify_mode] = locate_config_value(:node_ssl_verify_mode)
|
66
|
+
bootstrap.config[:node_verify_api_cert] = locate_config_value(:node_verify_api_cert)
|
67
|
+
bootstrap.config[:bootstrap_no_proxy] = locate_config_value(:bootstrap_no_proxy)
|
68
|
+
bootstrap.config[:bootstrap_url] = locate_config_value(:bootstrap_url)
|
69
|
+
bootstrap.config[:bootstrap_install_command] = locate_config_value(:bootstrap_install_command)
|
70
|
+
bootstrap.config[:bootstrap_wget_options] = locate_config_value(:bootstrap_wget_options)
|
71
|
+
bootstrap.config[:bootstrap_curl_options] = locate_config_value(:bootstrap_curl_options)
|
72
|
+
bootstrap.config[:bootstrap_vault_file] = locate_config_value(:bootstrap_vault_file)
|
73
|
+
bootstrap.config[:bootstrap_vault_json] = locate_config_value(:bootstrap_vault_json)
|
74
|
+
bootstrap.config[:bootstrap_vault_item] = locate_config_value(:bootstrap_vault_item)
|
75
|
+
bootstrap.config[:use_sudo_password] = locate_config_value(:use_sudo_password)
|
64
76
|
end
|
65
77
|
|
66
78
|
end
|
@@ -32,7 +32,6 @@ class Chef
|
|
32
32
|
|
33
33
|
def load_winrm_deps
|
34
34
|
require 'winrm'
|
35
|
-
require 'em-winrm'
|
36
35
|
require 'chef/knife/bootstrap_windows_winrm'
|
37
36
|
require 'chef/knife/core/windows_bootstrap_context'
|
38
37
|
require 'chef/knife/winrm'
|
@@ -75,7 +74,7 @@ class Chef
|
|
75
74
|
sleep 2
|
76
75
|
false
|
77
76
|
ensure
|
78
|
-
tcp_socket && tcp_socket.close
|
77
|
+
tcp_socket && tcp_socket.close
|
79
78
|
end
|
80
79
|
|
81
80
|
end
|
data/lib/knife-cloud/version.rb
CHANGED
@@ -10,14 +10,13 @@ exists() {
|
|
10
10
|
fi
|
11
11
|
}
|
12
12
|
|
13
|
-
install_sh="http://
|
14
|
-
version_string="-v <%= chef_version %>"
|
13
|
+
install_sh="http://chef.io/chef/install.sh"
|
15
14
|
|
16
15
|
if ! exists /usr/bin/chef-client; then
|
17
16
|
if exists wget; then
|
18
|
-
bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh} -O -)
|
17
|
+
bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh} -O -)
|
19
18
|
elif exists curl; then
|
20
|
-
bash <(curl -L <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> ${install_sh})
|
19
|
+
bash <(curl -L <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> ${install_sh})
|
21
20
|
else
|
22
21
|
echo "Neither wget nor curl found. Please install one and try again." >&2
|
23
22
|
exit 1
|
@@ -55,6 +55,17 @@ describe Chef::Knife::Cloud::BootstrapProtocol do
|
|
55
55
|
@config[:secret] = "secret"
|
56
56
|
@config[:secret_file] = "secret_file"
|
57
57
|
@config[:template_file] = "../template_file"
|
58
|
+
@config[:bootstrap_vault_file] = "/foo/bar/baz"
|
59
|
+
@config[:bootstrap_vault_json] = '{ "vault": "item1" }'
|
60
|
+
@config[:bootstrap_vault_item] = { 'vault' => 'item1' }
|
61
|
+
@config[:bootstrap_template] = "../template_file"
|
62
|
+
@config[:node_ssl_verify_mode] = "none"
|
63
|
+
@config[:node_verify_api_cert] = true
|
64
|
+
@config[:bootstrap_url] = "https://www.chef.io/chef/install.sh"
|
65
|
+
@config[:bootstrap_install_command] = "curl -l https://www.chef.io/chef/install.sh | sudo bash -s --"
|
66
|
+
@config[:bootstrap_wget_options] = "-e use_proxy=yes -e http://myproxy.com:8080"
|
67
|
+
@config[:bootstrap_curl_options] = "--proxy http://myproxy.com:8080"
|
68
|
+
@config[:use_sudo_password] = "true"
|
58
69
|
allow(@config).to receive(:locate_config_value).and_return({})
|
59
70
|
@instance.bootstrap = Chef::Knife::Bootstrap.new
|
60
71
|
@instance.init_bootstrap_options
|
@@ -65,6 +76,17 @@ describe Chef::Knife::Cloud::BootstrapProtocol do
|
|
65
76
|
expect(@instance.bootstrap.config[:secret]).to eq(@config[:secret])
|
66
77
|
expect(@instance.bootstrap.config[:secret_file]).to eq(@config[:secret_file])
|
67
78
|
expect(@instance.bootstrap.config[:template_file]).to eq(@config[:template_file])
|
79
|
+
expect(@instance.bootstrap.config[:bootstrap_vault_file]).to eq(@config[:bootstrap_vault_file])
|
80
|
+
expect(@instance.bootstrap.config[:bootstrap_vault_json]).to eq(@config[:bootstrap_vault_json])
|
81
|
+
expect(@instance.bootstrap.config[:bootstrap_vault_item]).to eq(@config[:bootstrap_vault_item])
|
82
|
+
expect(@instance.bootstrap.config[:bootstrap_template]).to eq(@config[:bootstrap_template])
|
83
|
+
expect(@instance.bootstrap.config[:node_ssl_verify_mode]).to eq(@config[:node_ssl_verify_mode])
|
84
|
+
expect(@instance.bootstrap.config[:node_verify_api_cert]).to eq(@config[:node_verify_api_cert])
|
85
|
+
expect(@instance.bootstrap.config[:bootstrap_url]).to eq(@config[:bootstrap_url])
|
86
|
+
expect(@instance.bootstrap.config[:bootstrap_install_command]).to eq(@config[:bootstrap_install_command])
|
87
|
+
expect(@instance.bootstrap.config[:bootstrap_wget_options]).to eq(@config[:bootstrap_wget_options])
|
88
|
+
expect(@instance.bootstrap.config[:bootstrap_curl_options]).to eq(@config[:bootstrap_curl_options])
|
89
|
+
expect(@instance.bootstrap.config[:use_sudo_password]).to eq(@config[:use_sudo_password])
|
68
90
|
end
|
69
91
|
end
|
70
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.rc.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaustubh Deorukhkar
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: knife-windows
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- LICENSE
|
141
141
|
- README.md
|
142
142
|
- Rakefile
|
143
|
+
- ci.gemfile
|
143
144
|
- knife-cloud.gemspec
|
144
145
|
- lib/chef/knife/cloud/chefbootstrap/bootstrap_distribution.rb
|
145
146
|
- lib/chef/knife/cloud/chefbootstrap/bootstrap_options.rb
|
@@ -213,9 +214,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
214
|
version: '0'
|
214
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
216
|
requirements:
|
216
|
-
- - "
|
217
|
+
- - ">"
|
217
218
|
- !ruby/object:Gem::Version
|
218
|
-
version:
|
219
|
+
version: 1.3.1
|
219
220
|
requirements: []
|
220
221
|
rubyforge_project:
|
221
222
|
rubygems_version: 2.2.2
|
@@ -245,3 +246,4 @@ test_files:
|
|
245
246
|
- spec/unit/unix_distribution_spec.rb
|
246
247
|
- spec/unit/windows_distribution_spec.rb
|
247
248
|
- spec/unit/winrm_bootstrap_protocol_spec.rb
|
249
|
+
has_rdoc:
|