chef 0.9.18 → 0.10.0.beta.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.
- data/README.rdoc +0 -3
- data/distro/arch/etc/rc.d/chef-server +0 -4
- data/distro/arch/etc/rc.d/chef-server-webui +0 -4
- data/distro/arch/etc/rc.d/chef-solr +0 -4
- data/distro/arch/etc/rc.d/chef-solr-indexer +0 -4
- data/lib/chef.rb +3 -3
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +11 -1
- data/lib/chef/application/client.rb +18 -22
- data/lib/chef/application/knife.rb +28 -29
- data/lib/chef/application/solo.rb +14 -12
- data/lib/chef/client.rb +112 -54
- data/lib/chef/config.rb +4 -0
- data/lib/chef/cookbook/chefignore.rb +66 -0
- data/lib/chef/cookbook/cookbook_collection.rb +6 -5
- data/lib/chef/cookbook/cookbook_version_loader.rb +151 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +10 -8
- data/lib/chef/cookbook/metadata.rb +200 -108
- data/lib/chef/cookbook_loader.rb +39 -163
- data/lib/chef/cookbook_uploader.rb +100 -78
- data/lib/chef/cookbook_version.rb +92 -47
- data/lib/chef/cookbook_version_selector.rb +163 -0
- data/lib/chef/couchdb.rb +9 -1
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item.rb +126 -0
- data/lib/chef/environment.rb +386 -0
- data/lib/chef/exceptions.rb +82 -1
- data/lib/chef/index_queue/amqp_client.rb +15 -12
- data/lib/chef/index_queue/indexable.rb +38 -4
- data/lib/chef/json_compat.rb +3 -3
- data/lib/chef/knife.rb +97 -202
- data/lib/chef/knife/bootstrap.rb +27 -61
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +4 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +6 -15
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +3 -4
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -5
- data/lib/chef/knife/client_bulk_delete.rb +6 -3
- data/lib/chef/knife/client_create.rb +13 -10
- data/lib/chef/knife/client_delete.rb +10 -7
- data/lib/chef/knife/client_edit.rb +9 -6
- data/lib/chef/knife/client_list.rb +8 -5
- data/lib/chef/knife/client_reregister.rb +9 -6
- data/lib/chef/knife/client_show.rb +9 -6
- data/lib/chef/knife/configure.rb +15 -19
- data/lib/chef/knife/configure_client.rb +4 -4
- data/lib/chef/knife/cookbook_bulk_delete.rb +11 -8
- data/lib/chef/knife/cookbook_create.rb +120 -55
- data/lib/chef/knife/cookbook_delete.rb +18 -12
- data/lib/chef/knife/cookbook_download.rb +10 -6
- data/lib/chef/knife/cookbook_list.rb +15 -6
- data/lib/chef/knife/cookbook_metadata.rb +41 -21
- data/lib/chef/knife/cookbook_metadata_from_file.rb +4 -0
- data/lib/chef/knife/cookbook_show.rb +16 -5
- data/lib/chef/knife/cookbook_site_download.rb +2 -2
- data/lib/chef/knife/cookbook_site_share.rb +18 -13
- data/lib/chef/knife/cookbook_site_unshare.rb +7 -4
- data/lib/chef/knife/cookbook_site_vendor.rb +21 -18
- data/lib/chef/knife/cookbook_test.rb +14 -14
- data/lib/chef/knife/cookbook_upload.rb +91 -40
- data/lib/chef/knife/data_bag_create.rb +41 -6
- data/lib/chef/knife/data_bag_delete.rb +5 -3
- data/lib/chef/knife/data_bag_edit.rb +55 -11
- data/lib/chef/knife/data_bag_from_file.rb +47 -7
- data/lib/chef/knife/data_bag_list.rb +4 -1
- data/lib/chef/knife/data_bag_show.rb +44 -4
- data/lib/chef/knife/environment_create.rb +53 -0
- data/lib/chef/knife/environment_delete.rb +45 -0
- data/lib/chef/knife/environment_edit.rb +45 -0
- data/lib/chef/knife/environment_from_file.rb +39 -0
- data/lib/chef/knife/environment_list.rb +42 -0
- data/lib/chef/knife/environment_show.rb +46 -0
- data/lib/chef/knife/exec.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +8 -9
- data/lib/chef/knife/node_bulk_delete.rb +9 -6
- data/lib/chef/knife/node_create.rb +9 -6
- data/lib/chef/knife/node_delete.rb +10 -7
- data/lib/chef/knife/node_edit.rb +129 -10
- data/lib/chef/knife/node_from_file.rb +10 -7
- data/lib/chef/knife/node_list.rb +11 -6
- data/lib/chef/knife/node_run_list_add.rb +10 -7
- data/lib/chef/knife/node_run_list_remove.rb +9 -6
- data/lib/chef/knife/node_show.rb +15 -7
- data/lib/chef/knife/recipe_list.rb +4 -3
- data/lib/chef/knife/role_bulk_delete.rb +9 -6
- data/lib/chef/knife/role_create.rb +9 -6
- data/lib/chef/knife/role_delete.rb +10 -7
- data/lib/chef/knife/role_edit.rb +11 -8
- data/lib/chef/knife/role_from_file.rb +10 -7
- data/lib/chef/knife/role_list.rb +8 -5
- data/lib/chef/knife/role_show.rb +11 -8
- data/lib/chef/knife/search.rb +33 -10
- data/lib/chef/knife/ssh.rb +33 -61
- data/lib/chef/knife/status.rb +7 -4
- data/lib/chef/knife/subcommand_loader.rb +101 -0
- data/lib/chef/knife/tag_create.rb +31 -0
- data/lib/chef/knife/tag_delete.rb +31 -0
- data/lib/chef/knife/tag_list.rb +29 -0
- data/lib/chef/knife/ui.rb +229 -0
- data/lib/chef/knife/windows_bootstrap.rb +8 -5
- data/lib/chef/log.rb +5 -59
- data/lib/chef/mash.rb +211 -0
- data/lib/chef/mixins.rb +1 -2
- data/lib/chef/nil_argument.rb +3 -0
- data/lib/chef/node.rb +96 -34
- data/lib/chef/platform.rb +27 -0
- data/lib/chef/provider/cookbook_file.rb +21 -20
- data/lib/chef/provider/deploy/revision.rb +3 -0
- data/lib/chef/provider/file.rb +20 -11
- data/lib/chef/provider/git.rb +26 -26
- data/lib/chef/provider/group/aix.rb +70 -0
- data/lib/chef/provider/group/groupadd.rb +7 -4
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/package.rb +28 -28
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/portage.rb +50 -39
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +3 -20
- data/lib/chef/provider/remote_directory.rb +0 -2
- data/lib/chef/provider/remote_file.rb +2 -3
- data/lib/chef/provider/service/arch.rb +28 -35
- data/lib/chef/provider/service/simple.rb +1 -1
- data/lib/chef/provider/subversion.rb +22 -22
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/recipe.rb +10 -12
- data/lib/chef/resource.rb +49 -42
- data/lib/chef/resource/gem_package.rb +7 -3
- data/lib/chef/resource/git.rb +5 -5
- data/lib/chef/resource/package.rb +7 -7
- data/lib/chef/resource/scm.rb +2 -1
- data/lib/chef/resource/solaris_package.rb +0 -1
- data/lib/chef/resource/yum_package.rb +0 -1
- data/lib/chef/rest.rb +7 -16
- data/lib/chef/rest/rest_request.rb +0 -16
- data/lib/chef/role.rb +67 -13
- data/lib/chef/run_context.rb +37 -21
- data/lib/chef/run_list.rb +30 -15
- data/lib/chef/run_list/run_list_expansion.rb +41 -20
- data/lib/chef/run_list/run_list_item.rb +20 -6
- data/lib/chef/run_list/versioned_recipe_list.rb +68 -0
- data/lib/chef/runner.rb +7 -15
- data/lib/chef/search/query.rb +12 -7
- data/lib/chef/shef.rb +6 -7
- data/lib/chef/shef/shef_session.rb +40 -35
- data/lib/chef/shell_out.rb +22 -201
- data/lib/chef/shell_out/unix.rb +224 -0
- data/lib/chef/shell_out/windows.rb +95 -0
- data/lib/chef/solr_query.rb +187 -0
- data/lib/chef/solr_query/lucene.treetop +145 -0
- data/lib/chef/solr_query/lucene_nodes.rb +285 -0
- data/lib/chef/solr_query/query_transform.rb +65 -0
- data/lib/chef/solr_query/solr_http_request.rb +118 -0
- data/lib/chef/version.rb +4 -2
- data/lib/chef/version_class.rb +70 -0
- data/lib/chef/version_constraint.rb +116 -0
- metadata +68 -37
- data/lib/chef/cookbook/metadata/version.rb +0 -87
- data/lib/chef/knife/bluebox_images_list.rb +0 -54
- data/lib/chef/knife/bluebox_server_create.rb +0 -157
- data/lib/chef/knife/bluebox_server_delete.rb +0 -63
- data/lib/chef/knife/bluebox_server_list.rb +0 -59
- data/lib/chef/knife/ec2_instance_data.rb +0 -46
- data/lib/chef/knife/ec2_server_create.rb +0 -218
- data/lib/chef/knife/ec2_server_delete.rb +0 -87
- data/lib/chef/knife/ec2_server_list.rb +0 -89
- data/lib/chef/knife/rackspace_server_create.rb +0 -184
- data/lib/chef/knife/rackspace_server_delete.rb +0 -57
- data/lib/chef/knife/rackspace_server_list.rb +0 -59
- data/lib/chef/knife/slicehost_images_list.rb +0 -53
- data/lib/chef/knife/slicehost_server_create.rb +0 -103
- data/lib/chef/knife/slicehost_server_delete.rb +0 -61
- data/lib/chef/knife/slicehost_server_list.rb +0 -64
- data/lib/chef/knife/terremark_server_create.rb +0 -152
- data/lib/chef/knife/terremark_server_delete.rb +0 -87
- data/lib/chef/knife/terremark_server_list.rb +0 -77
- data/lib/chef/mixin/find_preferred_file.rb +0 -92
|
@@ -1,57 +0,0 @@
|
|
|
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 'chef/json_compat'
|
|
21
|
-
|
|
22
|
-
class Chef
|
|
23
|
-
class Knife
|
|
24
|
-
class RackspaceServerDelete < Knife
|
|
25
|
-
|
|
26
|
-
banner "knife 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::Compute.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
|
-
|
|
@@ -1,59 +0,0 @@
|
|
|
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 'chef/json_compat'
|
|
21
|
-
|
|
22
|
-
class Chef
|
|
23
|
-
class Knife
|
|
24
|
-
class RackspaceServerList < Knife
|
|
25
|
-
|
|
26
|
-
banner "knife 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::Compute.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
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Author:: Ian Meyer (<ianmmeyer@gmail.com>)
|
|
3
|
-
# Copyright:: Copyright (c) 2010 Ian Meyer
|
|
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 'chef/json_compat'
|
|
21
|
-
|
|
22
|
-
class Chef
|
|
23
|
-
class Knife
|
|
24
|
-
class SlicehostImagesList < Knife
|
|
25
|
-
|
|
26
|
-
banner "knife slicehost images list"
|
|
27
|
-
|
|
28
|
-
def highline
|
|
29
|
-
@highline ||= HighLine.new
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def run
|
|
33
|
-
require 'fog'
|
|
34
|
-
require 'highline'
|
|
35
|
-
|
|
36
|
-
slicehost = Fog::Slicehost::Compute.new(
|
|
37
|
-
:slicehost_password => Chef::Config[:knife][:slicehost_password]
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
images = slicehost.images.inject({}) { |h,i| h[i.id] = i.name; h }
|
|
41
|
-
|
|
42
|
-
image_list = [ highline.color('ID', :bold), highline.color('Name', :bold) ]
|
|
43
|
-
|
|
44
|
-
slicehost.images.each do |server|
|
|
45
|
-
image_list << server.id.to_s
|
|
46
|
-
image_list << server.name
|
|
47
|
-
end
|
|
48
|
-
puts highline.list(image_list, :columns_across, 2)
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Author:: Ian Meyer (<ianmmeyer@gmail.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 'chef/json_compat'
|
|
21
|
-
|
|
22
|
-
class Chef
|
|
23
|
-
class Knife
|
|
24
|
-
class SlicehostServerCreate < Knife
|
|
25
|
-
|
|
26
|
-
banner "knife slicehost 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 => 49
|
|
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 :slicehost_password,
|
|
49
|
-
:short => "-K KEY",
|
|
50
|
-
:long => "--slicehost-password password",
|
|
51
|
-
:description => "Your slicehost API password",
|
|
52
|
-
:proc => Proc.new { |password| Chef::Config[:knife][:slicehost_password] = password }
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def h
|
|
56
|
-
@highline ||= HighLine.new
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def run
|
|
60
|
-
require 'fog'
|
|
61
|
-
require 'highline'
|
|
62
|
-
require 'net/ssh/multi'
|
|
63
|
-
require 'readline'
|
|
64
|
-
|
|
65
|
-
slicehost = Fog::Slicehost::Compute.new(
|
|
66
|
-
:slicehost_password => Chef::Config[:knife][:slicehost_password]
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
flavors = slicehost.flavors.inject({}) { |h,f| h[f.id] = f.name; h }
|
|
70
|
-
images = slicehost.images.inject({}) { |h,i| h[i.id] = i.name; h }
|
|
71
|
-
|
|
72
|
-
response = slicehost.create_slice(config[:flavor],
|
|
73
|
-
config[:image],
|
|
74
|
-
config[:server_name])
|
|
75
|
-
$stdout.sync = true
|
|
76
|
-
|
|
77
|
-
puts "#{h.color("Name", :cyan)}: #{response.body['name']}"
|
|
78
|
-
puts "#{h.color("Flavor", :cyan)}: #{flavors[response.body['flavor-id']]}"
|
|
79
|
-
puts "#{h.color("Image", :cyan)}: #{images[response.body['image-id']]}"
|
|
80
|
-
puts "#{h.color("Public Address", :cyan)}: #{response.body['addresses'][1]}"
|
|
81
|
-
puts "#{h.color("Private Address", :cyan)}: #{response.body['addresses'][0]}"
|
|
82
|
-
puts "#{h.color("Password", :cyan)}: #{response.body['root-password']}"
|
|
83
|
-
|
|
84
|
-
print "\n#{h.color("Requesting status of #{response.body['name']}", :magenta)}"
|
|
85
|
-
saved_password = response.body['root-password']
|
|
86
|
-
|
|
87
|
-
# wait for it to be ready to do stuff
|
|
88
|
-
loop do
|
|
89
|
-
sleep 15
|
|
90
|
-
host = slicehost.get_slice(response.body['id'])
|
|
91
|
-
if host.body['status'] == 'active'
|
|
92
|
-
break
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
puts "\nServer ready!!"
|
|
97
|
-
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Author:: Ian Meyer (<ianmmeyer@gmail.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 'chef/json_compat'
|
|
21
|
-
|
|
22
|
-
class Chef
|
|
23
|
-
class Knife
|
|
24
|
-
class SlicehostServerDelete < Knife
|
|
25
|
-
|
|
26
|
-
banner "knife slicehost server delete SLICENAME"
|
|
27
|
-
|
|
28
|
-
def run
|
|
29
|
-
require 'fog'
|
|
30
|
-
require 'readline'
|
|
31
|
-
|
|
32
|
-
slicehost = Fog::Slicehost::Compute.new(
|
|
33
|
-
:slicehost_password => Chef::Config[:knife][:slicehost_password]
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
# Build hash of slice => id
|
|
37
|
-
servers = slicehost.servers.inject({}) { |h,f| h[f.name] = f.id; h }
|
|
38
|
-
|
|
39
|
-
unless servers.has_key?(@name_args[0])
|
|
40
|
-
Chef::Log.warn("I can't find a slice named #{@name_args[0]}")
|
|
41
|
-
return false
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
confirm("Do you really want to delete server ID #{servers[@name_args[0]]} named #{@name_args[0]}")
|
|
45
|
-
|
|
46
|
-
begin
|
|
47
|
-
response = slicehost.delete_slice(servers[@name_args[0]])
|
|
48
|
-
|
|
49
|
-
if response.headers['status'] == "200 OK"
|
|
50
|
-
Chef::Log.warn("Deleted server #{servers[@name_args[0]]} named #{@name_args[0]}")
|
|
51
|
-
end
|
|
52
|
-
rescue Excon::Errors::UnprocessableEntity
|
|
53
|
-
Chef::Log.warn("There was a problem deleting #{@name_args[0]}, check your slice manager")
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Author:: Ian Meyer (<ianmmeyer@gmail.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 'chef/json_compat'
|
|
21
|
-
|
|
22
|
-
class Chef
|
|
23
|
-
class Knife
|
|
24
|
-
class SlicehostServerList < Knife
|
|
25
|
-
|
|
26
|
-
banner "knife slicehost 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
|
-
slicehost = Fog::Slicehost::Compute.new(
|
|
39
|
-
:slicehost_password => Chef::Config[:knife][:slicehost_password]
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
# Make hash of flavor id => name and image id => name
|
|
43
|
-
flavors = slicehost.flavors.inject({}) { |h,f| h[f.id] = f.name; h }
|
|
44
|
-
images = slicehost.images.inject({}) { |h,i| h[i.id] = i.name; h }
|
|
45
|
-
|
|
46
|
-
server_list = [ h.color('ID', :bold), h.color('Name', :bold), h.color('Public IP', :bold), h.color('Private IP', :bold), h.color('Image', :bold), h.color('Flavor', :bold) ]
|
|
47
|
-
|
|
48
|
-
slicehost.servers.each do |server|
|
|
49
|
-
server_list << server.id.to_s
|
|
50
|
-
server_list << server.name
|
|
51
|
-
server_list << server.addresses[1]
|
|
52
|
-
server_list << server.addresses[0]
|
|
53
|
-
server_list << images[server.image_id].to_s
|
|
54
|
-
server_list << flavors[server.flavor_id].to_s
|
|
55
|
-
end
|
|
56
|
-
puts h.list(server_list, :columns_across, 6)
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
@@ -1,152 +0,0 @@
|
|
|
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 'chef/json_compat'
|
|
21
|
-
require 'tempfile'
|
|
22
|
-
|
|
23
|
-
class Chef
|
|
24
|
-
class Knife
|
|
25
|
-
class TerremarkServerCreate < Knife
|
|
26
|
-
|
|
27
|
-
banner "knife terremark server create NAME [RUN LIST...] (options)"
|
|
28
|
-
|
|
29
|
-
option :terremark_password,
|
|
30
|
-
:short => "-K PASSWORD",
|
|
31
|
-
:long => "--terremark-password PASSWORD",
|
|
32
|
-
:description => "Your terremark password",
|
|
33
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:terremark_password] = key }
|
|
34
|
-
|
|
35
|
-
option :terremark_username,
|
|
36
|
-
:short => "-A USERNAME",
|
|
37
|
-
:long => "--terremark-username USERNAME",
|
|
38
|
-
:description => "Your terremark username",
|
|
39
|
-
:proc => Proc.new { |username| Chef::Config[:knife][:terremark_username] = username }
|
|
40
|
-
|
|
41
|
-
option :terremark_service,
|
|
42
|
-
:short => "-S SERVICE",
|
|
43
|
-
:long => "--terremark-service SERVICE",
|
|
44
|
-
:description => "Your terremark service name",
|
|
45
|
-
:proc => Proc.new { |service| Chef::Config[:knife][:terremark_service] = service }
|
|
46
|
-
|
|
47
|
-
def h
|
|
48
|
-
@highline ||= HighLine.new
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def run
|
|
52
|
-
require 'fog'
|
|
53
|
-
require 'highline'
|
|
54
|
-
require 'net/ssh/multi'
|
|
55
|
-
require 'readline'
|
|
56
|
-
require 'net/scp'
|
|
57
|
-
|
|
58
|
-
server_name = @name_args[0]
|
|
59
|
-
|
|
60
|
-
terremark = Fog::Terremark.new(
|
|
61
|
-
:terremark_username => Chef::Config[:knife][:terremark_username],
|
|
62
|
-
:terremark_password => Chef::Config[:knife][:terremark_password],
|
|
63
|
-
:terremark_service => Chef::Config[:knife][:terremark_service] || :vcloud
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
$stdout.sync = true
|
|
67
|
-
|
|
68
|
-
puts "Instantiating vApp #{h.color(server_name, :bold)}"
|
|
69
|
-
vapp_id = terremark.instantiate_vapp_template(server_name).body['href'].split('/').last
|
|
70
|
-
|
|
71
|
-
deploy_task_id = terremark.deploy_vapp(vapp_id).body['href'].split('/').last
|
|
72
|
-
print "Waiting for deploy task [#{h.color(deploy_task_id, :bold)}]"
|
|
73
|
-
terremark.tasks.get(deploy_task_id).wait_for { print "."; ready? }
|
|
74
|
-
print "\n"
|
|
75
|
-
|
|
76
|
-
power_on_task_id = terremark.power_on(vapp_id).body['href'].split('/').last
|
|
77
|
-
print "Waiting for power on task [#{h.color(power_on_task_id, :bold)}]"
|
|
78
|
-
terremark.tasks.get(power_on_task_id).wait_for { print "."; ready? }
|
|
79
|
-
print "\n"
|
|
80
|
-
|
|
81
|
-
private_ip = terremark.get_vapp(vapp_id).body['IpAddress']
|
|
82
|
-
ssh_internet_service = terremark.create_internet_service(terremark.default_vdc_id, 'SSH', 'TCP', 22).body
|
|
83
|
-
ssh_internet_service_id = ssh_internet_service['Id']
|
|
84
|
-
public_ip = ssh_internet_service['PublicIpAddress']['Name']
|
|
85
|
-
public_ip_id = ssh_internet_service['PublicIpAddress']['Id']
|
|
86
|
-
ssh_node_service_id = terremark.add_node_service(ssh_internet_service_id, private_ip, 'SSH', 22).body['Id']
|
|
87
|
-
|
|
88
|
-
puts "\nBootstrapping #{h.color(server_name, :bold)}..."
|
|
89
|
-
password = terremark.get_vapp_template(12).body['Description'].scan(/\npassword: (.*)\n/).first.first
|
|
90
|
-
|
|
91
|
-
command = <<EOH
|
|
92
|
-
bash -c '
|
|
93
|
-
echo nameserver 208.67.222.222 > /etc/resolv.conf
|
|
94
|
-
echo nameserver 208.67.220.220 >> /etc/resolv.conf
|
|
95
|
-
|
|
96
|
-
if [ ! -f /usr/bin/chef-client ]; then
|
|
97
|
-
apt-get update
|
|
98
|
-
apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
|
|
99
|
-
cd /tmp
|
|
100
|
-
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
|
|
101
|
-
tar xvf rubygems-1.3.6.tgz
|
|
102
|
-
cd rubygems-1.3.6
|
|
103
|
-
ruby setup.rb
|
|
104
|
-
cp /usr/bin/gem1.8 /usr/bin/gem
|
|
105
|
-
gem install chef ohai --no-rdoc --no-ri --verbose
|
|
106
|
-
fi
|
|
107
|
-
|
|
108
|
-
mkdir -p /etc/chef
|
|
109
|
-
|
|
110
|
-
(
|
|
111
|
-
cat <<'EOP'
|
|
112
|
-
#{IO.read(Chef::Config[:validation_key])}
|
|
113
|
-
EOP
|
|
114
|
-
) > /etc/chef/validation.pem
|
|
115
|
-
|
|
116
|
-
(
|
|
117
|
-
cat <<'EOP'
|
|
118
|
-
log_level :info
|
|
119
|
-
log_location STDOUT
|
|
120
|
-
chef_server_url "#{Chef::Config[:chef_server_url]}"
|
|
121
|
-
validation_client_name "#{Chef::Config[:validation_client_name]}"
|
|
122
|
-
EOP
|
|
123
|
-
) > /etc/chef/client.rb
|
|
124
|
-
|
|
125
|
-
(
|
|
126
|
-
cat <<'EOP'
|
|
127
|
-
#{{ "run_list" => @name_args[1..-1] }.to_json}
|
|
128
|
-
EOP
|
|
129
|
-
) > /etc/chef/first-boot.json
|
|
130
|
-
|
|
131
|
-
/usr/bin/chef-client -j /etc/chef/first-boot.json'
|
|
132
|
-
EOH
|
|
133
|
-
|
|
134
|
-
begin
|
|
135
|
-
ssh = Chef::Knife::Ssh.new
|
|
136
|
-
ssh.name_args = [ public_ip, "sudo #{command}" ]
|
|
137
|
-
ssh.config[:ssh_user] = "vcloud"
|
|
138
|
-
ssh.config[:manual] = true
|
|
139
|
-
ssh.config[:password] = password
|
|
140
|
-
ssh.password = password
|
|
141
|
-
ssh.run
|
|
142
|
-
rescue Errno::ETIMEDOUT
|
|
143
|
-
puts "Timed out on bootstrap, re-trying. Hit CTRL-C to abort."
|
|
144
|
-
puts "You probably need to log in to Terremark and powercycle #{h.color(@name_args[0], :bold)}"
|
|
145
|
-
retry
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|