chef 0.10.2 → 0.10.4.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/knife-cookbook.1.html +5 -3
- data/distro/common/html/knife-node.1.html +4 -4
- data/distro/common/man/man1/knife-cookbook.1 +5 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +3 -3
- data/distro/common/markdown/man1/knife-cookbook.mkd +7 -0
- data/distro/common/markdown/man1/knife-node.mkd +4 -3
- data/distro/common/markdown/man1/knife-ssh.mkd +2 -0
- data/lib/chef/application.rb +1 -0
- data/lib/chef/cookbook_loader.rb +18 -0
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_bag.rb +14 -2
- data/lib/chef/data_bag_item.rb +8 -2
- data/lib/chef/encrypted_data_bag_item.rb +19 -6
- data/lib/chef/environment.rb +12 -6
- data/lib/chef/exceptions.rb +1 -0
- data/lib/chef/knife.rb +0 -28
- data/lib/chef/knife/bootstrap.rb +7 -0
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +14 -12
- data/lib/chef/knife/bootstrap/centos5-gems.erb +8 -5
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +16 -9
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -3
- data/lib/chef/knife/client_bulk_delete.rb +28 -6
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/cookbook_upload.rb +71 -0
- data/lib/chef/knife/core/bootstrap_context.rb +13 -3
- data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -3
- data/lib/chef/knife/core/node_presenter.rb +5 -2
- data/lib/chef/knife/help.rb +13 -12
- data/lib/chef/knife/help_topics.rb +4 -0
- data/lib/chef/knife/ssh.rb +25 -4
- data/lib/chef/mixin/create_path.rb +3 -2
- data/lib/chef/mixin/get_source_from_package.rb +42 -0
- data/lib/chef/mixin/language.rb +8 -11
- data/lib/chef/monkey_patches/numeric.rb +9 -1
- data/lib/chef/monkey_patches/string.rb +21 -0
- data/lib/chef/platform.rb +2 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/provider/git.rb +16 -3
- data/lib/chef/provider/group/suse.rb +53 -0
- data/lib/chef/provider/mount/mount.rb +28 -20
- data/lib/chef/provider/package/apt.rb +39 -24
- data/lib/chef/provider/package/dpkg.rb +5 -2
- data/lib/chef/provider/package/easy_install.rb +2 -2
- data/lib/chef/provider/package/freebsd.rb +5 -2
- data/lib/chef/provider/package/macports.rb +4 -4
- data/lib/chef/provider/package/rpm.rb +4 -1
- data/lib/chef/provider/package/rubygems.rb +3 -0
- data/lib/chef/provider/package/solaris.rb +3 -0
- data/lib/chef/provider/package/yum-dump.py +239 -81
- data/lib/chef/provider/package/yum.rb +977 -110
- data/lib/chef/provider/package/zypper.rb +20 -3
- data/lib/chef/provider/remote_directory.rb +0 -1
- data/lib/chef/provider/service/arch.rb +35 -28
- data/lib/chef/provider/service/systemd.rb +102 -0
- data/lib/chef/provider/service/upstart.rb +8 -2
- data/lib/chef/providers.rb +2 -0
- data/lib/chef/resource.rb +31 -2
- data/lib/chef/resource/git.rb +9 -0
- data/lib/chef/resource/mount.rb +1 -2
- data/lib/chef/resource/yum_package.rb +20 -0
- data/lib/chef/rest.rb +1 -1
- data/lib/chef/role.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/runner.rb +15 -2
- data/lib/chef/shell_out.rb +1 -1
- data/lib/chef/shell_out/windows.rb +2 -2
- data/lib/chef/solr_query.rb +1 -1
- data/lib/chef/tasks/chef_repo.rake +1 -1
- data/lib/chef/version.rb +1 -1
- metadata +425 -441
@@ -1,14 +1,17 @@
|
|
1
1
|
bash -c '
|
2
|
+
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
|
3
|
+
|
2
4
|
if [ ! -f /usr/bin/chef-client ]; then
|
3
|
-
|
4
|
-
|
5
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
|
6
|
+
rpm -Uvh epel-release-5-4.noarch.rpm
|
7
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>-O /etc/yum.repos.d/aegis.repo http://rpm.aegisco.com/aegisco/el5/aegisco.repo
|
5
8
|
|
6
9
|
yum install -y ruby-1.8.7.334-2.el5 ruby-devel-1.8.7.334-2.el5 gcc gcc-c++ automake autoconf make
|
7
10
|
|
8
11
|
cd /tmp
|
9
|
-
wget http://production.cf.rubygems.org/rubygems/rubygems-1.
|
10
|
-
tar zxf rubygems-1.
|
11
|
-
cd rubygems-1.
|
12
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz
|
13
|
+
tar zxf rubygems-1.6.2.tgz
|
14
|
+
cd rubygems-1.6.2
|
12
15
|
ruby setup.rb --no-format-executable
|
13
16
|
fi
|
14
17
|
|
@@ -1,32 +1,39 @@
|
|
1
1
|
bash -c '
|
2
|
+
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
|
3
|
+
|
2
4
|
if [ ! -f /usr/bin/chef-client ]; then
|
3
|
-
echo "chef chef/chef_server_url string <%=
|
4
|
-
[ -f /etc/apt/sources.list.d/opscode.list ] || echo "deb http://apt.opscode.com lucid main" > /etc/apt/sources.list.d/opscode.list
|
5
|
-
wget
|
5
|
+
echo "chef chef/chef_server_url string <%= @chef_config[:chef_server_url] %>" | debconf-set-selections
|
6
|
+
[ -f /etc/apt/sources.list.d/opscode.list ] || echo "deb http://apt.opscode.com <%= chef_version.to_f == 0.10 ? "lucid-0.10" : "lucid" %> main" > /etc/apt/sources.list.d/opscode.list
|
7
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>-O- http://apt.opscode.com/packages@opscode.com.gpg.key | apt-key add -
|
6
8
|
fi
|
7
9
|
apt-get update
|
8
10
|
apt-get install -y chef
|
9
11
|
|
10
|
-
<% unless Chef::Config[:validation_client_name] == "chef-validator" -%>
|
11
|
-
[ `grep -qx "validation_client_name \"<%= Chef::Config[:validation_client_name] %>\"" /etc/chef/client.rb` ] || echo "validation_client_name \"<%= Chef::Config[:validation_client_name] %>\"" >> /etc/chef/client.rb
|
12
|
-
<% end -%>
|
13
|
-
|
14
12
|
(
|
15
13
|
cat <<'EOP'
|
16
|
-
<%=
|
14
|
+
<%= validation_key %>
|
17
15
|
EOP
|
18
16
|
) > /tmp/validation.pem
|
19
17
|
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
20
18
|
rm /tmp/validation.pem
|
21
19
|
|
20
|
+
<% unless @chef_config[:validation_client_name] == "chef-validator" -%>
|
21
|
+
[ `grep -qx "validation_client_name \"<%= @chef_config[:validation_client_name] %>\"" /etc/chef/client.rb` ] || echo "validation_client_name \"<%= @chef_config[:validation_client_name] %>\"" >> /etc/chef/client.rb
|
22
|
+
<% end -%>
|
23
|
+
|
22
24
|
<% if @config[:chef_node_name] %>
|
23
25
|
[ `grep -qx "node_name \"<%= @config[:chef_node_name] %>\"" /etc/chef/client.rb` ] || echo "node_name \"<%= @config[:chef_node_name] %>\"" >> /etc/chef/client.rb
|
24
26
|
<% end -%>
|
25
27
|
|
28
|
+
<% if knife_config[:bootstrap_proxy] %>
|
29
|
+
echo 'http_proxy "knife_config[:bootstrap_proxy]"' >> /etc/chef/client.rb
|
30
|
+
echo 'https_proxy "knife_config[:bootstrap_proxy]"' >> /etc/chef/client.rb
|
31
|
+
<% end -%>
|
32
|
+
|
26
33
|
(
|
27
34
|
cat <<'EOP'
|
28
35
|
<%= { "run_list" => @run_list }.to_json %>
|
29
36
|
EOP
|
30
37
|
) > /etc/chef/first-boot.json
|
31
38
|
|
32
|
-
|
39
|
+
<%= start_chef %>'
|
@@ -1,14 +1,17 @@
|
|
1
1
|
bash -c '
|
2
|
+
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
|
3
|
+
|
2
4
|
if [ ! -f /usr/bin/chef-client ]; then
|
3
5
|
apt-get update
|
4
6
|
apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
|
5
7
|
cd /tmp
|
6
|
-
wget http://production.cf.rubygems.org/rubygems/rubygems-1.
|
7
|
-
tar zxf rubygems-1.
|
8
|
-
cd rubygems-1.
|
8
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz
|
9
|
+
tar zxf rubygems-1.6.2.tgz
|
10
|
+
cd rubygems-1.6.2
|
9
11
|
ruby setup.rb --no-format-executable
|
10
12
|
fi
|
11
13
|
|
14
|
+
gem update --no-rdoc --no-ri
|
12
15
|
gem install ohai --no-rdoc --no-ri --verbose
|
13
16
|
gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
|
14
17
|
|
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -29,12 +29,34 @@ class Chef
|
|
29
29
|
|
30
30
|
banner "knife client bulk delete REGEX (options)"
|
31
31
|
|
32
|
-
def run
|
33
|
-
if
|
32
|
+
def run
|
33
|
+
if name_args.length < 1
|
34
34
|
ui.fatal("You must supply a regular expression to match the results against")
|
35
35
|
exit 42
|
36
|
-
|
37
|
-
|
36
|
+
end
|
37
|
+
all_clients = Chef::ApiClient.list(true)
|
38
|
+
|
39
|
+
matcher = /#{name_args[0]}/
|
40
|
+
clients_to_delete = {}
|
41
|
+
all_clients.each do |name, client|
|
42
|
+
next unless name =~ matcher
|
43
|
+
clients_to_delete[client.name] = client
|
44
|
+
end
|
45
|
+
|
46
|
+
if clients_to_delete.empty?
|
47
|
+
ui.info "No clients match the expression /#{name_args[0]}/"
|
48
|
+
exit 0
|
49
|
+
end
|
50
|
+
|
51
|
+
ui.msg("The following clients will be deleted:")
|
52
|
+
ui.msg("")
|
53
|
+
ui.msg(ui.list(clients_to_delete.keys.sort, :columns_down))
|
54
|
+
ui.msg("")
|
55
|
+
ui.confirm("Are you sure you want to delete these clients")
|
56
|
+
|
57
|
+
clients_to_delete.sort.each do |name, client|
|
58
|
+
client.destroy
|
59
|
+
ui.msg("Deleted client #{name}")
|
38
60
|
end
|
39
61
|
end
|
40
62
|
end
|
@@ -36,7 +36,7 @@ class Chef
|
|
36
36
|
:short => "-D",
|
37
37
|
:long => "--no-dependencies",
|
38
38
|
:boolean => true,
|
39
|
-
:description => "
|
39
|
+
:description => "Do not install dependencies automatically"
|
40
40
|
|
41
41
|
option :cookbook_path,
|
42
42
|
:short => "-o PATH:PATH",
|
@@ -44,7 +44,7 @@ class Chef
|
|
44
44
|
:description => "A colon-separated path to look for cookbooks in",
|
45
45
|
:proc => lambda { |o| o.split(":") }
|
46
46
|
|
47
|
-
option :
|
47
|
+
option :default_branch,
|
48
48
|
:short => "-B BRANCH",
|
49
49
|
:long => "--branch BRANCH",
|
50
50
|
:description => "Default branch to work with",
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
3
|
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
|
+
# Author:: Nuo Yan (<yan.nuo@gmail.com>)
|
4
5
|
# Copyright:: Copyright (c) 2009, 2010 Opscode, Inc.
|
5
6
|
# License:: Apache License, Version 2.0
|
6
7
|
#
|
@@ -61,11 +62,20 @@ class Chef
|
|
61
62
|
:description => "Set ENVIRONMENT's version dependency match the version you're uploading.",
|
62
63
|
:default => nil
|
63
64
|
|
65
|
+
option :depends,
|
66
|
+
:short => "-d",
|
67
|
+
:long => "--include-dependencies",
|
68
|
+
:description => "Also upload cookbook dependencies"
|
69
|
+
|
64
70
|
def run
|
65
71
|
config[:cookbook_path] ||= Chef::Config[:cookbook_path]
|
66
72
|
|
67
73
|
assert_environment_valid!
|
74
|
+
warn_about_cookbook_shadowing
|
68
75
|
version_constraints_to_update = {}
|
76
|
+
# Get a list of cookbooks and their versions from the server
|
77
|
+
# for checking existence of dependending cookbooks.
|
78
|
+
@server_side_cookbooks = Chef::CookbookVersion.list
|
69
79
|
|
70
80
|
if config[:all]
|
71
81
|
justify_width = cookbook_repo.cookbook_names.map {|name| name.size}.max.to_i + 2
|
@@ -84,6 +94,11 @@ class Chef
|
|
84
94
|
@name_args.each do |cookbook_name|
|
85
95
|
begin
|
86
96
|
cookbook = cookbook_repo[cookbook_name]
|
97
|
+
if config[:depends]
|
98
|
+
cookbook.metadata.dependencies.each do |dep, versions|
|
99
|
+
@name_args.push dep
|
100
|
+
end
|
101
|
+
end
|
87
102
|
cookbook.freeze_version if config[:freeze]
|
88
103
|
upload(cookbook, justify_width)
|
89
104
|
version_constraints_to_update[cookbook_name] = cookbook.version
|
@@ -117,6 +132,22 @@ class Chef
|
|
117
132
|
@environment ||= config[:environment] ? Environment.load(config[:environment]) : nil
|
118
133
|
end
|
119
134
|
|
135
|
+
def warn_about_cookbook_shadowing
|
136
|
+
unless cookbook_repo.merged_cookbooks.empty?
|
137
|
+
ui.warn "* " * 40
|
138
|
+
ui.warn(<<-WARNING)
|
139
|
+
The cookbooks: #{cookbook_repo.merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path.
|
140
|
+
A composite version of these cookbooks has been compiled for uploading.
|
141
|
+
|
142
|
+
#{ui.color('IMPORTANT:', :red, :bold)} In a future version of Chef, this behavior will be removed and you will no longer
|
143
|
+
be able to have the same version of a cookbook in multiple places in your cookbook_path.
|
144
|
+
WARNING
|
145
|
+
ui.warn "The affected cookbooks are located:"
|
146
|
+
ui.output ui.format_for_display(cookbook_repo.merged_cookbook_paths)
|
147
|
+
ui.warn "* " * 40
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
120
151
|
private
|
121
152
|
|
122
153
|
def assert_environment_valid!
|
@@ -135,6 +166,7 @@ class Chef
|
|
135
166
|
ui.info("Uploading #{cookbook.name.to_s.ljust(justify_width + 10)} [#{cookbook.version}]")
|
136
167
|
|
137
168
|
check_for_broken_links(cookbook)
|
169
|
+
check_dependencies(cookbook)
|
138
170
|
Chef::CookbookUploader.new(cookbook, config[:cookbook_path], :force => config[:force]).upload_cookbook
|
139
171
|
rescue Net::HTTPServerException => e
|
140
172
|
case e.response.code
|
@@ -164,6 +196,45 @@ class Chef
|
|
164
196
|
end
|
165
197
|
end
|
166
198
|
|
199
|
+
def check_dependencies(cookbook)
|
200
|
+
# for each dependency, check if the version is on the server, or
|
201
|
+
# the version is in the cookbooks being uploaded. If not, exit and warn the user.
|
202
|
+
cookbook.metadata.dependencies.each do |cookbook_name, version|
|
203
|
+
unless check_server_side_cookbooks(cookbook_name, version) || check_uploading_cookbooks(cookbook_name, version)
|
204
|
+
# warn the user and exit
|
205
|
+
ui.error "Cookbook #{cookbook.name} depends on cookbook #{cookbook_name} version #{version},"
|
206
|
+
ui.error "which is not currently being uploaded and cannot be found on the server."
|
207
|
+
exit 1
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def check_server_side_cookbooks(cookbook_name, version)
|
213
|
+
if @server_side_cookbooks[cookbook_name].nil?
|
214
|
+
false
|
215
|
+
else
|
216
|
+
@server_side_cookbooks[cookbook_name]["versions"].each do |versions_hash|
|
217
|
+
return true if Chef::VersionConstraint.new(version).include?(versions_hash["version"])
|
218
|
+
end
|
219
|
+
false
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def check_uploading_cookbooks(cookbook_name, version)
|
224
|
+
if config[:all]
|
225
|
+
# check from all local cookbooks in the path
|
226
|
+
unless cookbook_repo[cookbook_name].nil?
|
227
|
+
return Chef::VersionConstraint.new(version).include?(cookbook_repo[cookbook_name].version)
|
228
|
+
end
|
229
|
+
else
|
230
|
+
# check from only those in the command argument
|
231
|
+
if @name_args.include?(cookbook_name)
|
232
|
+
return Chef::VersionConstraint.new(version).include?(cookbook_repo[cookbook_name].version)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
false
|
236
|
+
end
|
237
|
+
|
167
238
|
end
|
168
239
|
end
|
169
240
|
end
|
@@ -38,8 +38,7 @@ class Chef
|
|
38
38
|
if @config[:prerelease]
|
39
39
|
"--prerelease"
|
40
40
|
else
|
41
|
-
version
|
42
|
-
"--version #{version}"
|
41
|
+
"--version #{chef_version}"
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
@@ -63,17 +62,28 @@ CONFIG
|
|
63
62
|
else
|
64
63
|
client_rb << "# Using default node name (fqdn)\n"
|
65
64
|
end
|
65
|
+
|
66
|
+
if knife_config[:bootstrap_proxy]
|
67
|
+
client_rb << %Q{http_proxy "#{knife_config[:bootstrap_proxy]}"\n}
|
68
|
+
client_rb << %Q{https_proxy "#{knife_config[:bootstrap_proxy]}"\n}
|
69
|
+
end
|
66
70
|
client_rb
|
67
71
|
end
|
68
72
|
|
69
73
|
def start_chef
|
70
|
-
"/usr/bin/chef-client -j /etc/chef/first-boot.json
|
74
|
+
s = "/usr/bin/chef-client -j /etc/chef/first-boot.json"
|
75
|
+
s << " -E #{bootstrap_environment}" if chef_version.to_f != 0.9 # only use the -E option on Chef 0.10+
|
76
|
+
s
|
71
77
|
end
|
72
78
|
|
73
79
|
def knife_config
|
74
80
|
@chef_config.key?(:knife) ? @chef_config[:knife] : {}
|
75
81
|
end
|
76
82
|
|
83
|
+
def chef_version
|
84
|
+
knife_config[:bootstrap_version] || Chef::VERSION
|
85
|
+
end
|
86
|
+
|
77
87
|
end
|
78
88
|
end
|
79
89
|
end
|
@@ -34,6 +34,7 @@ class Chef
|
|
34
34
|
@repo_path = repo_path
|
35
35
|
@ui = ui
|
36
36
|
@default_branch = 'master'
|
37
|
+
apply_opts(opts)
|
37
38
|
end
|
38
39
|
|
39
40
|
def sanity_check
|
@@ -113,7 +114,7 @@ class Chef
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def branch_exists?(branch_name)
|
116
|
-
git("branch --no-color").stdout.lines.any? {|l| l.
|
117
|
+
git("branch --no-color").stdout.lines.any? {|l| l =~ /\s#{Regexp.escape(branch_name)}(?:\s|$)/ }
|
117
118
|
end
|
118
119
|
|
119
120
|
private
|
@@ -133,8 +134,6 @@ class Chef
|
|
133
134
|
case option.to_s
|
134
135
|
when 'default_branch'
|
135
136
|
@default_branch = value
|
136
|
-
else
|
137
|
-
raise ArgumentError, "invalid option `#{option}' passed to CookbookRepo.new()"
|
138
137
|
end
|
139
138
|
end
|
140
139
|
end
|
@@ -60,14 +60,17 @@ class Chef
|
|
60
60
|
def summarize(data)
|
61
61
|
if data.kind_of?(Chef::Node)
|
62
62
|
node = data
|
63
|
+
# special case ec2 with their split horizon whatsis.
|
64
|
+
ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
|
65
|
+
|
63
66
|
summarized=<<-SUMMARY
|
64
67
|
#{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)}
|
65
68
|
#{key('Environment:')} #{node.chef_environment}
|
66
69
|
#{key('FQDN:')} #{node[:fqdn]}
|
67
|
-
#{key('IP:')} #{
|
70
|
+
#{key('IP:')} #{ip}
|
68
71
|
#{key('Run List:')} #{node.run_list}
|
69
72
|
#{key('Roles:')} #{Array(node[:roles]).join(', ')}
|
70
|
-
#{key('Recipes')}
|
73
|
+
#{key('Recipes:')} #{Array(node[:recipes]).join(', ')}
|
71
74
|
#{key('Platform:')} #{node[:platform]} #{node[:platform_version]}
|
72
75
|
SUMMARY
|
73
76
|
if config[:medium_output] || config[:long_output]
|
data/lib/chef/knife/help.rb
CHANGED
@@ -55,23 +55,25 @@ MOAR_HELP
|
|
55
55
|
@topic = find_manpages_for_query(@query)
|
56
56
|
end
|
57
57
|
|
58
|
-
manpage_path =
|
58
|
+
manpage_path = find_manpage_path(@topic)
|
59
59
|
exec "man #{manpage_path}"
|
60
60
|
end
|
61
61
|
|
62
62
|
def help_topics
|
63
|
-
|
63
|
+
# The list of help topics is generated by a rake task from the available man pages
|
64
|
+
# This constant is provided in help_topics.rb which is automatically required/loaded by the knife subcommand loader.
|
65
|
+
HELP_TOPICS
|
64
66
|
end
|
65
67
|
|
66
68
|
def print_help_topics
|
67
69
|
ui.info "Available help topics are: "
|
68
|
-
help_topics.each do |topic|
|
70
|
+
help_topics.collect {|t| t.gsub(/knife-/, '') }.sort.each do |topic|
|
69
71
|
ui.msg " #{topic}"
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
75
|
def find_manpages_for_query(query)
|
74
|
-
possibilities =
|
76
|
+
possibilities = help_topics.select do |manpage|
|
75
77
|
::File.fnmatch("knife-#{query}*", manpage) || ::File.fnmatch("#{query}*", manpage)
|
76
78
|
end
|
77
79
|
if possibilities.empty?
|
@@ -87,16 +89,15 @@ MOAR_HELP
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
def find_manpage_path(topic)
|
93
|
+
if ::File.exists?(::File.expand_path("../distro/common/man/man1/#{topic}.1", CHEF_ROOT))
|
94
|
+
# If we've provided the man page in the gem, give that
|
95
|
+
return ::File.expand_path("../distro/common/man/man1/#{topic}.1", CHEF_ROOT)
|
96
|
+
else
|
97
|
+
# Otherwise, we'll just be using MANPATH
|
98
|
+
topic
|
97
99
|
end
|
98
100
|
end
|
99
|
-
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
# Do not edit this file by hand
|
2
|
+
# This file is autogenerated by the docs:list rake task from the available manpages
|
3
|
+
|
4
|
+
HELP_TOPICS = ["knife-ssh", "knife-environment", "knife-bootstrap", "knife-cookbook", "knife-exec", "knife-tag", "knife-status", "knife", "knife-data-bag", "knife-index", "knife-configure", "knife-search", "knife-node", "knife-client", "shef", "knife-role", "knife-cookbook-site"]
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -149,9 +149,8 @@ class Chef
|
|
149
149
|
data.split(/\n/).each { |d| print_data(host, d) }
|
150
150
|
else
|
151
151
|
padding = @longest - host.length
|
152
|
-
|
153
|
-
|
154
|
-
puts data
|
152
|
+
str = ui.color(host, :cyan) + (" " * (padding + 1)) + data
|
153
|
+
ui.msg(str)
|
155
154
|
end
|
156
155
|
end
|
157
156
|
|
@@ -241,6 +240,7 @@ class Chef
|
|
241
240
|
window = 0
|
242
241
|
session.servers_for.each do |server|
|
243
242
|
tf.print("screen -t \"#{server.host}\" #{window} ssh ")
|
243
|
+
tf.print("-i #{config[:identity_file]} ") if config[:identity_file]
|
244
244
|
server.user ? tf.puts("#{server.user}@#{server.host}") : tf.puts(server.host)
|
245
245
|
window += 1
|
246
246
|
end
|
@@ -250,8 +250,9 @@ class Chef
|
|
250
250
|
|
251
251
|
def tmux
|
252
252
|
ssh_dest = lambda do |server|
|
253
|
+
identity = "-i #{config[:identity_file]} " if config[:identity_file]
|
253
254
|
prefix = server.user ? "#{server.user}@" : ""
|
254
|
-
"'ssh #{prefix}#{server.host}'"
|
255
|
+
"'ssh #{identity}#{prefix}#{server.host}'"
|
255
256
|
end
|
256
257
|
|
257
258
|
new_window_cmds = lambda do
|
@@ -300,11 +301,31 @@ class Chef
|
|
300
301
|
end
|
301
302
|
end
|
302
303
|
|
304
|
+
def configure_attribute
|
305
|
+
config[:attribute] = (config[:attribute] ||
|
306
|
+
Chef::Config[:knife][:ssh_attribute] ||
|
307
|
+
"fqdn").strip
|
308
|
+
end
|
309
|
+
|
310
|
+
def configure_user
|
311
|
+
config[:ssh_user] = (config[:ssh_user] ||
|
312
|
+
Chef::Config[:knife][:ssh_user])
|
313
|
+
config[:ssh_user].strip! unless config[:ssh_user].nil?
|
314
|
+
end
|
315
|
+
|
316
|
+
def configure_identity_file
|
317
|
+
config[:identity_file] = (config[:identity_file] || Chef::Config[:knife][:ssh_identity_file])
|
318
|
+
config[:identity_file].strip! unless config[:identity_file].nil?
|
319
|
+
end
|
320
|
+
|
303
321
|
def run
|
304
322
|
extend Chef::Mixin::Command
|
305
323
|
|
306
324
|
@longest = 0
|
307
325
|
|
326
|
+
configure_attribute
|
327
|
+
configure_user
|
328
|
+
configure_identity_file
|
308
329
|
configure_session
|
309
330
|
|
310
331
|
case @name_args[1]
|