chef 0.8.10 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/bin/chef-client +2 -2
- data/bin/chef-solo +1 -2
- data/bin/knife +1 -2
- data/bin/shef +2 -5
- data/lib/chef.rb +11 -7
- data/lib/chef/application.rb +25 -20
- data/lib/chef/application/client.rb +12 -7
- data/lib/chef/application/knife.rb +7 -1
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/applications.rb +4 -0
- data/lib/chef/cache/checksum.rb +7 -6
- data/lib/chef/certificate.rb +2 -2
- data/lib/chef/client.rb +28 -4
- data/lib/chef/config.rb +4 -3
- data/lib/chef/cookbook_loader.rb +6 -1
- data/lib/chef/daemon.rb +2 -0
- data/lib/chef/data_bag_item.rb +2 -1
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/file_cache.rb +18 -18
- data/lib/chef/index_queue/indexable.rb +5 -3
- data/lib/chef/knife.rb +45 -13
- data/lib/chef/knife/client_list.rb +1 -1
- data/lib/chef/knife/client_show.rb +1 -1
- data/lib/chef/knife/configure.rb +47 -36
- data/lib/chef/knife/cookbook_list.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +22 -27
- data/lib/chef/knife/cookbook_metadata_from_file.rb +40 -0
- data/lib/chef/knife/cookbook_show.rb +2 -2
- data/lib/chef/knife/cookbook_site_download.rb +57 -0
- data/lib/chef/knife/cookbook_site_list.rb +55 -0
- data/lib/chef/knife/cookbook_site_search.rb +50 -0
- data/lib/chef/knife/cookbook_site_show.rb +56 -0
- data/lib/chef/knife/cookbook_site_vendor.rb +114 -0
- data/lib/chef/knife/cookbook_test.rb +103 -0
- data/lib/chef/knife/cookbook_upload.rb +29 -38
- data/lib/chef/knife/data_bag_edit.rb +1 -1
- data/lib/chef/knife/data_bag_list.rb +2 -2
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/ec2_instance_data.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +2 -2
- data/lib/chef/knife/node_from_file.rb +1 -1
- data/lib/chef/knife/node_list.rb +2 -2
- data/lib/chef/knife/node_run_list_add.rb +1 -1
- data/lib/chef/knife/node_run_list_remove.rb +1 -1
- data/lib/chef/knife/node_show.rb +1 -1
- data/lib/chef/knife/rackspace_server_create.rb +156 -0
- data/lib/chef/knife/rackspace_server_delete.rb +57 -0
- data/lib/chef/knife/rackspace_server_list.rb +59 -0
- data/lib/chef/knife/role_from_file.rb +1 -1
- data/lib/chef/knife/role_list.rb +1 -1
- data/lib/chef/knife/role_show.rb +1 -1
- data/lib/chef/knife/search.rb +1 -1
- data/lib/chef/knife/ssh.rb +21 -4
- data/lib/chef/knife/terremark_server_create.rb +152 -0
- data/lib/chef/knife/terremark_server_delete.rb +87 -0
- data/lib/chef/knife/terremark_server_list.rb +77 -0
- data/lib/chef/mixin/command.rb +11 -9
- data/lib/chef/mixin/params_validate.rb +1 -1
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +4 -1
- data/lib/chef/mixin/template.rb +6 -5
- data/lib/chef/mixin/xml_escape.rb +3 -3
- data/lib/chef/mixins.rb +16 -0
- data/lib/chef/node.rb +53 -52
- data/lib/chef/openid_registration.rb +0 -1
- data/lib/chef/platform.rb +171 -137
- data/lib/chef/provider.rb +2 -2
- data/lib/chef/provider/cron.rb +22 -22
- data/lib/chef/provider/deploy/revision.rb +5 -1
- data/lib/chef/provider/erl_call.rb +2 -2
- data/lib/chef/provider/file.rb +44 -23
- data/lib/chef/provider/group/dscl.rb +6 -4
- data/lib/chef/provider/mdadm.rb +0 -4
- data/lib/chef/provider/mount/mount.rb +20 -8
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/package/freebsd.rb +22 -18
- data/lib/chef/provider/package/rubygems.rb +7 -10
- data/lib/chef/provider/remote_directory.rb +15 -0
- data/lib/chef/provider/remote_file.rb +73 -50
- data/lib/chef/provider/script.rb +10 -8
- data/lib/chef/provider/service/windows.rb +129 -0
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/template.rb +51 -50
- data/lib/chef/providers.rb +80 -0
- data/lib/chef/recipe.rb +2 -4
- data/lib/chef/resource.rb +21 -7
- data/lib/chef/resource/cron.rb +14 -5
- data/lib/chef/resource/deploy.rb +52 -45
- data/lib/chef/resource/execute.rb +1 -1
- data/lib/chef/resource/file.rb +16 -8
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/remote_directory.rb +19 -10
- data/lib/chef/resource/scm.rb +23 -16
- data/lib/chef/resource/service.rb +10 -1
- data/lib/chef/resources.rb +60 -0
- data/lib/chef/rest.rb +234 -189
- data/lib/chef/rest/auth_credentials.rb +78 -0
- data/lib/chef/{application/server.rb → rest/cookie_jar.rb} +18 -6
- data/lib/chef/rest/rest_request.rb +151 -0
- data/lib/chef/role.rb +38 -46
- data/lib/chef/streaming_cookbook_uploader.rb +8 -2
- data/lib/chef/tasks/chef_repo.rake +14 -4
- data/lib/chef/util/file_edit.rb +0 -1
- data/lib/chef/webui_user.rb +0 -1
- metadata +46 -9
- data/distro/suse/etc/init.d/chef-client +0 -121
data/lib/chef/knife/node_list.rb
CHANGED
data/lib/chef/knife/node_show.rb
CHANGED
@@ -0,0 +1,156 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife'
|
20
|
+
require 'json'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Knife
|
24
|
+
class RackspaceServerCreate < Knife
|
25
|
+
|
26
|
+
banner "Sub-Command: rackspace server create [RUN LIST...] (options)"
|
27
|
+
|
28
|
+
option :flavor,
|
29
|
+
:short => "-f FLAVOR",
|
30
|
+
:long => "--flavor FLAVOR",
|
31
|
+
:description => "The flavor of server",
|
32
|
+
:proc => Proc.new { |f| f.to_i },
|
33
|
+
:default => 1
|
34
|
+
|
35
|
+
option :image,
|
36
|
+
:short => "-i IMAGE",
|
37
|
+
:long => "--image IMAGE",
|
38
|
+
:description => "The image of the server",
|
39
|
+
:proc => Proc.new { |i| i.to_i },
|
40
|
+
:default => 14362
|
41
|
+
|
42
|
+
option :server_name,
|
43
|
+
:short => "-N NAME",
|
44
|
+
:long => "--server-name NAME",
|
45
|
+
:description => "The server name",
|
46
|
+
:default => "wtf"
|
47
|
+
|
48
|
+
option :api_key,
|
49
|
+
:short => "-K KEY",
|
50
|
+
:long => "--rackspace-api-key KEY",
|
51
|
+
:description => "Your rackspace API key",
|
52
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
|
53
|
+
|
54
|
+
option :api_username,
|
55
|
+
:short => "-A USERNAME",
|
56
|
+
:long => "--rackspace-api-username USERNAME",
|
57
|
+
:description => "Your rackspace API username",
|
58
|
+
:proc => Proc.new { |username| Chef::Config[:knife][:rackspace_api_username] = username }
|
59
|
+
|
60
|
+
def h
|
61
|
+
@highline ||= HighLine.new
|
62
|
+
end
|
63
|
+
|
64
|
+
def run
|
65
|
+
require 'fog'
|
66
|
+
require 'highline'
|
67
|
+
require 'net/ssh/multi'
|
68
|
+
require 'readline'
|
69
|
+
|
70
|
+
connection = Fog::Rackspace::Servers.new(
|
71
|
+
:rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
|
72
|
+
:rackspace_username => Chef::Config[:knife][:rackspace_api_username]
|
73
|
+
)
|
74
|
+
|
75
|
+
server = connection.servers.new
|
76
|
+
|
77
|
+
server.flavor_id = config[:flavor]
|
78
|
+
server.image_id = config[:image]
|
79
|
+
server.name = config[:server_name]
|
80
|
+
server.personality = [
|
81
|
+
{
|
82
|
+
'path' => '/etc/install-chef',
|
83
|
+
'contents' => <<-EOH
|
84
|
+
#!/bin/bash
|
85
|
+
# Customized rc.local for chef installation
|
86
|
+
|
87
|
+
if [ ! -f /usr/bin/chef-client ]; then
|
88
|
+
apt-get update
|
89
|
+
apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
|
90
|
+
cd /tmp
|
91
|
+
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
|
92
|
+
tar xvf rubygems-1.3.6.tgz
|
93
|
+
cd rubygems-1.3.6
|
94
|
+
ruby setup.rb
|
95
|
+
cp /usr/bin/gem1.8 /usr/bin/gem
|
96
|
+
gem install chef ohai --no-rdoc --no-ri --verbose
|
97
|
+
fi
|
98
|
+
|
99
|
+
exit 0
|
100
|
+
EOH
|
101
|
+
},
|
102
|
+
{
|
103
|
+
'path' => "/etc/chef/validation.pem",
|
104
|
+
'contents' => IO.read(Chef::Config[:validation_key])
|
105
|
+
},
|
106
|
+
{
|
107
|
+
'path' => "/etc/chef/client.rb",
|
108
|
+
'contents' => <<-EOH
|
109
|
+
log_level :info
|
110
|
+
log_location STDOUT
|
111
|
+
chef_server_url "#{Chef::Config[:chef_server_url]}"
|
112
|
+
validation_client_name "#{Chef::Config[:validation_client_name]}"
|
113
|
+
EOH
|
114
|
+
},
|
115
|
+
{
|
116
|
+
'path' => "/etc/chef/first-boot.json",
|
117
|
+
'contents' => { "run_list" => @name_args }.to_json
|
118
|
+
},
|
119
|
+
]
|
120
|
+
|
121
|
+
server.save
|
122
|
+
|
123
|
+
$stdout.sync = true
|
124
|
+
|
125
|
+
puts "#{h.color("Name", :cyan)}: #{server.name}"
|
126
|
+
puts "#{h.color("Flavor", :cyan)}: #{server.flavor_id}"
|
127
|
+
puts "#{h.color("Image", :cyan)}: #{server.image_id}"
|
128
|
+
puts "#{h.color("Public Address", :cyan)}: #{server.addresses["public"]}"
|
129
|
+
puts "#{h.color("Private Address", :cyan)}: #{server.addresses["private"]}"
|
130
|
+
puts "#{h.color("Password", :cyan)}: #{server.password}"
|
131
|
+
|
132
|
+
print "\n#{h.color("Requesting server", :magenta)}"
|
133
|
+
saved_password = server.password
|
134
|
+
|
135
|
+
# wait for it to be ready to do stuff
|
136
|
+
server.wait_for { print "."; ready? }
|
137
|
+
|
138
|
+
puts "\nServer ready, waiting 15 seconds to bootstrap."
|
139
|
+
sleep 15
|
140
|
+
|
141
|
+
puts "\nBootstrapping #{h.color(server.name, :bold)}..."
|
142
|
+
|
143
|
+
ssh = Chef::Knife::Ssh.new
|
144
|
+
ssh.name_args = [ server.addresses["public"][0], "/bin/bash /etc/install-chef && /usr/bin/chef-client -j /etc/chef/first-boot.json" ]
|
145
|
+
ssh.config[:ssh_user] = "root"
|
146
|
+
ssh.config[:manual] = true
|
147
|
+
ssh.config[:password] = saved_password
|
148
|
+
ssh.password = saved_password
|
149
|
+
ssh.run
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife'
|
20
|
+
require 'json'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Knife
|
24
|
+
class RackspaceServerDelete < Knife
|
25
|
+
|
26
|
+
banner "Sub-Command: rackspace server delete SERVER (options)"
|
27
|
+
|
28
|
+
def h
|
29
|
+
@highline ||= HighLine.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
require 'fog'
|
34
|
+
require 'highline'
|
35
|
+
require 'net/ssh/multi'
|
36
|
+
require 'readline'
|
37
|
+
|
38
|
+
connection = Fog::Rackspace::Servers.new(
|
39
|
+
:rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
|
40
|
+
:rackspace_username => Chef::Config[:knife][:rackspace_api_username]
|
41
|
+
)
|
42
|
+
|
43
|
+
server = connection.servers.get(@name_args[0])
|
44
|
+
|
45
|
+
confirm("Do you really want to delete server ID #{server.id} named #{server.name}")
|
46
|
+
|
47
|
+
server.destroy
|
48
|
+
|
49
|
+
Chef::Log.warn("Deleted server #{server.id} named #{server.name}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife'
|
20
|
+
require 'json'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Knife
|
24
|
+
class RackspaceServerList < Knife
|
25
|
+
|
26
|
+
banner "Sub-Command: rackspace server list (options)"
|
27
|
+
|
28
|
+
def h
|
29
|
+
@highline ||= HighLine.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
require 'fog'
|
34
|
+
require 'highline'
|
35
|
+
require 'net/ssh/multi'
|
36
|
+
require 'readline'
|
37
|
+
|
38
|
+
connection = Fog::Rackspace::Servers.new(
|
39
|
+
:rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
|
40
|
+
:rackspace_username => Chef::Config[:knife][:rackspace_api_username]
|
41
|
+
)
|
42
|
+
|
43
|
+
server_list = [ h.color('ID', :bold), h.color('Name', :bold), h.color('Public IP', :bold), h.color('Private IP', :bold), h.color('Flavor ID', :bold) ]
|
44
|
+
connection.servers.all.each do |server|
|
45
|
+
server_list << server.id.to_s
|
46
|
+
server_list << server.name
|
47
|
+
server_list << server.addresses["public"][0]
|
48
|
+
server_list << server.addresses["private"][0]
|
49
|
+
server_list << server.flavor_id.to_s
|
50
|
+
end
|
51
|
+
puts h.list(server_list, :columns_across, 5)
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
data/lib/chef/knife/role_list.rb
CHANGED
data/lib/chef/knife/role_show.rb
CHANGED
data/lib/chef/knife/search.rb
CHANGED
data/lib/chef/knife/ssh.rb
CHANGED
@@ -23,6 +23,8 @@ class Chef
|
|
23
23
|
class Knife
|
24
24
|
class Ssh < Knife
|
25
25
|
|
26
|
+
attr_writer :password
|
27
|
+
|
26
28
|
banner "Sub-Command: ssh QUERY COMMAND (options)"
|
27
29
|
|
28
30
|
option :concurrency,
|
@@ -44,11 +46,20 @@ class Chef
|
|
44
46
|
:description => "QUERY is a space separated list of servers",
|
45
47
|
:default => false
|
46
48
|
|
49
|
+
option :ssh_user,
|
50
|
+
:short => "-x USERNAME",
|
51
|
+
:long => "--ssh-user USERNAME",
|
52
|
+
:description => "The ssh username"
|
53
|
+
|
54
|
+
option :ssh_password,
|
55
|
+
:short => "-P PASSWORD",
|
56
|
+
:long => "--ssh-password PASSWORD",
|
57
|
+
:description => "The ssh password"
|
58
|
+
|
47
59
|
def session
|
48
60
|
@session ||= Net::SSH::Multi.start(:concurrent_connections => config[:concurrency])
|
49
61
|
end
|
50
62
|
|
51
|
-
|
52
63
|
def h
|
53
64
|
@highline ||= HighLine.new
|
54
65
|
end
|
@@ -71,7 +82,12 @@ class Chef
|
|
71
82
|
def session_from_list(list)
|
72
83
|
list.each do |item|
|
73
84
|
Chef::Log.debug("Adding #{item}")
|
74
|
-
|
85
|
+
|
86
|
+
if config[:password]
|
87
|
+
session.use config[:ssh_user] ? "#{config[:ssh_user]}@#{item}" : item, :password => config[:password]
|
88
|
+
else
|
89
|
+
session.use config[:ssh_user] ? "#{config[:ssh_user]}@#{item}" : item
|
90
|
+
end
|
75
91
|
@longest = item.length if item.length > @longest
|
76
92
|
end
|
77
93
|
session
|
@@ -173,8 +189,9 @@ class Chef
|
|
173
189
|
tf.puts("caption always '%w'")
|
174
190
|
tf.puts("hardstatus alwayslastline 'knife ssh #{@name_args[0]}'")
|
175
191
|
window = 0
|
176
|
-
session.servers_for.
|
177
|
-
tf.
|
192
|
+
session.servers_for.each do |server|
|
193
|
+
tf.print("screen -t \"#{server.host}\" #{window} ssh ")
|
194
|
+
server.user ? tf.puts("#{server.user}@#{server.host}") : tf.puts(server.host)
|
178
195
|
window += 1
|
179
196
|
end
|
180
197
|
tf.close
|