mbailey-chef 0.9.12.1
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/LICENSE +201 -0
- data/README.rdoc +172 -0
- data/bin/chef-client +26 -0
- data/bin/chef-solo +25 -0
- data/bin/knife +26 -0
- data/bin/shef +34 -0
- data/distro/README +2 -0
- data/distro/common/man/man1/chef-indexer.1 +42 -0
- data/distro/common/man/man1/chef-server-webui.1 +106 -0
- data/distro/common/man/man1/chef-server.1 +107 -0
- data/distro/common/man/man1/chef-solr-indexer.1 +55 -0
- data/distro/common/man/man1/chef-solr.1 +55 -0
- data/distro/common/man/man8/chef-client.8 +63 -0
- data/distro/common/man/man8/chef-solo.8 +57 -0
- data/distro/common/man/man8/chef-solr-rebuild.8 +37 -0
- data/distro/common/man/man8/knife.8 +1349 -0
- data/distro/common/man/man8/shef.8 +45 -0
- data/distro/common/markdown/README +3 -0
- data/distro/common/markdown/knife.mkd +832 -0
- data/distro/debian/etc/default/chef-client +4 -0
- data/distro/debian/etc/default/chef-server +9 -0
- data/distro/debian/etc/default/chef-server-webui +9 -0
- data/distro/debian/etc/default/chef-solr +7 -0
- data/distro/debian/etc/default/chef-solr-indexer +7 -0
- data/distro/debian/etc/init/chef-client.conf +17 -0
- data/distro/debian/etc/init/chef-server-webui.conf +17 -0
- data/distro/debian/etc/init/chef-server.conf +17 -0
- data/distro/debian/etc/init/chef-solr-indexer.conf +17 -0
- data/distro/debian/etc/init/chef-solr.conf +17 -0
- data/distro/debian/etc/init.d/chef-client +175 -0
- data/distro/debian/etc/init.d/chef-server +122 -0
- data/distro/debian/etc/init.d/chef-server-webui +123 -0
- data/distro/debian/etc/init.d/chef-solr +177 -0
- data/distro/debian/etc/init.d/chef-solr-indexer +176 -0
- data/distro/redhat/etc/init.d/chef-client +106 -0
- data/distro/redhat/etc/init.d/chef-server +112 -0
- data/distro/redhat/etc/init.d/chef-server-webui +112 -0
- data/distro/redhat/etc/init.d/chef-solr +104 -0
- data/distro/redhat/etc/init.d/chef-solr-indexer +104 -0
- data/distro/redhat/etc/logrotate.d/chef-client +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server-webui +8 -0
- data/distro/redhat/etc/logrotate.d/chef-solr +8 -0
- data/distro/redhat/etc/logrotate.d/chef-solr-indexer +8 -0
- data/distro/redhat/etc/sysconfig/chef-client +15 -0
- data/distro/redhat/etc/sysconfig/chef-server +14 -0
- data/distro/redhat/etc/sysconfig/chef-server-webui +14 -0
- data/distro/redhat/etc/sysconfig/chef-solr +8 -0
- data/distro/redhat/etc/sysconfig/chef-solr-indexer +7 -0
- data/lib/chef/api_client.rb +264 -0
- data/lib/chef/application/agent.rb +18 -0
- data/lib/chef/application/client.rb +246 -0
- data/lib/chef/application/knife.rb +171 -0
- data/lib/chef/application/solo.rb +215 -0
- data/lib/chef/application.rb +127 -0
- data/lib/chef/applications.rb +4 -0
- data/lib/chef/certificate.rb +194 -0
- data/lib/chef/checksum.rb +182 -0
- data/lib/chef/checksum_cache.rb +173 -0
- data/lib/chef/client.rb +304 -0
- data/lib/chef/config.rb +240 -0
- data/lib/chef/cookbook/cookbook_collection.rb +44 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +54 -0
- data/lib/chef/cookbook/file_vendor.rb +48 -0
- data/lib/chef/cookbook/metadata/version.rb +87 -0
- data/lib/chef/cookbook/metadata.rb +500 -0
- data/lib/chef/cookbook/remote_file_vendor.rb +87 -0
- data/lib/chef/cookbook/syntax_check.rb +136 -0
- data/lib/chef/cookbook_loader.rb +227 -0
- data/lib/chef/cookbook_site_streaming_uploader.rb +244 -0
- data/lib/chef/cookbook_uploader.rb +103 -0
- data/lib/chef/cookbook_version.rb +930 -0
- data/lib/chef/couchdb.rb +239 -0
- data/lib/chef/daemon.rb +172 -0
- data/lib/chef/data_bag.rb +215 -0
- data/lib/chef/data_bag_item.rb +228 -0
- data/lib/chef/exceptions.rb +66 -0
- data/lib/chef/file_access_control.rb +140 -0
- data/lib/chef/file_cache.rb +218 -0
- data/lib/chef/handler/json_file.rb +58 -0
- data/lib/chef/handler.rb +206 -0
- data/lib/chef/index_queue/amqp_client.rb +113 -0
- data/lib/chef/index_queue/consumer.rb +76 -0
- data/lib/chef/index_queue/indexable.rb +76 -0
- data/lib/chef/index_queue.rb +29 -0
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +44 -0
- data/lib/chef/knife/bootstrap/centos5-gems.erb +41 -0
- data/lib/chef/knife/bootstrap/client-install.vbs +80 -0
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +38 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +32 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +43 -0
- data/lib/chef/knife/bootstrap/windows-gems.erb +34 -0
- data/lib/chef/knife/bootstrap.rb +181 -0
- data/lib/chef/knife/client_bulk_delete.rb +40 -0
- data/lib/chef/knife/client_create.rb +70 -0
- data/lib/chef/knife/client_delete.rb +45 -0
- data/lib/chef/knife/client_edit.rb +45 -0
- data/lib/chef/knife/client_list.rb +40 -0
- data/lib/chef/knife/client_reregister.rb +56 -0
- data/lib/chef/knife/client_show.rb +50 -0
- data/lib/chef/knife/configure.rb +140 -0
- data/lib/chef/knife/configure_client.rb +52 -0
- data/lib/chef/knife/cookbook_bulk_delete.rb +58 -0
- data/lib/chef/knife/cookbook_create.rb +209 -0
- data/lib/chef/knife/cookbook_delete.rb +143 -0
- data/lib/chef/knife/cookbook_download.rb +130 -0
- data/lib/chef/knife/cookbook_list.rb +41 -0
- data/lib/chef/knife/cookbook_metadata.rb +82 -0
- data/lib/chef/knife/cookbook_metadata_from_file.rb +40 -0
- data/lib/chef/knife/cookbook_show.rb +98 -0
- data/lib/chef/knife/cookbook_site_download.rb +58 -0
- data/lib/chef/knife/cookbook_site_list.rb +56 -0
- data/lib/chef/knife/cookbook_site_search.rb +51 -0
- data/lib/chef/knife/cookbook_site_share.rb +109 -0
- data/lib/chef/knife/cookbook_site_show.rb +57 -0
- data/lib/chef/knife/cookbook_site_unshare.rb +52 -0
- data/lib/chef/knife/cookbook_site_vendor.rb +133 -0
- data/lib/chef/knife/cookbook_test.rb +82 -0
- data/lib/chef/knife/cookbook_upload.rb +95 -0
- data/lib/chef/knife/data_bag_create.rb +59 -0
- data/lib/chef/knife/data_bag_delete.rb +48 -0
- data/lib/chef/knife/data_bag_edit.rb +50 -0
- data/lib/chef/knife/data_bag_from_file.rb +44 -0
- data/lib/chef/knife/data_bag_list.rb +43 -0
- data/lib/chef/knife/data_bag_show.rb +41 -0
- data/lib/chef/knife/ec2_instance_data.rb +46 -0
- data/lib/chef/knife/ec2_server_create.rb +216 -0
- data/lib/chef/knife/ec2_server_delete.rb +90 -0
- data/lib/chef/knife/ec2_server_list.rb +88 -0
- data/lib/chef/knife/exec.rb +52 -0
- data/lib/chef/knife/index_rebuild.rb +51 -0
- data/lib/chef/knife/node_bulk_delete.rb +43 -0
- data/lib/chef/knife/node_create.rb +47 -0
- data/lib/chef/knife/node_delete.rb +44 -0
- data/lib/chef/knife/node_edit.rb +44 -0
- data/lib/chef/knife/node_from_file.rb +42 -0
- data/lib/chef/knife/node_list.rb +41 -0
- data/lib/chef/knife/node_run_list_add.rb +64 -0
- data/lib/chef/knife/node_run_list_remove.rb +45 -0
- data/lib/chef/knife/node_show.rb +54 -0
- 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/recipe_list.rb +32 -0
- data/lib/chef/knife/role_bulk_delete.rb +44 -0
- data/lib/chef/knife/role_create.rb +52 -0
- data/lib/chef/knife/role_delete.rb +44 -0
- data/lib/chef/knife/role_edit.rb +45 -0
- data/lib/chef/knife/role_from_file.rb +46 -0
- data/lib/chef/knife/role_list.rb +40 -0
- data/lib/chef/knife/role_show.rb +51 -0
- data/lib/chef/knife/search.rb +94 -0
- data/lib/chef/knife/slicehost_images_list.rb +53 -0
- data/lib/chef/knife/slicehost_server_create.rb +103 -0
- data/lib/chef/knife/slicehost_server_delete.rb +61 -0
- data/lib/chef/knife/slicehost_server_list.rb +64 -0
- data/lib/chef/knife/ssh.rb +328 -0
- data/lib/chef/knife/status.rb +87 -0
- 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/knife/windows_bootstrap.rb +154 -0
- data/lib/chef/knife.rb +522 -0
- data/lib/chef/log.rb +61 -0
- data/lib/chef/mixin/check_helper.rb +31 -0
- data/lib/chef/mixin/checksum.rb +32 -0
- data/lib/chef/mixin/command/unix.rb +215 -0
- data/lib/chef/mixin/command/windows.rb +72 -0
- data/lib/chef/mixin/command.rb +220 -0
- data/lib/chef/mixin/convert_to_class_name.rb +63 -0
- data/lib/chef/mixin/create_path.rb +56 -0
- data/lib/chef/mixin/deep_merge.rb +225 -0
- data/lib/chef/mixin/deprecation.rb +65 -0
- data/lib/chef/mixin/find_preferred_file.rb +92 -0
- data/lib/chef/mixin/from_file.rb +50 -0
- data/lib/chef/mixin/language.rb +156 -0
- data/lib/chef/mixin/language_include_attribute.rb +61 -0
- data/lib/chef/mixin/language_include_recipe.rb +52 -0
- data/lib/chef/mixin/params_validate.rb +225 -0
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +81 -0
- data/lib/chef/mixin/shell_out.rb +38 -0
- data/lib/chef/mixin/template.rb +95 -0
- data/lib/chef/mixin/xml_escape.rb +140 -0
- data/lib/chef/mixins.rb +16 -0
- data/lib/chef/monkey_patches/dir.rb +36 -0
- data/lib/chef/monkey_patches/string.rb +28 -0
- data/lib/chef/monkey_patches/tempfile.rb +64 -0
- data/lib/chef/node/attribute.rb +465 -0
- data/lib/chef/node.rb +601 -0
- data/lib/chef/openid_registration.rb +187 -0
- data/lib/chef/platform.rb +371 -0
- data/lib/chef/provider/breakpoint.rb +36 -0
- data/lib/chef/provider/cookbook_file.rb +100 -0
- data/lib/chef/provider/cron/solaris.rb +195 -0
- data/lib/chef/provider/cron.rb +186 -0
- data/lib/chef/provider/deploy/revision.rb +73 -0
- data/lib/chef/provider/deploy/timestamped.rb +33 -0
- data/lib/chef/provider/deploy.rb +319 -0
- data/lib/chef/provider/directory.rb +72 -0
- data/lib/chef/provider/env/windows.rb +75 -0
- data/lib/chef/provider/env.rb +152 -0
- data/lib/chef/provider/erl_call.rb +72 -0
- data/lib/chef/provider/execute.rb +58 -0
- data/lib/chef/provider/file.rb +213 -0
- data/lib/chef/provider/git.rb +211 -0
- data/lib/chef/provider/group/dscl.rb +121 -0
- data/lib/chef/provider/group/gpasswd.rb +53 -0
- data/lib/chef/provider/group/groupadd.rb +78 -0
- data/lib/chef/provider/group/pw.rb +84 -0
- data/lib/chef/provider/group/usermod.rb +57 -0
- data/lib/chef/provider/group/windows.rb +79 -0
- data/lib/chef/provider/group.rb +133 -0
- data/lib/chef/provider/http_request.rb +122 -0
- data/lib/chef/provider/ifconfig.rb +132 -0
- data/lib/chef/provider/link.rb +161 -0
- data/lib/chef/provider/log.rb +54 -0
- data/lib/chef/provider/mdadm.rb +91 -0
- data/lib/chef/provider/mount/mount.rb +232 -0
- data/lib/chef/provider/mount/windows.rb +80 -0
- data/lib/chef/provider/mount.rb +117 -0
- data/lib/chef/provider/ohai.rb +41 -0
- data/lib/chef/provider/package/apt.rb +110 -0
- data/lib/chef/provider/package/dpkg.rb +112 -0
- data/lib/chef/provider/package/easy_install.rb +114 -0
- data/lib/chef/provider/package/freebsd.rb +123 -0
- data/lib/chef/provider/package/macports.rb +105 -0
- data/lib/chef/provider/package/pacman.rb +101 -0
- data/lib/chef/provider/package/portage.rb +124 -0
- data/lib/chef/provider/package/rpm.rb +101 -0
- data/lib/chef/provider/package/rubygems.rb +462 -0
- data/lib/chef/provider/package/solaris.rb +127 -0
- data/lib/chef/provider/package/yum-dump.py +128 -0
- data/lib/chef/provider/package/yum.rb +222 -0
- data/lib/chef/provider/package/zypper.rb +133 -0
- data/lib/chef/provider/package.rb +160 -0
- data/lib/chef/provider/remote_directory.rb +140 -0
- data/lib/chef/provider/remote_file.rb +120 -0
- data/lib/chef/provider/route.rb +195 -0
- data/lib/chef/provider/ruby_block.rb +33 -0
- data/lib/chef/provider/script.rb +55 -0
- data/lib/chef/provider/service/arch.rb +109 -0
- data/lib/chef/provider/service/debian.rb +105 -0
- data/lib/chef/provider/service/freebsd.rb +156 -0
- data/lib/chef/provider/service/gentoo.rb +54 -0
- data/lib/chef/provider/service/init.rb +71 -0
- data/lib/chef/provider/service/redhat.rb +60 -0
- data/lib/chef/provider/service/simple.rb +118 -0
- data/lib/chef/provider/service/solaris.rb +85 -0
- data/lib/chef/provider/service/upstart.rb +192 -0
- data/lib/chef/provider/service/windows.rb +129 -0
- data/lib/chef/provider/service.rb +128 -0
- data/lib/chef/provider/subversion.rb +159 -0
- data/lib/chef/provider/template.rb +105 -0
- data/lib/chef/provider/user/dscl.rb +280 -0
- data/lib/chef/provider/user/pw.rb +113 -0
- data/lib/chef/provider/user/useradd.rb +137 -0
- data/lib/chef/provider/user/windows.rb +124 -0
- data/lib/chef/provider/user.rb +187 -0
- data/lib/chef/provider.rb +124 -0
- data/lib/chef/providers.rb +91 -0
- data/lib/chef/recipe.rb +130 -0
- data/lib/chef/resource/apt_package.rb +34 -0
- data/lib/chef/resource/bash.rb +33 -0
- data/lib/chef/resource/breakpoint.rb +35 -0
- data/lib/chef/resource/cookbook_file.rb +45 -0
- data/lib/chef/resource/cron.rb +188 -0
- data/lib/chef/resource/csh.rb +33 -0
- data/lib/chef/resource/deploy.rb +371 -0
- data/lib/chef/resource/deploy_revision.rb +35 -0
- data/lib/chef/resource/directory.rb +76 -0
- data/lib/chef/resource/dpkg_package.rb +34 -0
- data/lib/chef/resource/easy_install_package.rb +41 -0
- data/lib/chef/resource/env.rb +58 -0
- data/lib/chef/resource/erl_call.rb +83 -0
- data/lib/chef/resource/execute.rb +127 -0
- data/lib/chef/resource/file.rb +92 -0
- data/lib/chef/resource/freebsd_package.rb +35 -0
- data/lib/chef/resource/gem_package.rb +49 -0
- data/lib/chef/resource/git.rb +36 -0
- data/lib/chef/resource/group.rb +70 -0
- data/lib/chef/resource/http_request.rb +61 -0
- data/lib/chef/resource/ifconfig.rb +134 -0
- data/lib/chef/resource/link.rb +78 -0
- data/lib/chef/resource/log.rb +62 -0
- data/lib/chef/resource/macports_package.rb +29 -0
- data/lib/chef/resource/mdadm.rb +82 -0
- data/lib/chef/resource/mount.rb +135 -0
- data/lib/chef/resource/ohai.rb +40 -0
- data/lib/chef/resource/package.rb +80 -0
- data/lib/chef/resource/pacman_package.rb +33 -0
- data/lib/chef/resource/perl.rb +33 -0
- data/lib/chef/resource/portage_package.rb +33 -0
- data/lib/chef/resource/python.rb +33 -0
- data/lib/chef/resource/remote_directory.rb +109 -0
- data/lib/chef/resource/remote_file.rb +83 -0
- data/lib/chef/resource/route.rb +135 -0
- data/lib/chef/resource/rpm_package.rb +34 -0
- data/lib/chef/resource/ruby.rb +33 -0
- data/lib/chef/resource/ruby_block.rb +40 -0
- data/lib/chef/resource/scm.rb +146 -0
- data/lib/chef/resource/script.rb +60 -0
- data/lib/chef/resource/service.rb +160 -0
- data/lib/chef/resource/solaris_package.rb +36 -0
- data/lib/chef/resource/subversion.rb +36 -0
- data/lib/chef/resource/template.rb +69 -0
- data/lib/chef/resource/timestamped_deploy.rb +31 -0
- data/lib/chef/resource/user.rb +130 -0
- data/lib/chef/resource/yum_package.rb +43 -0
- data/lib/chef/resource.rb +523 -0
- data/lib/chef/resource_collection/stepable_iterator.rb +124 -0
- data/lib/chef/resource_collection.rb +217 -0
- data/lib/chef/resource_definition.rb +67 -0
- data/lib/chef/resource_definition_list.rb +38 -0
- data/lib/chef/resources.rb +64 -0
- data/lib/chef/rest/auth_credentials.rb +78 -0
- data/lib/chef/rest/cookie_jar.rb +31 -0
- data/lib/chef/rest/rest_request.rb +188 -0
- data/lib/chef/rest.rb +394 -0
- data/lib/chef/role.rb +287 -0
- data/lib/chef/run_context.rb +110 -0
- data/lib/chef/run_list/run_list_expansion.rb +172 -0
- data/lib/chef/run_list/run_list_item.rb +78 -0
- data/lib/chef/run_list.rb +150 -0
- data/lib/chef/run_status.rb +121 -0
- data/lib/chef/runner.rb +107 -0
- data/lib/chef/sandbox.rb +153 -0
- data/lib/chef/search/query.rb +60 -0
- data/lib/chef/shef/ext.rb +568 -0
- data/lib/chef/shef/model_wrapper.rb +120 -0
- data/lib/chef/shef/shef_rest.rb +28 -0
- data/lib/chef/shef/shef_session.rb +271 -0
- data/lib/chef/shef.rb +325 -0
- data/lib/chef/shell_out.rb +413 -0
- data/lib/chef/streaming_cookbook_uploader.rb +201 -0
- data/lib/chef/tasks/chef_repo.rake +256 -0
- data/lib/chef/util/file_edit.rb +122 -0
- data/lib/chef/util/windows/net_group.rb +101 -0
- data/lib/chef/util/windows/net_use.rb +121 -0
- data/lib/chef/util/windows/net_user.rb +198 -0
- data/lib/chef/util/windows/volume.rb +59 -0
- data/lib/chef/util/windows.rb +56 -0
- data/lib/chef/version.rb +21 -0
- data/lib/chef/webui_user.rb +231 -0
- data/lib/chef.rb +39 -0
- metadata +533 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
|
3
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
|
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
|
+
class Chef
|
|
20
|
+
module IndexQueue
|
|
21
|
+
module Indexable
|
|
22
|
+
|
|
23
|
+
module ClassMethods
|
|
24
|
+
|
|
25
|
+
def index_object_type(explicit_type_name=nil)
|
|
26
|
+
@index_object_type = explicit_type_name.to_s if explicit_type_name
|
|
27
|
+
@index_object_type
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Resets all metadata used for indexing to nil. Used for testing
|
|
31
|
+
def reset_index_metadata!
|
|
32
|
+
@index_object_type = nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.included(including_class)
|
|
38
|
+
including_class.send(:extend, ClassMethods)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
attr_accessor :index_id
|
|
42
|
+
|
|
43
|
+
def index_object_type
|
|
44
|
+
self.class.index_object_type || Mixin::ConvertToClassName.snake_case_basename(self.class.name)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def with_indexer_metadata(indexer_metadata={})
|
|
48
|
+
# changing input param symbol keys to strings, as the keys in hash that goes to solr are expected to be strings [cb]
|
|
49
|
+
# Ruby 1.9 hates you, cb [dan]
|
|
50
|
+
with_metadata = {}
|
|
51
|
+
indexer_metadata.each_key do |key|
|
|
52
|
+
with_metadata[key.to_s] = indexer_metadata[key]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
with_metadata["type"] ||= self.index_object_type
|
|
56
|
+
with_metadata["id"] ||= self.index_id
|
|
57
|
+
with_metadata["database"] ||= Chef::Config[:couchdb_database]
|
|
58
|
+
with_metadata["item"] ||= self.to_hash
|
|
59
|
+
|
|
60
|
+
raise ArgumentError, "Type, Id, or Database missing in index operation: #{with_metadata.inspect}" if (with_metadata["id"].nil? or with_metadata["type"].nil?)
|
|
61
|
+
with_metadata
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def add_to_index(metadata={})
|
|
65
|
+
Chef::Log.debug("pushing item to index queue for addition: #{self.with_indexer_metadata(metadata)}")
|
|
66
|
+
AmqpClient.instance.send_action(:add, self.with_indexer_metadata(metadata))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def delete_from_index(metadata={})
|
|
70
|
+
Chef::Log.debug("pushing item to index queue for deletion: #{self.with_indexer_metadata(metadata)}")
|
|
71
|
+
AmqpClient.instance.send_action(:delete, self.with_indexer_metadata(metadata))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
|
3
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
|
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 "singleton"
|
|
20
|
+
require "bunny"
|
|
21
|
+
|
|
22
|
+
require "chef/index_queue/amqp_client"
|
|
23
|
+
require "chef/index_queue/indexable"
|
|
24
|
+
require "chef/index_queue/consumer"
|
|
25
|
+
|
|
26
|
+
class Chef
|
|
27
|
+
module IndexQueue
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
bash -c '
|
|
2
|
+
if [ ! -f /usr/bin/chef-client ]; then
|
|
3
|
+
pacman -Syy
|
|
4
|
+
pacman -S --noconfirm ruby ntp
|
|
5
|
+
ntpdate pool.ntp.org
|
|
6
|
+
gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
mkdir -p /etc/chef
|
|
10
|
+
(
|
|
11
|
+
cat <<'EOP'
|
|
12
|
+
<%= IO.read(Chef::Config[:validation_key]) %>
|
|
13
|
+
EOP
|
|
14
|
+
) > /tmp/validation.pem
|
|
15
|
+
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
|
16
|
+
rm /tmp/validation.pem
|
|
17
|
+
|
|
18
|
+
(
|
|
19
|
+
cat <<'EOP'
|
|
20
|
+
log_level :info
|
|
21
|
+
log_location STDOUT
|
|
22
|
+
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
|
|
23
|
+
validation_client_name "<%= Chef::Config[:validation_client_name] %>"
|
|
24
|
+
<% if @config[:chef_node_name] == nil %>
|
|
25
|
+
# Using default node name (fqdn)
|
|
26
|
+
<% else %>
|
|
27
|
+
node_name "<%= @config[:chef_node_name] %>"
|
|
28
|
+
<% end %>
|
|
29
|
+
# ArchLinux follows the Filesystem Hierarchy Standard
|
|
30
|
+
file_cache_path "/var/cache/chef"
|
|
31
|
+
file_backup_path "/var/lib/chef/backup"
|
|
32
|
+
pid_file "/var/run/chef/client.pid"
|
|
33
|
+
cache_options({ :path => "/var/cache/chef/checksums", :skip_expires => true})
|
|
34
|
+
EOP
|
|
35
|
+
) > /etc/chef/client.rb
|
|
36
|
+
|
|
37
|
+
(
|
|
38
|
+
cat <<'EOP'
|
|
39
|
+
<%= { "run_list" => @run_list }.to_json %>
|
|
40
|
+
EOP
|
|
41
|
+
) > /etc/chef/first-boot.json
|
|
42
|
+
|
|
43
|
+
/usr/bin/chef-client -j /etc/chef/first-boot.json
|
|
44
|
+
'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
bash -c '
|
|
2
|
+
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
|
|
3
|
+
rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
|
|
4
|
+
|
|
5
|
+
yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
|
|
6
|
+
|
|
7
|
+
gem update --system
|
|
8
|
+
gem update
|
|
9
|
+
gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
|
|
10
|
+
|
|
11
|
+
mkdir -p /etc/chef
|
|
12
|
+
|
|
13
|
+
(
|
|
14
|
+
cat <<'EOP'
|
|
15
|
+
<%= IO.read(Chef::Config[:validation_key]) %>
|
|
16
|
+
EOP
|
|
17
|
+
) > /tmp/validation.pem
|
|
18
|
+
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
|
19
|
+
rm /tmp/validation.pem
|
|
20
|
+
|
|
21
|
+
(
|
|
22
|
+
cat <<'EOP'
|
|
23
|
+
log_level :info
|
|
24
|
+
log_location STDOUT
|
|
25
|
+
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
|
|
26
|
+
validation_client_name "<%= Chef::Config[:validation_client_name] %>"
|
|
27
|
+
<% if @config[:chef_node_name] == nil %>
|
|
28
|
+
# Using default node name"
|
|
29
|
+
<% else %>
|
|
30
|
+
node_name "<%= @config[:chef_node_name] %>"
|
|
31
|
+
<% end %>
|
|
32
|
+
EOP
|
|
33
|
+
) > /etc/chef/client.rb
|
|
34
|
+
|
|
35
|
+
(
|
|
36
|
+
cat <<'EOP'
|
|
37
|
+
<%= { "run_list" => @run_list }.to_json %>
|
|
38
|
+
EOP
|
|
39
|
+
) > /etc/chef/first-boot.json
|
|
40
|
+
|
|
41
|
+
/usr/bin/chef-client -j /etc/chef/first-boot.json'
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'
|
|
2
|
+
' Author:: Doug MacEachern <dougm@vmware.com>
|
|
3
|
+
' Copyright:: Copyright (c) 2010 VMware, 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
|
+
' download & install ruby && install chef client gems
|
|
19
|
+
|
|
20
|
+
Exe = "rubyinstaller-1.8.7-p249-rc2.exe"
|
|
21
|
+
Url = "http://rubyforge.org/frs/download.php/69034/" & Exe
|
|
22
|
+
Dst = "C:\Ruby"
|
|
23
|
+
Proxy = ""
|
|
24
|
+
If WScript.Arguments.Count = 1 Then
|
|
25
|
+
Proxy = WScript.Arguments.Item(0)
|
|
26
|
+
WScript.Echo "Using HTTP proxy=" & Proxy
|
|
27
|
+
End If
|
|
28
|
+
|
|
29
|
+
Set Shell = CreateObject("WScript.Shell")
|
|
30
|
+
Set Fs = CreateObject("Scripting.FileSystemObject")
|
|
31
|
+
If Fs.FileExists(Exe) Then
|
|
32
|
+
WScript.Echo "Using existing " & Exe
|
|
33
|
+
Else
|
|
34
|
+
WScript.Echo "Downloading " & Url
|
|
35
|
+
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
|
|
36
|
+
If Proxy <> "" Then
|
|
37
|
+
Http.setProxy 2, Proxy, ""
|
|
38
|
+
End If
|
|
39
|
+
Http.Open "GET", Url, False
|
|
40
|
+
Http.Send
|
|
41
|
+
Set BinaryStream = CreateObject("ADODB.Stream")
|
|
42
|
+
BinaryStream.Type = 1
|
|
43
|
+
BinaryStream.Open
|
|
44
|
+
BinaryStream.Write Http.ResponseBody
|
|
45
|
+
BinaryStream.SaveToFile Exe, 2
|
|
46
|
+
BinaryStream.Close
|
|
47
|
+
End If
|
|
48
|
+
|
|
49
|
+
Ruby = Dst & "\bin\ruby.exe"
|
|
50
|
+
|
|
51
|
+
If Fs.FileExists(Ruby) Then
|
|
52
|
+
WScript.Echo Dst & " exists"
|
|
53
|
+
Else
|
|
54
|
+
WScript.Echo "Installing " & Exe & " to " & Dst
|
|
55
|
+
Cmd = Exe & " /dir=" & Dst & " /verysilent /tasks=assocfiles,modpath"
|
|
56
|
+
WScript.Echo Cmd
|
|
57
|
+
Set Exec = Shell.Exec(Cmd)
|
|
58
|
+
Do Until Exec.StdOut.AtEndOfStream
|
|
59
|
+
Line = Exec.StdOut.ReadLine()
|
|
60
|
+
Wscript.Echo Line
|
|
61
|
+
Loop
|
|
62
|
+
End If
|
|
63
|
+
|
|
64
|
+
GemProxy = ""
|
|
65
|
+
If Proxy <> "" Then
|
|
66
|
+
GemProxy = " --http-proxy=http://" & Proxy
|
|
67
|
+
End If
|
|
68
|
+
|
|
69
|
+
Cmd = Ruby & " " & Dst & "\bin\gem install" & GemProxy & " --no-ri --no-rdoc chef ruby-wmi windows-pr win32-open3 rubyzip"
|
|
70
|
+
WScript.Echo Cmd
|
|
71
|
+
Set Exec = Shell.Exec(Cmd)
|
|
72
|
+
Do Until Exec.StdOut.AtEndOfStream
|
|
73
|
+
Line = Exec.StdOut.ReadLine()
|
|
74
|
+
Wscript.Echo Line
|
|
75
|
+
Loop
|
|
76
|
+
Do Until Exec.StdErr.AtEndOfStream
|
|
77
|
+
Line = Exec.StdErr.ReadLine()
|
|
78
|
+
Wscript.Echo Line
|
|
79
|
+
Loop
|
|
80
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
bash -c '
|
|
2
|
+
yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
|
|
3
|
+
|
|
4
|
+
gem update --system
|
|
5
|
+
gem update
|
|
6
|
+
gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
|
|
7
|
+
|
|
8
|
+
mkdir -p /etc/chef
|
|
9
|
+
|
|
10
|
+
(
|
|
11
|
+
cat <<'EOP'
|
|
12
|
+
<%= IO.read(Chef::Config[:validation_key]) %>
|
|
13
|
+
EOP
|
|
14
|
+
) > /tmp/validation.pem
|
|
15
|
+
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
|
16
|
+
rm /tmp/validation.pem
|
|
17
|
+
|
|
18
|
+
(
|
|
19
|
+
cat <<'EOP'
|
|
20
|
+
log_level :info
|
|
21
|
+
log_location STDOUT
|
|
22
|
+
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
|
|
23
|
+
validation_client_name "<%= Chef::Config[:validation_client_name] %>"
|
|
24
|
+
<% if @config[:chef_node_name] == nil %>
|
|
25
|
+
# Using default node name"
|
|
26
|
+
<% else %>
|
|
27
|
+
node_name "<%= @config[:chef_node_name] %>"
|
|
28
|
+
<% end %>
|
|
29
|
+
EOP
|
|
30
|
+
) > /etc/chef/client.rb
|
|
31
|
+
|
|
32
|
+
(
|
|
33
|
+
cat <<'EOP'
|
|
34
|
+
<%= { "run_list" => @run_list }.to_json %>
|
|
35
|
+
EOP
|
|
36
|
+
) > /etc/chef/first-boot.json
|
|
37
|
+
|
|
38
|
+
/usr/bin/chef-client -j /etc/chef/first-boot.json'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
bash -c '
|
|
2
|
+
if [ ! -f /usr/bin/chef-client ]; then
|
|
3
|
+
echo "chef chef/chef_server_url string <%= Chef::Config[:chef_server_url] %>" | debconf-set-selections
|
|
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 -O- http://apt.opscode.com/packages@opscode.com.gpg.key | apt-key add -
|
|
6
|
+
fi
|
|
7
|
+
apt-get update
|
|
8
|
+
apt-get install -y chef
|
|
9
|
+
|
|
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
|
+
(
|
|
15
|
+
cat <<'EOP'
|
|
16
|
+
<%= IO.read(Chef::Config[:validation_key]) %>
|
|
17
|
+
EOP
|
|
18
|
+
) > /tmp/validation.pem
|
|
19
|
+
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
|
20
|
+
rm /tmp/validation.pem
|
|
21
|
+
|
|
22
|
+
<% if @config[:chef_node_name] %>
|
|
23
|
+
[ `grep -qx "node_name \"<%= @config[:chef_node_name] %>\"" /etc/chef/client.rb` ] || echo "node_name \"<%= @config[:chef_node_name] %>\"" >> /etc/chef/client.rb
|
|
24
|
+
<% end -%>
|
|
25
|
+
|
|
26
|
+
(
|
|
27
|
+
cat <<'EOP'
|
|
28
|
+
<%= { "run_list" => @run_list }.to_json %>
|
|
29
|
+
EOP
|
|
30
|
+
) > /etc/chef/first-boot.json
|
|
31
|
+
|
|
32
|
+
/usr/bin/chef-client -j /etc/chef/first-boot.json'
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
bash -c '
|
|
2
|
+
if [ ! -f /usr/bin/chef-client ]; then
|
|
3
|
+
apt-get update
|
|
4
|
+
apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
|
|
5
|
+
cd /tmp
|
|
6
|
+
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
|
|
7
|
+
tar zxf rubygems-1.3.7.tgz
|
|
8
|
+
cd rubygems-1.3.7
|
|
9
|
+
ruby setup.rb --no-format-executable
|
|
10
|
+
fi
|
|
11
|
+
gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
|
|
12
|
+
|
|
13
|
+
mkdir -p /etc/chef
|
|
14
|
+
|
|
15
|
+
(
|
|
16
|
+
cat <<'EOP'
|
|
17
|
+
<%= IO.read(Chef::Config[:validation_key]) %>
|
|
18
|
+
EOP
|
|
19
|
+
) > /tmp/validation.pem
|
|
20
|
+
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
|
21
|
+
rm /tmp/validation.pem
|
|
22
|
+
|
|
23
|
+
(
|
|
24
|
+
cat <<'EOP'
|
|
25
|
+
log_level :info
|
|
26
|
+
log_location STDOUT
|
|
27
|
+
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
|
|
28
|
+
validation_client_name "<%= Chef::Config[:validation_client_name] %>"
|
|
29
|
+
<% if @config[:chef_node_name] == nil %>
|
|
30
|
+
# Using default node name"
|
|
31
|
+
<% else %>
|
|
32
|
+
node_name "<%= @config[:chef_node_name] %>"
|
|
33
|
+
<% end %>
|
|
34
|
+
EOP
|
|
35
|
+
) > /etc/chef/client.rb
|
|
36
|
+
|
|
37
|
+
(
|
|
38
|
+
cat <<'EOP'
|
|
39
|
+
<%= { "run_list" => @run_list }.to_json %>
|
|
40
|
+
EOP
|
|
41
|
+
) > /etc/chef/first-boot.json
|
|
42
|
+
|
|
43
|
+
/usr/bin/chef-client -j /etc/chef/first-boot.json'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
cscript /nologo client-install.vbs <%= @config[:proxy] %>
|
|
2
|
+
|
|
3
|
+
> c:/chef/etc/client.rb (
|
|
4
|
+
@echo.log_level :info
|
|
5
|
+
@echo.log_location STDOUT
|
|
6
|
+
@echo.chef_server_url "<%= Chef::Config[:chef_server_url] %>"
|
|
7
|
+
@echo.validation_client_name "<%= Chef::Config[:validation_client_name] %>"
|
|
8
|
+
@echo.client_key "c:/chef/etc/client.pem"
|
|
9
|
+
@echo.validation_key "c:/chef/etc/validation.pem"
|
|
10
|
+
@echo.checksum_path "c:/chef/var/checksums"
|
|
11
|
+
@echo.file_cache_path "c:/chef/var/cache"
|
|
12
|
+
@echo.file_backup_path "c:/chef/var/backup"
|
|
13
|
+
@echo.cache_options ^( {:path, "c:/chef/var/cache/checksums", :skip_expires, true} ^)
|
|
14
|
+
<% if Chef::Config[:http_proxy] != nil %>
|
|
15
|
+
@echo.http_proxy "<%= Chef::Config[:http_proxy] %>"
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if Chef::Config[:https_proxy] != nil %>
|
|
18
|
+
@echo.https_proxy "<%= Chef::Config[:https_proxy] %>"
|
|
19
|
+
<% end %>
|
|
20
|
+
<% if Chef::Config[:no_proxy] != nil %>
|
|
21
|
+
@echo.no_proxy "<%= Chef::Config[:no_proxy] %>"
|
|
22
|
+
<% end %>
|
|
23
|
+
<% if @config[:chef_node_name] == nil %>
|
|
24
|
+
@echo.# Using default node name
|
|
25
|
+
<% else %>
|
|
26
|
+
@echo.node_name "<%= @config[:chef_node_name] %>"
|
|
27
|
+
<% end %>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
> c:/chef/etc/first-boot.json (
|
|
31
|
+
@echo.<%= { "run_list" => @run_list }.to_json %>
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
c:/ruby/bin/ruby c:/ruby/bin/chef-client -c c:/chef/etc/client.rb -j c:/chef/etc/first-boot.json -l <%= Chef::Config[:log_level] %>"
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
|
3
|
+
# Copyright:: Copyright (c) 2010 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
|
+
require 'tempfile'
|
|
22
|
+
require 'erubis'
|
|
23
|
+
|
|
24
|
+
class Chef
|
|
25
|
+
class Knife
|
|
26
|
+
class Bootstrap < Knife
|
|
27
|
+
|
|
28
|
+
banner "knife bootstrap FQDN [RUN LIST...] (options)"
|
|
29
|
+
|
|
30
|
+
option :ssh_user,
|
|
31
|
+
:short => "-x USERNAME",
|
|
32
|
+
:long => "--ssh-user USERNAME",
|
|
33
|
+
:description => "The ssh username",
|
|
34
|
+
:default => "root"
|
|
35
|
+
|
|
36
|
+
option :ssh_password,
|
|
37
|
+
:short => "-P PASSWORD",
|
|
38
|
+
:long => "--ssh-password PASSWORD",
|
|
39
|
+
:description => "The ssh password"
|
|
40
|
+
|
|
41
|
+
option :ssh_gateway,
|
|
42
|
+
:short => "-G GATEWAY",
|
|
43
|
+
:long => "--ssh-gateway GATEWAY",
|
|
44
|
+
:description => "The ssh gateway"
|
|
45
|
+
|
|
46
|
+
option :identity_file,
|
|
47
|
+
:short => "-i IDENTITY_FILE",
|
|
48
|
+
:long => "--identity-file IDENTITY_FILE",
|
|
49
|
+
:description => "The SSH identity file used for authentication"
|
|
50
|
+
|
|
51
|
+
option :chef_node_name,
|
|
52
|
+
:short => "-N NAME",
|
|
53
|
+
:long => "--node-name NAME",
|
|
54
|
+
:description => "The Chef node name for your new node"
|
|
55
|
+
|
|
56
|
+
option :prerelease,
|
|
57
|
+
:long => "--prerelease",
|
|
58
|
+
:description => "Install the pre-release chef gems"
|
|
59
|
+
|
|
60
|
+
option :distro,
|
|
61
|
+
:short => "-d DISTRO",
|
|
62
|
+
:long => "--distro DISTRO",
|
|
63
|
+
:description => "Bootstrap a distro using a template",
|
|
64
|
+
:default => "ubuntu10.04-gems"
|
|
65
|
+
|
|
66
|
+
option :use_sudo,
|
|
67
|
+
:long => "--sudo",
|
|
68
|
+
:description => "Execute the bootstrap via sudo",
|
|
69
|
+
:boolean => true
|
|
70
|
+
|
|
71
|
+
option :template_file,
|
|
72
|
+
:long => "--template-file TEMPLATE",
|
|
73
|
+
:description => "Full path to location of template to use",
|
|
74
|
+
:default => false
|
|
75
|
+
|
|
76
|
+
option :run_list,
|
|
77
|
+
:short => "-r RUN_LIST",
|
|
78
|
+
:long => "--run-list RUN_LIST",
|
|
79
|
+
:description => "Comma separated list of roles/recipes to apply",
|
|
80
|
+
:proc => lambda { |o| o.split(",") },
|
|
81
|
+
:default => []
|
|
82
|
+
|
|
83
|
+
def h
|
|
84
|
+
@highline ||= HighLine.new
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def load_template(template=nil)
|
|
88
|
+
# Are we bootstrapping using an already shipped template?
|
|
89
|
+
if config[:template_file]
|
|
90
|
+
bootstrap_files = config[:template_file]
|
|
91
|
+
else
|
|
92
|
+
bootstrap_files = []
|
|
93
|
+
bootstrap_files << File.join(File.dirname(__FILE__), 'bootstrap', "#{config[:distro]}.erb")
|
|
94
|
+
bootstrap_files << File.join(Dir.pwd, ".chef", "bootstrap", "#{config[:distro]}.erb")
|
|
95
|
+
bootstrap_files << File.join(ENV['HOME'], '.chef', 'bootstrap', "#{config[:distro]}.erb")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
template = Array(bootstrap_files).find do |bootstrap_template|
|
|
99
|
+
Chef::Log.debug("Looking for bootstrap template in #{File.dirname(bootstrap_template)}")
|
|
100
|
+
File.exists?(bootstrap_template)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
unless template
|
|
104
|
+
Chef::Log.info("Can not find bootstrap definition for #{config[:distro]}")
|
|
105
|
+
raise Errno::ENOENT
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Chef::Log.debug("Found bootstrap template in #{File.dirname(template)}")
|
|
109
|
+
|
|
110
|
+
IO.read(template).chomp
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def render_template(template=nil)
|
|
114
|
+
context = {}
|
|
115
|
+
context[:run_list] = config[:run_list]
|
|
116
|
+
context[:config] = config
|
|
117
|
+
Erubis::Eruby.new(template).evaluate(context)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def run
|
|
121
|
+
require 'highline'
|
|
122
|
+
|
|
123
|
+
validate_name_args!
|
|
124
|
+
|
|
125
|
+
$stdout.sync = true
|
|
126
|
+
|
|
127
|
+
Chef::Log.info("Bootstrapping Chef on #{h.color(config[:server_name], :bold)}")
|
|
128
|
+
|
|
129
|
+
begin
|
|
130
|
+
knife_ssh.run
|
|
131
|
+
rescue Net::SSH::AuthenticationFailed
|
|
132
|
+
unless config[:ssh_password]
|
|
133
|
+
puts "Failed to authenticate #{config[:ssh_user]} - trying password auth"
|
|
134
|
+
knife_ssh_with_password_auth.run
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def validate_name_args!
|
|
140
|
+
if Array(@name_args).first.nil?
|
|
141
|
+
Chef::Log.error("Must pass an FQDN or ip to bootstrap")
|
|
142
|
+
exit 1
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def server_name
|
|
147
|
+
Array(@name_args).first
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def knife_ssh
|
|
151
|
+
ssh = Chef::Knife::Ssh.new
|
|
152
|
+
ssh.name_args = [ server_name, ssh_command ]
|
|
153
|
+
ssh.config[:ssh_user] = config[:ssh_user]
|
|
154
|
+
ssh.config[:ssh_password] = config[:ssh_password]
|
|
155
|
+
ssh.config[:ssh_gateway] = config[:ssh_gateway]
|
|
156
|
+
ssh.config[:identity_file] = config[:identity_file]
|
|
157
|
+
ssh.config[:manual] = true
|
|
158
|
+
ssh
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def knife_ssh_with_password_auth
|
|
162
|
+
ssh = knife_ssh
|
|
163
|
+
ssh.config[:identity_file] = nil
|
|
164
|
+
ssh.config[:ssh_password] = ssh.get_password
|
|
165
|
+
ssh
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def ssh_command
|
|
169
|
+
command = render_template(load_template(config[:bootstrap_template]))
|
|
170
|
+
|
|
171
|
+
if config[:use_sudo]
|
|
172
|
+
command = "sudo #{command}"
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
command
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|