mbailey-chef 0.9.12.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,256 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008, 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 'rubygems'
|
20
|
+
require 'json'
|
21
|
+
require 'chef'
|
22
|
+
require 'chef/role'
|
23
|
+
require 'chef/cookbook/metadata'
|
24
|
+
require 'tempfile'
|
25
|
+
require 'rake'
|
26
|
+
|
27
|
+
# Allow REMOTE options to be overridden on the command line
|
28
|
+
REMOTE_HOST = ENV["REMOTE_HOST"] if ENV["REMOTE_HOST"] != nil
|
29
|
+
REMOTE_SUDO = ENV["REMOTE_SUDO"] if ENV["REMOTE_SUDO"] != nil
|
30
|
+
if defined? REMOTE_HOST
|
31
|
+
REMOTE_PATH_PREFIX = "#{REMOTE_HOST}:"
|
32
|
+
REMOTE_EXEC_PREFIX = "ssh #{REMOTE_HOST}"
|
33
|
+
REMOTE_EXEC_PREFIX += " sudo" if defined? REMOTE_SUDO
|
34
|
+
LOCAL_EXEC_PREFIX = ""
|
35
|
+
else
|
36
|
+
REMOTE_PATH_PREFIX = ""
|
37
|
+
REMOTE_EXEC_PREFIX = ""
|
38
|
+
LOCAL_EXEC_PREFIX = "sudo"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Update your repository from source control"
|
42
|
+
task :update do
|
43
|
+
puts "** Updating your repository"
|
44
|
+
|
45
|
+
case $vcs
|
46
|
+
when :svn
|
47
|
+
sh %{svn up}
|
48
|
+
when :git
|
49
|
+
pull = false
|
50
|
+
IO.foreach(File.join(TOPDIR, ".git", "config")) do |line|
|
51
|
+
pull = true if line =~ /\[remote "origin"\]/
|
52
|
+
end
|
53
|
+
if pull
|
54
|
+
sh %{git pull}
|
55
|
+
else
|
56
|
+
puts "* Skipping git pull, no origin specified"
|
57
|
+
end
|
58
|
+
else
|
59
|
+
puts "* No SCM configured, skipping update"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Install the latest copy of the repository on this Chef Server"
|
64
|
+
task :install => [ :update, :roles, :upload_cookbooks ] do
|
65
|
+
if File.exists?(File.join(TOPDIR, "config", "server.rb"))
|
66
|
+
puts "* Installing new Chef Server Config"
|
67
|
+
sh "#{LOCAL_EXEC_PREFIX} rsync -rlt --delete --exclude '.svn' --exclude '.git*' config/server.rb #{REMOTE_PATH_PREFIX}#{CHEF_SERVER_CONFIG}"
|
68
|
+
end
|
69
|
+
if File.exists?(File.join(TOPDIR, "config", "client.rb"))
|
70
|
+
puts "* Installing new Chef Client Config"
|
71
|
+
sh "#{LOCAL_EXEC_PREFIX} rsync -rlt --delete --exclude '.svn' --exclude '.git*' config/client.rb #{REMOTE_PATH_PREFIX}#{CHEF_CLIENT_CONFIG}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "By default, run rake test_cookbooks"
|
76
|
+
task :default => [ :test_cookbooks ]
|
77
|
+
|
78
|
+
desc "Create a new cookbook (with COOKBOOK=name, optional CB_PREFIX=site-)"
|
79
|
+
task :new_cookbook do
|
80
|
+
puts "***WARN: rake new_cookbook is deprecated. Please use 'knife cookbook new COOKBOOK' command.***"
|
81
|
+
create_cookbook(File.join(TOPDIR, "#{ENV["CB_PREFIX"]}cookbooks"))
|
82
|
+
create_readme(File.join(TOPDIR, "#{ENV["CB_PREFIX"]}cookbooks"))
|
83
|
+
create_metadata(File.join(TOPDIR, "#{ENV["CB_PREFIX"]}cookbooks"))
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_cookbook(dir)
|
87
|
+
raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
|
88
|
+
puts "** Creating cookbook #{ENV["COOKBOOK"]}"
|
89
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "attributes")}"
|
90
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "recipes")}"
|
91
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "definitions")}"
|
92
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "libraries")}"
|
93
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "resources")}"
|
94
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "providers")}"
|
95
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "files", "default")}"
|
96
|
+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "templates", "default")}"
|
97
|
+
unless File.exists?(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"))
|
98
|
+
open(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"), "w") do |file|
|
99
|
+
file.puts <<-EOH
|
100
|
+
#
|
101
|
+
# Cookbook Name:: #{ENV["COOKBOOK"]}
|
102
|
+
# Recipe:: default
|
103
|
+
#
|
104
|
+
# Copyright #{Time.now.year}, #{COMPANY_NAME}
|
105
|
+
#
|
106
|
+
EOH
|
107
|
+
case NEW_COOKBOOK_LICENSE
|
108
|
+
when :apachev2
|
109
|
+
file.puts <<-EOH
|
110
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
111
|
+
# you may not use this file except in compliance with the License.
|
112
|
+
# You may obtain a copy of the License at
|
113
|
+
#
|
114
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
115
|
+
#
|
116
|
+
# Unless required by applicable law or agreed to in writing, software
|
117
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
118
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
119
|
+
# See the License for the specific language governing permissions and
|
120
|
+
# limitations under the License.
|
121
|
+
#
|
122
|
+
EOH
|
123
|
+
when :none
|
124
|
+
file.puts <<-EOH
|
125
|
+
# All rights reserved - Do Not Redistribute
|
126
|
+
#
|
127
|
+
EOH
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def create_readme(dir)
|
134
|
+
raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
|
135
|
+
puts "** Creating README for cookbook: #{ENV["COOKBOOK"]}"
|
136
|
+
unless File.exists?(File.join(dir, ENV["COOKBOOK"], "README.rdoc"))
|
137
|
+
open(File.join(dir, ENV["COOKBOOK"], "README.rdoc"), "w") do |file|
|
138
|
+
file.puts <<-EOH
|
139
|
+
= DESCRIPTION:
|
140
|
+
|
141
|
+
= REQUIREMENTS:
|
142
|
+
|
143
|
+
= ATTRIBUTES:
|
144
|
+
|
145
|
+
= USAGE:
|
146
|
+
|
147
|
+
EOH
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def create_metadata(dir)
|
153
|
+
raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
|
154
|
+
puts "** Creating metadata for cookbook: #{ENV["COOKBOOK"]}"
|
155
|
+
|
156
|
+
case NEW_COOKBOOK_LICENSE
|
157
|
+
when :apachev2
|
158
|
+
license = "Apache 2.0"
|
159
|
+
when :none
|
160
|
+
license = "All rights reserved"
|
161
|
+
end
|
162
|
+
|
163
|
+
unless File.exists?(File.join(dir, ENV["COOKBOOK"], "metadata.rb"))
|
164
|
+
open(File.join(dir, ENV["COOKBOOK"], "metadata.rb"), "w") do |file|
|
165
|
+
if File.exists?(File.join(dir, ENV["COOKBOOK"], 'README.rdoc'))
|
166
|
+
long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))"
|
167
|
+
end
|
168
|
+
file.puts <<-EOH
|
169
|
+
maintainer "#{COMPANY_NAME}"
|
170
|
+
maintainer_email "#{SSL_EMAIL_ADDRESS}"
|
171
|
+
license "#{license}"
|
172
|
+
description "Installs/Configures #{ENV["COOKBOOK"]}"
|
173
|
+
#{long_description}
|
174
|
+
version "0.1"
|
175
|
+
EOH
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
desc "Create a new self-signed SSL certificate for FQDN=foo.example.com"
|
181
|
+
task :ssl_cert do
|
182
|
+
$expect_verbose = true
|
183
|
+
fqdn = ENV["FQDN"]
|
184
|
+
fqdn =~ /^(.+?)\.(.+)$/
|
185
|
+
hostname = $1
|
186
|
+
domain = $2
|
187
|
+
keyfile = fqdn.gsub("*", "wildcard")
|
188
|
+
raise "Must provide FQDN!" unless fqdn && hostname && domain
|
189
|
+
puts "** Creating self signed SSL Certificate for #{fqdn}"
|
190
|
+
sh("(cd #{CADIR} && openssl genrsa 2048 > #{keyfile}.key)")
|
191
|
+
sh("(cd #{CADIR} && chmod 644 #{keyfile}.key)")
|
192
|
+
puts "* Generating Self Signed Certificate Request"
|
193
|
+
tf = Tempfile.new("#{keyfile}.ssl-conf")
|
194
|
+
ssl_config = <<EOH
|
195
|
+
[ req ]
|
196
|
+
distinguished_name = req_distinguished_name
|
197
|
+
prompt = no
|
198
|
+
|
199
|
+
[ req_distinguished_name ]
|
200
|
+
C = #{SSL_COUNTRY_NAME}
|
201
|
+
ST = #{SSL_STATE_NAME}
|
202
|
+
L = #{SSL_LOCALITY_NAME}
|
203
|
+
O = #{COMPANY_NAME}
|
204
|
+
OU = #{SSL_ORGANIZATIONAL_UNIT_NAME}
|
205
|
+
CN = #{fqdn}
|
206
|
+
emailAddress = #{SSL_EMAIL_ADDRESS}
|
207
|
+
EOH
|
208
|
+
tf.puts(ssl_config)
|
209
|
+
tf.close
|
210
|
+
sh("(cd #{CADIR} && openssl req -config '#{tf.path}' -new -x509 -nodes -sha1 -days 3650 -key #{keyfile}.key > #{keyfile}.crt)")
|
211
|
+
sh("(cd #{CADIR} && openssl x509 -noout -fingerprint -text < #{keyfile}.crt > #{keyfile}.info)")
|
212
|
+
sh("(cd #{CADIR} && cat #{keyfile}.crt #{keyfile}.key > #{keyfile}.pem)")
|
213
|
+
sh("(cd #{CADIR} && chmod 644 #{keyfile}.pem)")
|
214
|
+
end
|
215
|
+
|
216
|
+
rule(%r{\b(?:site-)?cookbooks/[^/]+/metadata\.json\Z} => [ proc { |task_name| task_name.sub(/\.[^.]+$/, '.rb') } ]) do |t|
|
217
|
+
system("knife cookbook metadata from file #{t.source}")
|
218
|
+
end
|
219
|
+
|
220
|
+
desc "Build cookbook metadata.json from metadata.rb"
|
221
|
+
task :metadata => FileList[File.join(TOPDIR, '*cookbooks', ENV['COOKBOOK'] || '*', 'metadata.rb')].pathmap('%X.json')
|
222
|
+
|
223
|
+
rule(%r{\broles/\S+\.json\Z} => [ proc { |task_name| task_name.sub(/\.[^.]+$/, '.rb') } ]) do |t|
|
224
|
+
system("knife role from file #{t.source}")
|
225
|
+
end
|
226
|
+
|
227
|
+
desc "Update roles"
|
228
|
+
task :roles => FileList[File.join(TOPDIR, 'roles', '**', '*.rb')].pathmap('%X.json')
|
229
|
+
|
230
|
+
desc "Update a specific role"
|
231
|
+
task :role, :role_name do |t, args|
|
232
|
+
system("knife role from file #{File.join(TOPDIR, 'roles', args.role_name)}.rb")
|
233
|
+
end
|
234
|
+
|
235
|
+
desc "Upload all cookbooks"
|
236
|
+
task :upload_cookbooks => [ :metadata ]
|
237
|
+
task :upload_cookbooks do
|
238
|
+
system("knife cookbook upload --all")
|
239
|
+
end
|
240
|
+
|
241
|
+
desc "Upload a single cookbook"
|
242
|
+
task :upload_cookbook => [ :metadata ]
|
243
|
+
task :upload_cookbook, :cookbook do |t, args|
|
244
|
+
system("knife cookbook upload #{args.cookbook}")
|
245
|
+
end
|
246
|
+
|
247
|
+
desc "Test all cookbooks"
|
248
|
+
task :test_cookbooks do
|
249
|
+
system("knife cookbook test --all")
|
250
|
+
end
|
251
|
+
|
252
|
+
desc "Test a single cookbook"
|
253
|
+
task :test_cookbook, :cookbook do |t, args|
|
254
|
+
system("knife cookbook test #{args.cookbook}")
|
255
|
+
end
|
256
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Nuo Yan (<nuo@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
|
+
require 'fileutils'
|
19
|
+
require 'tempfile'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Util
|
23
|
+
class FileEdit
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_accessor :original_pathname, :contents, :file_edited
|
28
|
+
|
29
|
+
public
|
30
|
+
|
31
|
+
def initialize(filepath)
|
32
|
+
@original_pathname = filepath
|
33
|
+
@file_edited = false
|
34
|
+
|
35
|
+
raise ArgumentError, "File doesn't exist" unless File.exist? @original_pathname
|
36
|
+
raise ArgumentError, "File is blank" unless (@contents = File.new(@original_pathname).readlines).length > 0
|
37
|
+
end
|
38
|
+
|
39
|
+
#search the file line by line and match each line with the given regex
|
40
|
+
#if matched, replace the whole line with newline.
|
41
|
+
def search_file_replace_line(regex, newline)
|
42
|
+
search_match(regex, newline, 'r', 1)
|
43
|
+
end
|
44
|
+
|
45
|
+
#search the file line by line and match each line with the given regex
|
46
|
+
#if matched, replace the match (all occurances) with the replace parameter
|
47
|
+
def search_file_replace(regex, replace)
|
48
|
+
search_match(regex, replace, 'r', 2)
|
49
|
+
end
|
50
|
+
|
51
|
+
#search the file line by line and match each line with the given regex
|
52
|
+
#if matched, delete the line
|
53
|
+
def search_file_delete_line(regex)
|
54
|
+
search_match(regex, " ", 'd', 1)
|
55
|
+
end
|
56
|
+
|
57
|
+
#search the file line by line and match each line with the given regex
|
58
|
+
#if matched, delete the match (all occurances) from the line
|
59
|
+
def search_file_delete(regex)
|
60
|
+
search_match(regex, " ", 'd', 2)
|
61
|
+
end
|
62
|
+
|
63
|
+
#search the file line by line and match each line with the given regex
|
64
|
+
#if matched, insert newline after each matching line
|
65
|
+
def insert_line_after_match(regex, newline)
|
66
|
+
search_match(regex, newline, 'i', 0)
|
67
|
+
end
|
68
|
+
|
69
|
+
#Make a copy of old_file and write new file out (only if file changed)
|
70
|
+
def write_file
|
71
|
+
|
72
|
+
# file_edited is false when there was no match in the whole file and thus no contents have changed.
|
73
|
+
if file_edited
|
74
|
+
backup_pathname = original_pathname + ".old"
|
75
|
+
FileUtils.cp(original_pathname, backup_pathname, :preserve => true)
|
76
|
+
File.open(original_pathname, "w") do |newfile|
|
77
|
+
contents.each do |line|
|
78
|
+
newfile.puts(line)
|
79
|
+
end
|
80
|
+
newfile.flush
|
81
|
+
end
|
82
|
+
end
|
83
|
+
self.file_edited = false
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
#helper method to do the match, replace, delete, and insert operations
|
89
|
+
#command is the switch of delete, replace, and insert ('d', 'r', 'i')
|
90
|
+
#method is to control operation on whole line or only the match (1 for line, 2 for match)
|
91
|
+
def search_match(regex, replace, command, method)
|
92
|
+
|
93
|
+
#convert regex to a Regexp object (if not already is one) and store it in exp.
|
94
|
+
exp = Regexp.new(regex)
|
95
|
+
|
96
|
+
#loop through contents and do the appropriate operation depending on 'command' and 'method'
|
97
|
+
new_contents = []
|
98
|
+
|
99
|
+
contents.each do |line|
|
100
|
+
if line.match(exp)
|
101
|
+
self.file_edited = true
|
102
|
+
case
|
103
|
+
when command == 'r'
|
104
|
+
new_contents << ((method == 1) ? replace : line.gsub!(exp, replace))
|
105
|
+
when command == 'd'
|
106
|
+
if method == 2
|
107
|
+
new_contents << line.gsub!(exp, "")
|
108
|
+
end
|
109
|
+
when command == 'i'
|
110
|
+
new_contents << line
|
111
|
+
new_contents << replace
|
112
|
+
end
|
113
|
+
else
|
114
|
+
new_contents << line
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
self.contents = new_contents
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,101 @@
|
|
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
|
+
|
19
|
+
require 'chef/util/windows'
|
20
|
+
|
21
|
+
#wrapper around a subset of the NetGroup* APIs.
|
22
|
+
#nothing Chef specific, but not complete enough to be its own gem, so util for now.
|
23
|
+
class Chef::Util::Windows::NetGroup < Chef::Util::Windows
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def pack_str(s)
|
28
|
+
[str_to_ptr(s)].pack('L')
|
29
|
+
end
|
30
|
+
|
31
|
+
def modify_members(members, func)
|
32
|
+
buffer = 0.chr * (members.size * PTR_SIZE)
|
33
|
+
members.each_with_index do |member,offset|
|
34
|
+
buffer[offset*PTR_SIZE,PTR_SIZE] = pack_str(multi_to_wide(member))
|
35
|
+
end
|
36
|
+
rc = func.call(nil, @name, 3, buffer, members.size)
|
37
|
+
if rc != NERR_Success
|
38
|
+
raise ArgumentError, get_last_error(rc)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
public
|
43
|
+
|
44
|
+
def initialize(groupname)
|
45
|
+
@name = multi_to_wide(groupname)
|
46
|
+
end
|
47
|
+
|
48
|
+
def local_get_members
|
49
|
+
group_members = []
|
50
|
+
handle = 0.chr * PTR_SIZE
|
51
|
+
rc = ERROR_MORE_DATA
|
52
|
+
|
53
|
+
while rc == ERROR_MORE_DATA
|
54
|
+
ptr = 0.chr * PTR_SIZE
|
55
|
+
nread = 0.chr * PTR_SIZE
|
56
|
+
total = 0.chr * PTR_SIZE
|
57
|
+
|
58
|
+
rc = NetLocalGroupGetMembers.call(nil, @name, 1, ptr, -1,
|
59
|
+
nread, total, handle)
|
60
|
+
if (rc == NERR_Success) || (rc == ERROR_MORE_DATA)
|
61
|
+
ptr = ptr.unpack('L')[0]
|
62
|
+
nread = nread.unpack('i')[0]
|
63
|
+
members = 0.chr * (nread * (PTR_SIZE * 3)) #nread * sizeof(LOCALGROUP_MEMBERS_INFO_1)
|
64
|
+
memcpy(members, ptr, members.size)
|
65
|
+
|
66
|
+
#3 pointer fields in LOCALGROUP_MEMBERS_INFO_1, offset 2*PTR_SIZE is lgrmi1_name
|
67
|
+
nread.times do |i|
|
68
|
+
offset = (i * 3) + 2
|
69
|
+
member = lpwstr_to_s(members, offset)
|
70
|
+
group_members << member
|
71
|
+
end
|
72
|
+
NetApiBufferFree(ptr)
|
73
|
+
else
|
74
|
+
raise ArgumentError, get_last_error(rc)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
group_members
|
78
|
+
end
|
79
|
+
|
80
|
+
def local_add
|
81
|
+
rc = NetLocalGroupAdd.call(nil, 0, pack_str(@name), nil)
|
82
|
+
if rc != NERR_Success
|
83
|
+
raise ArgumentError, get_last_error(rc)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def local_set_members(members)
|
88
|
+
modify_members(members, NetLocalGroupSetMembers)
|
89
|
+
end
|
90
|
+
|
91
|
+
def local_add_members(members)
|
92
|
+
modify_members(members, NetLocalGroupAddMembers)
|
93
|
+
end
|
94
|
+
|
95
|
+
def local_delete
|
96
|
+
rc = NetLocalGroupDel.call(nil, @name)
|
97
|
+
if rc != NERR_Success
|
98
|
+
raise ArgumentError, get_last_error(rc)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|