chef 0.10.0.beta.8 → 0.10.0.beta.9
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.
- data/distro/common/html/knife-bootstrap.1.html +69 -10
- data/distro/common/html/knife-client.1.html +25 -22
- data/distro/common/html/knife-configure.1.html +1 -1
- data/distro/common/html/knife-cookbook-site.1.html +91 -19
- data/distro/common/html/knife-cookbook.1.html +216 -76
- data/distro/common/html/knife-data-bag.1.html +1 -1
- data/distro/common/html/knife-environment.1.html +177 -3
- data/distro/common/html/knife-exec.1.html +44 -3
- data/distro/common/html/knife-index.1.html +1 -1
- data/distro/common/html/knife-node.1.html +5 -3
- data/distro/common/html/knife-recipe.1.html +1 -1
- data/distro/common/html/knife-role.1.html +83 -19
- data/distro/common/html/knife-search.1.html +43 -2
- data/distro/common/html/knife-ssh.1.html +57 -2
- data/distro/common/html/knife-status.1.html +33 -2
- data/distro/common/html/knife-tag.1.html +45 -1
- data/distro/common/html/knife.1.html +94 -161
- data/distro/common/html/shef.1.html +283 -0
- data/distro/common/man/man1/knife-bootstrap.1 +56 -4
- data/distro/common/man/man1/knife-client.1 +12 -11
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +64 -22
- data/distro/common/man/man1/knife-cookbook.1 +200 -122
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +167 -2
- data/distro/common/man/man1/knife-exec.1 +36 -3
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +2 -1
- data/distro/common/man/man1/knife-role.1 +48 -24
- data/distro/common/man/man1/knife-search.1 +27 -3
- data/distro/common/man/man1/knife-ssh.1 +43 -2
- data/distro/common/man/man1/knife-status.1 +14 -2
- data/distro/common/man/man1/knife-tag.1 +32 -2
- data/distro/common/man/man1/knife.1 +91 -186
- data/distro/common/man/man1/shef.1 +237 -26
- data/distro/common/markdown/man1/knife-bootstrap.mkd +57 -7
- data/distro/common/markdown/man1/knife-client.mkd +19 -17
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +63 -15
- data/distro/common/markdown/man1/knife-cookbook.mkd +220 -103
- data/distro/common/markdown/man1/knife-environment.mkd +144 -1
- data/distro/common/markdown/man1/knife-exec.mkd +29 -1
- data/distro/common/markdown/man1/knife-node.mkd +1 -1
- data/distro/common/markdown/man1/knife-role.mkd +36 -30
- data/distro/common/markdown/man1/knife-search.mkd +0 -1
- data/distro/common/markdown/man1/knife-ssh.mkd +0 -2
- data/distro/common/markdown/man1/knife-status.mkd +0 -2
- data/distro/common/markdown/man1/knife-tag.mkd +31 -0
- data/distro/common/markdown/man1/knife.mkd +93 -165
- data/distro/common/markdown/man1/shef.mkd +189 -0
- data/lib/chef/api_client.rb +36 -35
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/client.rb +1 -0
- data/lib/chef/cookbook/cookbook_version_loader.rb +29 -7
- data/lib/chef/cookbook_uploader.rb +55 -36
- data/lib/chef/cookbook_version.rb +3 -1
- data/lib/chef/couchdb.rb +0 -1
- data/lib/chef/knife/cookbook_list.rb +1 -1
- data/lib/chef/knife/cookbook_show.rb +1 -0
- data/lib/chef/knife/core/generic_presenter.rb +3 -3
- data/lib/chef/knife/help.rb +6 -2
- data/lib/chef/knife/tag_create.rb +26 -5
- data/lib/chef/knife/tag_delete.rb +34 -5
- data/lib/chef/knife/tag_list.rb +24 -6
- data/lib/chef/node.rb +1 -0
- data/lib/chef/role.rb +1 -0
- data/lib/chef/shef.rb +1 -0
- data/lib/chef/version.rb +1 -1
- metadata +4 -4
- data/distro/common/man/man1/knife-recipe.1 +0 -13
- data/distro/common/markdown/man1/knife-recipe.mkd +0 -24
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
require 'rest_client'
|
2
3
|
require 'chef/exceptions'
|
3
4
|
require 'chef/knife/cookbook_metadata'
|
@@ -10,6 +11,23 @@ require 'chef/cookbook/file_system_file_vendor'
|
|
10
11
|
class Chef
|
11
12
|
class CookbookUploader
|
12
13
|
|
14
|
+
def self.work_queue
|
15
|
+
@work_queue ||= Queue.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.setup_worker_threads
|
19
|
+
@worker_threads ||= begin
|
20
|
+
work_queue
|
21
|
+
(1...10).map do
|
22
|
+
Thread.new do
|
23
|
+
loop do
|
24
|
+
work_queue.pop.call
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
13
31
|
attr_reader :cookbook
|
14
32
|
attr_reader :path
|
15
33
|
attr_reader :opts
|
@@ -35,51 +53,32 @@ class Chef
|
|
35
53
|
end
|
36
54
|
|
37
55
|
def upload_cookbook
|
56
|
+
Thread.abort_on_exception = true
|
38
57
|
Chef::Log.info("Saving #{cookbook.name}")
|
39
58
|
|
40
59
|
# Syntax Check
|
41
60
|
validate_cookbook
|
42
|
-
# Generate metadata.json from metadata.rb
|
43
|
-
build_metadata
|
44
|
-
|
45
61
|
# generate checksums of cookbook files and create a sandbox
|
46
62
|
checksum_files = cookbook.checksums
|
47
63
|
checksums = checksum_files.inject({}){|memo,elt| memo[elt.first]=nil ; memo}
|
48
64
|
new_sandbox = rest.post_rest("sandboxes", { :checksums => checksums })
|
49
65
|
|
50
66
|
Chef::Log.info("Uploading files")
|
67
|
+
|
68
|
+
self.class.setup_worker_threads
|
69
|
+
|
51
70
|
# upload the new checksums and commit the sandbox
|
52
71
|
new_sandbox['checksums'].each do |checksum, info|
|
53
72
|
if info['needs_upload'] == true
|
54
73
|
Chef::Log.info("Uploading #{checksum_files[checksum]} (checksum hex = #{checksum}) to #{info['url']}")
|
55
|
-
|
56
|
-
# Checksum is the hexadecimal representation of the md5,
|
57
|
-
# but we need the base64 encoding for the content-md5
|
58
|
-
# header
|
59
|
-
checksum64 = Base64.encode64([checksum].pack("H*")).strip
|
60
|
-
timestamp = Time.now.utc.iso8601
|
61
|
-
file_contents = File.read(checksum_files[checksum])
|
62
|
-
# TODO - 5/28/2010, cw: make signing and sending the request streaming
|
63
|
-
sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(
|
64
|
-
:http_method => :put,
|
65
|
-
:path => URI.parse(info['url']).path,
|
66
|
-
:body => file_contents,
|
67
|
-
:timestamp => timestamp,
|
68
|
-
:user_id => rest.client_name
|
69
|
-
)
|
70
|
-
headers = { 'content-type' => 'application/x-binary', 'content-md5' => checksum64, :accept => 'application/json' }
|
71
|
-
headers.merge!(sign_obj.sign(OpenSSL::PKey::RSA.new(rest.signing_key)))
|
72
|
-
|
73
|
-
begin
|
74
|
-
RestClient::Resource.new(info['url'], :headers=>headers, :timeout=>1800, :open_timeout=>1800).put(file_contents)
|
75
|
-
rescue RestClient::Exception => e
|
76
|
-
Chef::Log.error("Upload failed: #{e.message}\n#{e.response.body}")
|
77
|
-
raise
|
78
|
-
end
|
74
|
+
self.class.work_queue << uploader_function_for(checksum_files[checksum], checksum, info['url'])
|
79
75
|
else
|
80
76
|
Chef::Log.debug("#{checksum_files[checksum]} has not changed")
|
81
77
|
end
|
82
78
|
end
|
79
|
+
|
80
|
+
sleep 0.1 until self.class.work_queue.empty?
|
81
|
+
|
83
82
|
sandbox_url = new_sandbox['uri']
|
84
83
|
Chef::Log.debug("Committing sandbox")
|
85
84
|
# Retry if S3 is claims a checksum doesn't exist (the eventual
|
@@ -100,15 +99,35 @@ class Chef
|
|
100
99
|
Chef::Log.info("Upload complete!")
|
101
100
|
end
|
102
101
|
|
103
|
-
def
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
102
|
+
def worker_thread(work_queue)
|
103
|
+
end
|
104
|
+
|
105
|
+
def uploader_function_for(file, checksum, url)
|
106
|
+
lambda do
|
107
|
+
# Checksum is the hexadecimal representation of the md5,
|
108
|
+
# but we need the base64 encoding for the content-md5
|
109
|
+
# header
|
110
|
+
checksum64 = Base64.encode64([checksum].pack("H*")).strip
|
111
|
+
timestamp = Time.now.utc.iso8601
|
112
|
+
file_contents = File.read(file)
|
113
|
+
# TODO - 5/28/2010, cw: make signing and sending the request streaming
|
114
|
+
sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(
|
115
|
+
:http_method => :put,
|
116
|
+
:path => URI.parse(url).path,
|
117
|
+
:body => file_contents,
|
118
|
+
:timestamp => timestamp,
|
119
|
+
:user_id => rest.client_name
|
120
|
+
)
|
121
|
+
headers = { 'content-type' => 'application/x-binary', 'content-md5' => checksum64, :accept => 'application/json' }
|
122
|
+
headers.merge!(sign_obj.sign(OpenSSL::PKey::RSA.new(rest.signing_key)))
|
123
|
+
|
124
|
+
begin
|
125
|
+
RestClient::Resource.new(url, :headers=>headers, :timeout=>1800, :open_timeout=>1800).put(file_contents)
|
126
|
+
rescue RestClient::Exception => e
|
127
|
+
Chef::Log.error("Upload failed: #{e.message}\n#{e.response.body}")
|
128
|
+
raise
|
129
|
+
end
|
130
|
+
end
|
112
131
|
end
|
113
132
|
|
114
133
|
def validate_cookbook
|
@@ -861,7 +861,9 @@ class Chef
|
|
861
861
|
# [String]:: Array of cookbook versions, which are strings like 'x.y.z'
|
862
862
|
# nil:: if the cookbook doesn't exist. an error will also be logged.
|
863
863
|
def self.available_versions(cookbook_name)
|
864
|
-
chef_server_rest.get_rest("cookbooks/#{cookbook_name}").
|
864
|
+
chef_server_rest.get_rest("cookbooks/#{cookbook_name}")[cookbook_name]["versions"].map do |cb|
|
865
|
+
cb["version"]
|
866
|
+
end
|
865
867
|
rescue Net::HTTPServerException => e
|
866
868
|
if e.to_s =~ /^404/
|
867
869
|
Chef::Log.error("Cannot find a cookbook named #{cookbook_name}")
|
data/lib/chef/couchdb.rb
CHANGED
@@ -53,7 +53,7 @@ class Chef
|
|
53
53
|
|
54
54
|
# Returns a String representation of +data+ that is suitable for output
|
55
55
|
# to a terminal or perhaps for data interchange with another program.
|
56
|
-
# The representation of the +data+ depends on the value of the
|
56
|
+
# The representation of the +data+ depends on the value of the
|
57
57
|
# `config[:format]` setting.
|
58
58
|
def format(data)
|
59
59
|
case parse_format_option
|
@@ -171,9 +171,9 @@ class Chef
|
|
171
171
|
collected[cookbook] = versions["versions"].map {|v| v['version']}
|
172
172
|
collected
|
173
173
|
end
|
174
|
-
key_length = versions_by_cookbook.keys.map {|name| name.size }.max + 2
|
174
|
+
key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map {|name| name.size }.max + 2
|
175
175
|
versions_by_cookbook.sort.map do |cookbook, versions|
|
176
|
-
"#{cookbook.ljust(key_length)} #{versions.join('
|
176
|
+
"#{cookbook.ljust(key_length)} #{versions.join(' ')}"
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
data/lib/chef/knife/help.rb
CHANGED
@@ -25,14 +25,18 @@ class Chef
|
|
25
25
|
def run
|
26
26
|
if name_args.empty?
|
27
27
|
ui.info "Usage: knife SUBCOMMAND (options)"
|
28
|
-
|
28
|
+
ui.msg ""
|
29
|
+
# This command is atypical, the user is likely not interested in usage of
|
30
|
+
# this command, but knife in general. So hack the banner.
|
31
|
+
opt_parser.banner = "General Knife Options:"
|
32
|
+
ui.msg opt_parser.to_s
|
29
33
|
ui.msg ""
|
30
34
|
ui.info "For further help:"
|
31
35
|
ui.info(<<-MOAR_HELP)
|
32
36
|
knife help list list help topics
|
33
37
|
knife help knife show general knife help
|
34
38
|
knife help TOPIC display the manual for TOPIC
|
35
|
-
knife
|
39
|
+
knife SUBCOMMAND --help show the options for a command
|
36
40
|
MOAR_HELP
|
37
41
|
exit 1
|
38
42
|
else
|
@@ -1,3 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Ryan Davis (<ryand-ruby@zenspider.com>)
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Author:: Nuo Yan (<nuo@opscode.com>)
|
5
|
+
# Copyright:: Copyright (c) 2011 Ryan Davis and Opscode, Inc.
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
1
21
|
require 'chef/knife'
|
2
22
|
|
3
23
|
class Chef
|
@@ -12,19 +32,20 @@ class Chef
|
|
12
32
|
|
13
33
|
def run
|
14
34
|
name = @name_args[0]
|
15
|
-
tags = @name_args[1..-1]
|
35
|
+
tags = @name_args[1..-1]
|
16
36
|
|
17
|
-
|
37
|
+
if name.nil? || tags.nil? || tags.empty?
|
18
38
|
show_usage
|
19
|
-
|
20
|
-
ui.fatal("You must specify a node name")
|
39
|
+
ui.fatal("You must specify a node name and at least one tag.")
|
21
40
|
exit 1
|
22
41
|
end
|
23
42
|
|
24
43
|
node = Chef::Node.load name
|
25
44
|
tags.each do |tag|
|
26
|
-
node.tags << tag
|
45
|
+
(node.tags << tag).uniq!
|
27
46
|
end
|
47
|
+
node.save
|
48
|
+
ui.info("Created tags #{tags.join(", ")} for node #{name}.")
|
28
49
|
end
|
29
50
|
end
|
30
51
|
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Ryan Davis (<ryand-ruby@zenspider.com>)
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Author:: Nuo Yan (<nuo@opscode.com>)
|
5
|
+
# Copyright:: Copyright (c) 2011 Ryan Davis and Opscode, Inc.
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
1
21
|
require 'chef/knife'
|
2
22
|
|
3
23
|
class Chef
|
@@ -12,19 +32,28 @@ class Chef
|
|
12
32
|
|
13
33
|
def run
|
14
34
|
name = @name_args[0]
|
15
|
-
tags = @name_args[1..-1]
|
35
|
+
tags = @name_args[1..-1]
|
16
36
|
|
17
|
-
|
37
|
+
if name.nil? || tags.nil? || tags.empty?
|
18
38
|
show_usage
|
19
|
-
|
20
|
-
ui.fatal("You must specify a node name")
|
39
|
+
ui.fatal("You must specify a node name and at least one tag.")
|
21
40
|
exit 1
|
22
41
|
end
|
23
42
|
|
24
43
|
node = Chef::Node.load name
|
44
|
+
deleted_tags = Array.new
|
25
45
|
tags.each do |tag|
|
26
|
-
node.tags.delete
|
46
|
+
unless node.tags.delete(tag).nil?
|
47
|
+
deleted_tags << tag
|
48
|
+
end
|
27
49
|
end
|
50
|
+
node.save
|
51
|
+
message = if deleted_tags.empty?
|
52
|
+
"Nothing has changed. The tags requested to be deleted do not exist."
|
53
|
+
else
|
54
|
+
"Deleted the following tags: #{deleted_tags.join(", ")}."
|
55
|
+
end
|
56
|
+
ui.info(message)
|
28
57
|
end
|
29
58
|
end
|
30
59
|
end
|
data/lib/chef/knife/tag_list.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Ryan Davis (<ryand-ruby@zenspider.com>)
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Author:: Nuo Yan (<nuo@opscode.com>)
|
5
|
+
# Copyright:: Copyright (c) 2011 Ryan Davis and Opscode, Inc.
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
1
21
|
require 'chef/knife'
|
2
22
|
|
3
23
|
class Chef
|
@@ -12,17 +32,15 @@ class Chef
|
|
12
32
|
|
13
33
|
def run
|
14
34
|
name = @name_args[0]
|
15
|
-
tags = @name_args[1..-1].join(",").split(/\s*,\s*/)
|
16
35
|
|
17
|
-
|
36
|
+
if name.nil?
|
18
37
|
show_usage
|
19
|
-
|
20
|
-
ui.fatal("You must specify a node name")
|
38
|
+
ui.fatal("You must specify a node name.")
|
21
39
|
exit 1
|
22
40
|
end
|
23
41
|
|
24
|
-
node = Chef::Node.load
|
25
|
-
output
|
42
|
+
node = Chef::Node.load(name)
|
43
|
+
output(node.tags)
|
26
44
|
end
|
27
45
|
end
|
28
46
|
end
|
data/lib/chef/node.rb
CHANGED
data/lib/chef/role.rb
CHANGED
data/lib/chef/shef.rb
CHANGED
data/lib/chef/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 7
|
5
|
-
version: 0.10.0.beta.
|
5
|
+
version: 0.10.0.beta.9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Adam Jacob
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-10 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- distro/common/html/knife-status.1.html
|
227
227
|
- distro/common/html/knife-tag.1.html
|
228
228
|
- distro/common/html/knife.1.html
|
229
|
+
- distro/common/html/shef.1.html
|
229
230
|
- distro/common/man/man1/knife-bootstrap.1
|
230
231
|
- distro/common/man/man1/knife-client.1
|
231
232
|
- distro/common/man/man1/knife-configure.1
|
@@ -236,7 +237,6 @@ files:
|
|
236
237
|
- distro/common/man/man1/knife-exec.1
|
237
238
|
- distro/common/man/man1/knife-index.1
|
238
239
|
- distro/common/man/man1/knife-node.1
|
239
|
-
- distro/common/man/man1/knife-recipe.1
|
240
240
|
- distro/common/man/man1/knife-role.1
|
241
241
|
- distro/common/man/man1/knife-search.1
|
242
242
|
- distro/common/man/man1/knife-ssh.1
|
@@ -259,13 +259,13 @@ files:
|
|
259
259
|
- distro/common/markdown/man1/knife-exec.mkd
|
260
260
|
- distro/common/markdown/man1/knife-index.mkd
|
261
261
|
- distro/common/markdown/man1/knife-node.mkd
|
262
|
-
- distro/common/markdown/man1/knife-recipe.mkd
|
263
262
|
- distro/common/markdown/man1/knife-role.mkd
|
264
263
|
- distro/common/markdown/man1/knife-search.mkd
|
265
264
|
- distro/common/markdown/man1/knife-ssh.mkd
|
266
265
|
- distro/common/markdown/man1/knife-status.mkd
|
267
266
|
- distro/common/markdown/man1/knife-tag.mkd
|
268
267
|
- distro/common/markdown/man1/knife.mkd
|
268
|
+
- distro/common/markdown/man1/shef.mkd
|
269
269
|
- distro/common/markdown/README
|
270
270
|
- distro/debian/etc/default/chef-client
|
271
271
|
- distro/debian/etc/default/chef-server
|