microwave 11.400.3 → 11.400.4
Sign up to get free protection for your applications and to get access to all the features.
- data/distro/README +2 -0
- data/distro/arch/etc/conf.d/chef-client.conf +5 -0
- data/distro/arch/etc/conf.d/chef-expander.conf +8 -0
- data/distro/arch/etc/conf.d/chef-server-webui.conf +10 -0
- data/distro/arch/etc/conf.d/chef-server.conf +10 -0
- data/distro/arch/etc/conf.d/chef-solr.conf +8 -0
- data/distro/arch/etc/rc.d/chef-client +90 -0
- data/distro/arch/etc/rc.d/chef-expander +78 -0
- data/distro/arch/etc/rc.d/chef-server +78 -0
- data/distro/arch/etc/rc.d/chef-server-webui +78 -0
- data/distro/arch/etc/rc.d/chef-solr +78 -0
- data/distro/common/html/chef-client.8.html +145 -0
- data/distro/common/html/chef-expander.8.html +164 -0
- data/distro/common/html/chef-expanderctl.8.html +146 -0
- data/distro/common/html/chef-server-webui.8.html +185 -0
- data/distro/common/html/chef-server.8.html +182 -0
- data/distro/common/html/chef-shell.1.html +286 -0
- data/distro/common/html/chef-solo.8.html +191 -0
- data/distro/common/html/chef-solr.8.html +165 -0
- data/distro/common/html/knife-bootstrap.1.html +241 -0
- data/distro/common/html/knife-client.1.html +219 -0
- data/distro/common/html/knife-configure.1.html +170 -0
- data/distro/common/html/knife-cookbook-site.1.html +241 -0
- data/distro/common/html/knife-cookbook.1.html +384 -0
- data/distro/common/html/knife-data-bag.1.html +238 -0
- data/distro/common/html/knife-environment.1.html +267 -0
- data/distro/common/html/knife-exec.1.html +134 -0
- data/distro/common/html/knife-index.1.html +125 -0
- data/distro/common/html/knife-node.1.html +250 -0
- data/distro/common/html/knife-role.1.html +200 -0
- data/distro/common/html/knife-search.1.html +288 -0
- data/distro/common/html/knife-ssh.1.html +156 -0
- data/distro/common/html/knife-status.1.html +128 -0
- data/distro/common/html/knife-tag.1.html +137 -0
- data/distro/common/html/knife.1.html +315 -0
- data/distro/common/man/man1/chef-shell.1 +220 -0
- data/distro/common/man/man1/knife-bootstrap.1 +201 -0
- data/distro/common/man/man1/knife-client.1 +99 -0
- data/distro/common/man/man1/knife-configure.1 +88 -0
- data/distro/common/man/man1/knife-cookbook-site.1 +145 -0
- data/distro/common/man/man1/knife-cookbook.1 +345 -0
- data/distro/common/man/man1/knife-data-bag.1 +136 -0
- data/distro/common/man/man1/knife-environment.1 +178 -0
- data/distro/common/man/man1/knife-exec.1 +43 -0
- data/distro/common/man/man1/knife-index.1 +29 -0
- data/distro/common/man/man1/knife-node.1 +134 -0
- data/distro/common/man/man1/knife-role.1 +88 -0
- data/distro/common/man/man1/knife-search.1 +280 -0
- data/distro/common/man/man1/knife-ssh.1 +79 -0
- data/distro/common/man/man1/knife-status.1 +29 -0
- data/distro/common/man/man1/knife-tag.1 +43 -0
- data/distro/common/man/man1/knife.1 +285 -0
- data/distro/common/man/man8/chef-client.8 +104 -0
- data/distro/common/man/man8/chef-expander.8 +97 -0
- data/distro/common/man/man8/chef-expanderctl.8 +62 -0
- data/distro/common/man/man8/chef-server-webui.8 +155 -0
- data/distro/common/man/man8/chef-server.8 +147 -0
- data/distro/common/man/man8/chef-solo.8 +158 -0
- data/distro/common/man/man8/chef-solr.8 +122 -0
- data/distro/common/markdown/README +3 -0
- data/distro/common/markdown/man1/chef-shell.mkd +195 -0
- data/distro/common/markdown/man1/knife-bootstrap.mkd +141 -0
- data/distro/common/markdown/man1/knife-client.mkd +103 -0
- data/distro/common/markdown/man1/knife-configure.mkd +70 -0
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +123 -0
- data/distro/common/markdown/man1/knife-cookbook.mkd +263 -0
- data/distro/common/markdown/man1/knife-data-bag.mkd +121 -0
- data/distro/common/markdown/man1/knife-environment.mkd +151 -0
- data/distro/common/markdown/man1/knife-exec.mkd +42 -0
- data/distro/common/markdown/man1/knife-index.mkd +30 -0
- data/distro/common/markdown/man1/knife-node.mkd +130 -0
- data/distro/common/markdown/man1/knife-role.mkd +85 -0
- data/distro/common/markdown/man1/knife-search.mkd +180 -0
- data/distro/common/markdown/man1/knife-ssh.mkd +69 -0
- data/distro/common/markdown/man1/knife-status.mkd +36 -0
- data/distro/common/markdown/man1/knife-tag.mkd +39 -0
- data/distro/common/markdown/man1/knife.mkd +213 -0
- data/distro/common/markdown/man8/chef-client.mkd +74 -0
- data/distro/common/markdown/man8/chef-expander.mkd +82 -0
- data/distro/common/markdown/man8/chef-expanderctl.mkd +58 -0
- data/distro/common/markdown/man8/chef-server-webui.mkd +121 -0
- data/distro/common/markdown/man8/chef-server.mkd +121 -0
- data/distro/common/markdown/man8/chef-solo.mkd +107 -0
- data/distro/common/markdown/man8/chef-solr.mkd +89 -0
- data/distro/debian/etc/default/chef-client +4 -0
- data/distro/debian/etc/default/chef-expander +8 -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 +8 -0
- data/distro/debian/etc/init.d/chef-client +210 -0
- data/distro/debian/etc/init.d/chef-expander +176 -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 +176 -0
- data/distro/debian/etc/init/chef-client.conf +17 -0
- data/distro/debian/etc/init/chef-expander.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.conf +17 -0
- data/distro/redhat/etc/init.d/chef-client +121 -0
- data/distro/redhat/etc/init.d/chef-expander +104 -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/logrotate.d/chef-client +8 -0
- data/distro/redhat/etc/logrotate.d/chef-expander +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/sysconfig/chef-client +15 -0
- data/distro/redhat/etc/sysconfig/chef-expander +7 -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/windows/service_manager.rb +164 -0
- data/lib/chef/api_client.rb +205 -0
- data/lib/chef/api_client/registration.rb +126 -0
- data/lib/chef/application.rb +225 -0
- data/lib/chef/application/agent.rb +18 -0
- data/lib/chef/application/apply.rb +160 -0
- data/lib/chef/application/client.rb +340 -0
- data/lib/chef/application/knife.rb +183 -0
- data/lib/chef/application/solo.rb +263 -0
- data/lib/chef/application/windows_service.rb +230 -0
- data/lib/chef/applications.rb +5 -0
- data/lib/chef/checksum/storage.rb +18 -0
- data/lib/chef/checksum/storage/filesystem.rb +56 -0
- data/lib/chef/chef_fs.rb +11 -0
- data/lib/chef/chef_fs/command_line.rb +232 -0
- data/lib/chef/chef_fs/file_pattern.rb +312 -0
- data/lib/chef/chef_fs/file_system.rb +358 -0
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +47 -0
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +121 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +109 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +31 -0
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +84 -0
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +188 -0
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +78 -0
- data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +54 -0
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +68 -0
- data/lib/chef/chef_fs/file_system/data_bag_dir.rb +78 -0
- data/lib/chef/chef_fs/file_system/data_bag_item.rb +59 -0
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +66 -0
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +90 -0
- data/lib/chef/chef_fs/file_system/file_system_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/file_system_root_dir.rb +31 -0
- data/lib/chef/chef_fs/file_system/must_delete_recursively_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +47 -0
- data/lib/chef/chef_fs/file_system/nonexistent_fs_object.rb +40 -0
- data/lib/chef/chef_fs/file_system/not_found_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +84 -0
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +123 -0
- data/lib/chef/chef_fs/knife.rb +77 -0
- data/lib/chef/chef_fs/path_utils.rb +64 -0
- data/lib/chef/client.rb +556 -0
- data/lib/chef/config.rb +354 -0
- data/lib/chef/cookbook/chefignore.rb +66 -0
- data/lib/chef/cookbook/cookbook_collection.rb +45 -0
- data/lib/chef/cookbook/cookbook_version_loader.rb +171 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +56 -0
- data/lib/chef/cookbook/file_vendor.rb +48 -0
- data/lib/chef/cookbook/metadata.rb +627 -0
- data/lib/chef/cookbook/remote_file_vendor.rb +84 -0
- data/lib/chef/cookbook/synchronizer.rb +216 -0
- data/lib/chef/cookbook/syntax_check.rb +183 -0
- data/lib/chef/cookbook_loader.rb +134 -0
- data/lib/chef/cookbook_site_streaming_uploader.rb +244 -0
- data/lib/chef/cookbook_uploader.rb +164 -0
- data/lib/chef/cookbook_version.rb +782 -0
- data/lib/chef/daemon.rb +172 -0
- data/lib/chef/data_bag.rb +145 -0
- data/lib/chef/data_bag_item.rb +214 -0
- data/lib/chef/digester.rb +73 -0
- data/lib/chef/dsl.rb +6 -0
- data/lib/chef/dsl/data_query.rb +71 -0
- data/lib/chef/dsl/include_attribute.rb +63 -0
- data/lib/chef/dsl/include_recipe.rb +45 -0
- data/lib/chef/dsl/platform_introspection.rb +218 -0
- data/lib/chef/dsl/recipe.rb +87 -0
- data/lib/chef/dsl/registry_helper.rb +59 -0
- data/lib/chef/encrypted_data_bag_item.rb +323 -0
- data/lib/chef/environment.rb +287 -0
- data/lib/chef/event_dispatch/base.rb +311 -0
- data/lib/chef/event_dispatch/dispatcher.rb +42 -0
- data/lib/chef/exceptions.rb +275 -0
- data/lib/chef/file_access_control.rb +75 -0
- data/lib/chef/file_access_control/unix.rb +216 -0
- data/lib/chef/file_access_control/windows.rb +310 -0
- data/lib/chef/file_cache.rb +220 -0
- data/lib/chef/formatters/base.rb +250 -0
- data/lib/chef/formatters/doc.rb +236 -0
- data/lib/chef/formatters/error_descriptor.rb +66 -0
- data/lib/chef/formatters/error_inspectors.rb +19 -0
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +111 -0
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +106 -0
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +146 -0
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +80 -0
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +125 -0
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +137 -0
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +117 -0
- data/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +118 -0
- data/lib/chef/formatters/error_mapper.rb +85 -0
- data/lib/chef/formatters/minimal.rb +235 -0
- data/lib/chef/handler.rb +235 -0
- data/lib/chef/handler/error_report.rb +33 -0
- data/lib/chef/handler/json_file.rb +65 -0
- data/lib/chef/json_compat.rb +147 -0
- data/lib/chef/knife.rb +589 -0
- data/lib/chef/knife/bootstrap.rb +233 -0
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +62 -0
- data/lib/chef/knife/bootstrap/centos5-gems.erb +62 -0
- data/lib/chef/knife/bootstrap/chef-full.erb +60 -0
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +44 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +53 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +48 -0
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +46 -0
- data/lib/chef/knife/client_bulk_delete.rb +65 -0
- data/lib/chef/knife/client_create.rb +80 -0
- data/lib/chef/knife/client_delete.rb +46 -0
- data/lib/chef/knife/client_edit.rb +45 -0
- data/lib/chef/knife/client_list.rb +42 -0
- data/lib/chef/knife/client_reregister.rb +59 -0
- data/lib/chef/knife/client_show.rb +52 -0
- data/lib/chef/knife/configure.rb +170 -0
- data/lib/chef/knife/configure_client.rb +50 -0
- data/lib/chef/knife/cookbook_bulk_delete.rb +72 -0
- data/lib/chef/knife/cookbook_create.rb +447 -0
- data/lib/chef/knife/cookbook_delete.rb +151 -0
- data/lib/chef/knife/cookbook_download.rb +137 -0
- data/lib/chef/knife/cookbook_list.rb +47 -0
- data/lib/chef/knife/cookbook_metadata.rb +108 -0
- data/lib/chef/knife/cookbook_metadata_from_file.rb +44 -0
- data/lib/chef/knife/cookbook_show.rb +102 -0
- data/lib/chef/knife/cookbook_site_download.rb +109 -0
- data/lib/chef/knife/cookbook_site_install.rb +164 -0
- data/lib/chef/knife/cookbook_site_list.rb +62 -0
- data/lib/chef/knife/cookbook_site_search.rb +51 -0
- data/lib/chef/knife/cookbook_site_share.rb +114 -0
- data/lib/chef/knife/cookbook_site_show.rb +60 -0
- data/lib/chef/knife/cookbook_site_unshare.rb +56 -0
- data/lib/chef/knife/cookbook_site_vendor.rb +46 -0
- data/lib/chef/knife/cookbook_test.rb +94 -0
- data/lib/chef/knife/cookbook_upload.rb +295 -0
- data/lib/chef/knife/core/bootstrap_context.rb +106 -0
- data/lib/chef/knife/core/cookbook_scm_repo.rb +160 -0
- data/lib/chef/knife/core/generic_presenter.rb +204 -0
- data/lib/chef/knife/core/node_editor.rb +130 -0
- data/lib/chef/knife/core/node_presenter.rb +137 -0
- data/lib/chef/knife/core/object_loader.rb +112 -0
- data/lib/chef/knife/core/subcommand_loader.rb +112 -0
- data/lib/chef/knife/core/text_formatter.rb +86 -0
- data/lib/chef/knife/core/ui.rb +219 -0
- data/lib/chef/knife/data_bag_create.rb +93 -0
- data/lib/chef/knife/data_bag_delete.rb +51 -0
- data/lib/chef/knife/data_bag_edit.rb +94 -0
- data/lib/chef/knife/data_bag_from_file.rb +136 -0
- data/lib/chef/knife/data_bag_list.rb +46 -0
- data/lib/chef/knife/data_bag_show.rb +81 -0
- data/lib/chef/knife/delete.rb +39 -0
- data/lib/chef/knife/diff.rb +46 -0
- data/lib/chef/knife/download.rb +50 -0
- 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 +83 -0
- data/lib/chef/knife/environment_list.rb +42 -0
- data/lib/chef/knife/environment_show.rb +53 -0
- data/lib/chef/knife/exec.rb +86 -0
- data/lib/chef/knife/help.rb +103 -0
- data/lib/chef/knife/help_topics.rb +4 -0
- data/lib/chef/knife/index_rebuild.rb +134 -0
- data/lib/chef/knife/list.rb +109 -0
- data/lib/chef/knife/node_bulk_delete.rb +80 -0
- data/lib/chef/knife/node_create.rb +50 -0
- data/lib/chef/knife/node_delete.rb +47 -0
- data/lib/chef/knife/node_edit.rb +72 -0
- data/lib/chef/knife/node_from_file.rb +50 -0
- data/lib/chef/knife/node_list.rb +46 -0
- data/lib/chef/knife/node_run_list_add.rb +75 -0
- data/lib/chef/knife/node_run_list_remove.rb +48 -0
- data/lib/chef/knife/node_show.rb +73 -0
- data/lib/chef/knife/raw.rb +108 -0
- data/lib/chef/knife/recipe_list.rb +32 -0
- data/lib/chef/knife/role_bulk_delete.rb +70 -0
- data/lib/chef/knife/role_create.rb +55 -0
- data/lib/chef/knife/role_delete.rb +47 -0
- data/lib/chef/knife/role_edit.rb +48 -0
- data/lib/chef/knife/role_from_file.rb +56 -0
- data/lib/chef/knife/role_list.rb +43 -0
- data/lib/chef/knife/role_show.rb +54 -0
- data/lib/chef/knife/search.rb +159 -0
- data/lib/chef/knife/show.rb +32 -0
- data/lib/chef/knife/ssh.rb +463 -0
- data/lib/chef/knife/status.rb +119 -0
- data/lib/chef/knife/tag_create.rb +52 -0
- data/lib/chef/knife/tag_delete.rb +60 -0
- data/lib/chef/knife/tag_list.rb +47 -0
- data/lib/chef/knife/upload.rb +50 -0
- data/lib/chef/knife/user_create.rb +93 -0
- data/lib/chef/knife/user_delete.rb +46 -0
- data/lib/chef/knife/user_edit.rb +53 -0
- data/lib/chef/knife/user_list.rb +42 -0
- data/lib/chef/knife/user_reregister.rb +59 -0
- data/lib/chef/knife/user_show.rb +52 -0
- data/lib/chef/log.rb +39 -0
- data/lib/chef/mash.rb +225 -0
- data/lib/chef/mixin/checksum.rb +32 -0
- data/lib/chef/mixin/command.rb +164 -0
- data/lib/chef/mixin/command/unix.rb +220 -0
- data/lib/chef/mixin/command/windows.rb +76 -0
- data/lib/chef/mixin/convert_to_class_name.rb +65 -0
- data/lib/chef/mixin/create_path.rb +57 -0
- data/lib/chef/mixin/deep_merge.rb +168 -0
- data/lib/chef/mixin/deprecation.rb +100 -0
- data/lib/chef/mixin/enforce_ownership_and_permissions.rb +39 -0
- data/lib/chef/mixin/file_class.rb +46 -0
- data/lib/chef/mixin/from_file.rb +50 -0
- data/lib/chef/mixin/get_source_from_package.rb +42 -0
- data/lib/chef/mixin/language.rb +48 -0
- data/lib/chef/mixin/language_include_attribute.rb +35 -0
- data/lib/chef/mixin/language_include_recipe.rb +32 -0
- data/lib/chef/mixin/params_validate.rb +225 -0
- data/lib/chef/mixin/path_sanity.rb +67 -0
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +35 -0
- data/lib/chef/mixin/securable.rb +205 -0
- data/lib/chef/mixin/shell_out.rb +69 -0
- data/lib/chef/mixin/template.rb +140 -0
- data/lib/chef/mixin/why_run.rb +332 -0
- data/lib/chef/mixin/xml_escape.rb +140 -0
- data/lib/chef/mixins.rb +14 -0
- data/lib/chef/monkey_patches/dir.rb +36 -0
- data/lib/chef/monkey_patches/fileutils.rb +65 -0
- data/lib/chef/monkey_patches/net_http.rb +22 -0
- data/lib/chef/monkey_patches/numeric.rb +15 -0
- data/lib/chef/monkey_patches/object.rb +9 -0
- data/lib/chef/monkey_patches/regexp.rb +34 -0
- data/lib/chef/monkey_patches/string.rb +49 -0
- data/lib/chef/monkey_patches/tempfile.rb +64 -0
- data/lib/chef/nil_argument.rb +3 -0
- data/lib/chef/node.rb +509 -0
- data/lib/chef/node/attribute.rb +398 -0
- data/lib/chef/node/attribute_collections.rb +206 -0
- data/lib/chef/node/immutable_collections.rb +186 -0
- data/lib/chef/platform.rb +519 -0
- data/lib/chef/provider.rb +176 -0
- data/lib/chef/provider/breakpoint.rb +36 -0
- data/lib/chef/provider/cookbook_file.rb +113 -0
- data/lib/chef/provider/cron.rb +214 -0
- data/lib/chef/provider/cron/solaris.rb +56 -0
- data/lib/chef/provider/deploy.rb +475 -0
- data/lib/chef/provider/deploy/revision.rb +80 -0
- data/lib/chef/provider/deploy/timestamped.rb +32 -0
- data/lib/chef/provider/directory.rb +131 -0
- data/lib/chef/provider/env.rb +152 -0
- data/lib/chef/provider/env/windows.rb +75 -0
- data/lib/chef/provider/erl_call.rb +106 -0
- data/lib/chef/provider/execute.rb +68 -0
- data/lib/chef/provider/file.rb +328 -0
- data/lib/chef/provider/git.rb +260 -0
- data/lib/chef/provider/group.rb +158 -0
- data/lib/chef/provider/group/aix.rb +70 -0
- data/lib/chef/provider/group/dscl.rb +129 -0
- data/lib/chef/provider/group/gpasswd.rb +65 -0
- data/lib/chef/provider/group/groupadd.rb +96 -0
- data/lib/chef/provider/group/groupmod.rb +120 -0
- data/lib/chef/provider/group/pw.rb +93 -0
- data/lib/chef/provider/group/suse.rb +60 -0
- data/lib/chef/provider/group/usermod.rb +68 -0
- data/lib/chef/provider/group/windows.rb +79 -0
- data/lib/chef/provider/http_request.rb +119 -0
- data/lib/chef/provider/ifconfig.rb +214 -0
- data/lib/chef/provider/link.rb +132 -0
- data/lib/chef/provider/log.rb +54 -0
- data/lib/chef/provider/lwrp_base.rb +150 -0
- data/lib/chef/provider/mdadm.rb +92 -0
- data/lib/chef/provider/mount.rb +128 -0
- data/lib/chef/provider/mount/mount.rb +252 -0
- data/lib/chef/provider/mount/windows.rb +81 -0
- data/lib/chef/provider/ohai.rb +47 -0
- data/lib/chef/provider/package.rb +229 -0
- data/lib/chef/provider/package/apt.rb +147 -0
- data/lib/chef/provider/package/dpkg.rb +128 -0
- data/lib/chef/provider/package/easy_install.rb +136 -0
- data/lib/chef/provider/package/freebsd.rb +149 -0
- data/lib/chef/provider/package/ips.rb +101 -0
- data/lib/chef/provider/package/macports.rb +105 -0
- data/lib/chef/provider/package/pacman.rb +111 -0
- data/lib/chef/provider/package/portage.rb +138 -0
- data/lib/chef/provider/package/rpm.rb +121 -0
- data/lib/chef/provider/package/rubygems.rb +548 -0
- data/lib/chef/provider/package/smartos.rb +84 -0
- data/lib/chef/provider/package/solaris.rb +139 -0
- data/lib/chef/provider/package/yum-dump.py +307 -0
- data/lib/chef/provider/package/yum.rb +1255 -0
- data/lib/chef/provider/package/zypper.rb +144 -0
- data/lib/chef/provider/registry_key.rb +156 -0
- data/lib/chef/provider/remote_directory.rb +180 -0
- data/lib/chef/provider/remote_file.rb +141 -0
- data/lib/chef/provider/resource_update.rb +55 -0
- data/lib/chef/provider/route.rb +223 -0
- data/lib/chef/provider/ruby_block.rb +42 -0
- data/lib/chef/provider/script.rb +57 -0
- data/lib/chef/provider/service.rb +173 -0
- data/lib/chef/provider/service/arch.rb +113 -0
- data/lib/chef/provider/service/debian.rb +152 -0
- data/lib/chef/provider/service/freebsd.rb +175 -0
- data/lib/chef/provider/service/gentoo.rb +67 -0
- data/lib/chef/provider/service/init.rb +89 -0
- data/lib/chef/provider/service/insserv.rb +52 -0
- data/lib/chef/provider/service/invokercd.rb +35 -0
- data/lib/chef/provider/service/macosx.rb +144 -0
- data/lib/chef/provider/service/redhat.rb +77 -0
- data/lib/chef/provider/service/simple.rb +172 -0
- data/lib/chef/provider/service/solaris.rb +86 -0
- data/lib/chef/provider/service/systemd.rb +115 -0
- data/lib/chef/provider/service/upstart.rb +232 -0
- data/lib/chef/provider/service/windows.rb +163 -0
- data/lib/chef/provider/subversion.rb +214 -0
- data/lib/chef/provider/template.rb +120 -0
- data/lib/chef/provider/template_finder.rb +61 -0
- data/lib/chef/provider/user.rb +206 -0
- data/lib/chef/provider/user/dscl.rb +288 -0
- data/lib/chef/provider/user/pw.rb +113 -0
- data/lib/chef/provider/user/useradd.rb +144 -0
- data/lib/chef/provider/user/windows.rb +124 -0
- data/lib/chef/providers.rb +103 -0
- data/lib/chef/recipe.rb +135 -0
- data/lib/chef/reserved_names.rb +9 -0
- data/lib/chef/resource.rb +794 -0
- data/lib/chef/resource/apt_package.rb +43 -0
- data/lib/chef/resource/bash.rb +33 -0
- data/lib/chef/resource/breakpoint.rb +35 -0
- data/lib/chef/resource/chef_gem.rb +53 -0
- data/lib/chef/resource/conditional.rb +101 -0
- data/lib/chef/resource/cookbook_file.rb +52 -0
- data/lib/chef/resource/cron.rb +202 -0
- data/lib/chef/resource/csh.rb +33 -0
- data/lib/chef/resource/deploy.rb +403 -0
- data/lib/chef/resource/deploy_revision.rb +40 -0
- data/lib/chef/resource/directory.rb +65 -0
- data/lib/chef/resource/dpkg_package.rb +34 -0
- data/lib/chef/resource/easy_install_package.rb +57 -0
- data/lib/chef/resource/env.rb +63 -0
- data/lib/chef/resource/erl_call.rb +86 -0
- data/lib/chef/resource/execute.rb +132 -0
- data/lib/chef/resource/file.rb +96 -0
- data/lib/chef/resource/freebsd_package.rb +35 -0
- data/lib/chef/resource/gem_package.rb +53 -0
- data/lib/chef/resource/git.rb +46 -0
- data/lib/chef/resource/group.rb +83 -0
- data/lib/chef/resource/http_request.rb +65 -0
- data/lib/chef/resource/ifconfig.rb +149 -0
- data/lib/chef/resource/ips_package.rb +42 -0
- data/lib/chef/resource/link.rb +92 -0
- data/lib/chef/resource/log.rb +74 -0
- data/lib/chef/resource/lwrp_base.rb +127 -0
- data/lib/chef/resource/macports_package.rb +29 -0
- data/lib/chef/resource/mdadm.rb +105 -0
- data/lib/chef/resource/mount.rb +139 -0
- data/lib/chef/resource/ohai.rb +54 -0
- data/lib/chef/resource/package.rb +84 -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/registry_key.rb +86 -0
- data/lib/chef/resource/remote_directory.rb +126 -0
- data/lib/chef/resource/remote_file.rb +81 -0
- data/lib/chef/resource/route.rb +140 -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 +51 -0
- data/lib/chef/resource/scm.rb +151 -0
- data/lib/chef/resource/script.rb +63 -0
- data/lib/chef/resource/service.rb +178 -0
- data/lib/chef/resource/smartos_package.rb +36 -0
- data/lib/chef/resource/solaris_package.rb +36 -0
- data/lib/chef/resource/subversion.rb +37 -0
- data/lib/chef/resource/template.rb +76 -0
- data/lib/chef/resource/timestamped_deploy.rb +31 -0
- data/lib/chef/resource/user.rb +134 -0
- data/lib/chef/resource/yum_package.rb +63 -0
- data/lib/chef/resource_collection.rb +221 -0
- data/lib/chef/resource_collection/stepable_iterator.rb +124 -0
- data/lib/chef/resource_definition.rb +67 -0
- data/lib/chef/resource_definition_list.rb +38 -0
- data/lib/chef/resource_platform_map.rb +151 -0
- data/lib/chef/resource_reporter.rb +281 -0
- data/lib/chef/resources.rb +69 -0
- data/lib/chef/rest.rb +438 -0
- data/lib/chef/rest/auth_credentials.rb +57 -0
- data/lib/chef/rest/cookie_jar.rb +31 -0
- data/lib/chef/rest/rest_request.rb +229 -0
- data/lib/chef/role.rb +253 -0
- data/lib/chef/run_context.rb +214 -0
- data/lib/chef/run_context/cookbook_compiler.rb +280 -0
- data/lib/chef/run_list.rb +163 -0
- data/lib/chef/run_list/run_list_expansion.rb +191 -0
- data/lib/chef/run_list/run_list_item.rb +99 -0
- data/lib/chef/run_list/versioned_recipe_list.rb +68 -0
- data/lib/chef/run_lock.rb +90 -0
- data/lib/chef/run_status.rb +124 -0
- data/lib/chef/runner.rb +118 -0
- data/lib/chef/sandbox.rb +20 -0
- data/lib/chef/scan_access_control.rb +133 -0
- data/lib/chef/search/query.rb +65 -0
- data/lib/chef/shef/ext.rb +19 -0
- data/lib/chef/shell.rb +329 -0
- data/lib/chef/shell/ext.rb +593 -0
- data/lib/chef/shell/model_wrapper.rb +120 -0
- data/lib/chef/shell/shell_rest.rb +28 -0
- data/lib/chef/shell/shell_session.rb +298 -0
- data/lib/chef/shell_out.rb +13 -0
- data/lib/chef/streaming_cookbook_uploader.rb +201 -0
- data/lib/chef/tasks/chef_repo.rake +334 -0
- data/lib/chef/user.rb +182 -0
- data/lib/chef/util/file_edit.rb +132 -0
- data/lib/chef/util/windows.rb +56 -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/version.rb +23 -0
- data/lib/chef/version_class.rb +70 -0
- data/lib/chef/version_constraint.rb +116 -0
- data/lib/chef/win32/api.rb +364 -0
- data/lib/chef/win32/api/error.rb +921 -0
- data/lib/chef/win32/api/file.rb +535 -0
- data/lib/chef/win32/api/memory.rb +105 -0
- data/lib/chef/win32/api/process.rb +41 -0
- data/lib/chef/win32/api/psapi.rb +51 -0
- data/lib/chef/win32/api/security.rb +385 -0
- data/lib/chef/win32/api/system.rb +192 -0
- data/lib/chef/win32/api/unicode.rb +178 -0
- data/lib/chef/win32/error.rb +73 -0
- data/lib/chef/win32/file.rb +167 -0
- data/lib/chef/win32/file/info.rb +100 -0
- data/lib/chef/win32/handle.rb +55 -0
- data/lib/chef/win32/memory.rb +101 -0
- data/lib/chef/win32/process.rb +84 -0
- data/lib/chef/win32/registry.rb +382 -0
- data/lib/chef/win32/security.rb +508 -0
- data/lib/chef/win32/security/ace.rb +125 -0
- data/lib/chef/win32/security/acl.rb +101 -0
- data/lib/chef/win32/security/securable_object.rb +109 -0
- data/lib/chef/win32/security/security_descriptor.rb +93 -0
- data/lib/chef/win32/security/sid.rb +199 -0
- data/lib/chef/win32/security/token.rb +64 -0
- data/lib/chef/win32/unicode.rb +43 -0
- data/lib/chef/win32/version.rb +119 -0
- metadata +553 -3
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 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/config'
|
20
|
+
require 'uri'
|
21
|
+
require 'chef/rest'
|
22
|
+
require 'chef/node'
|
23
|
+
require 'chef/role'
|
24
|
+
require 'chef/data_bag'
|
25
|
+
require 'chef/data_bag_item'
|
26
|
+
|
27
|
+
class Chef
|
28
|
+
class Search
|
29
|
+
class Query
|
30
|
+
|
31
|
+
attr_accessor :rest
|
32
|
+
|
33
|
+
def initialize(url=nil)
|
34
|
+
@rest = Chef::REST.new(url ||Chef::Config[:search_url])
|
35
|
+
end
|
36
|
+
|
37
|
+
# Search Solr for objects of a given type, for a given query. If you give
|
38
|
+
# it a block, it will handle the paging for you dynamically.
|
39
|
+
def search(type, query="*:*", sort='X_CHEF_id_CHEF_X asc', start=0, rows=1000, &block)
|
40
|
+
raise ArgumentError, "Type must be a string or a symbol!" unless (type.kind_of?(String) || type.kind_of?(Symbol))
|
41
|
+
|
42
|
+
response = @rest.get_rest("search/#{type}?q=#{escape(query)}&sort=#{escape(sort)}&start=#{escape(start)}&rows=#{escape(rows)}")
|
43
|
+
if block
|
44
|
+
response["rows"].each { |o| block.call(o) unless o.nil?}
|
45
|
+
unless (response["start"] + response["rows"].length) >= response["total"]
|
46
|
+
nstart = response["start"] + rows
|
47
|
+
search(type, query, sort, nstart, rows, &block)
|
48
|
+
end
|
49
|
+
true
|
50
|
+
else
|
51
|
+
[ response["rows"], response["start"], response["total"] ]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def list_indexes
|
56
|
+
response = @rest.get_rest("search")
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def escape(s)
|
61
|
+
s && URI.escape(s.to_s)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 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/shell/ext'
|
data/lib/chef/shell.rb
ADDED
@@ -0,0 +1,329 @@
|
|
1
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
2
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'singleton'
|
19
|
+
require 'pp'
|
20
|
+
require 'etc'
|
21
|
+
require 'mixlib/cli'
|
22
|
+
|
23
|
+
require 'chef'
|
24
|
+
require 'chef/version'
|
25
|
+
require 'chef/client'
|
26
|
+
require 'chef/config'
|
27
|
+
|
28
|
+
require 'chef/shell/shell_session'
|
29
|
+
require 'chef/shell/ext'
|
30
|
+
require 'chef/json_compat'
|
31
|
+
|
32
|
+
# = Shell
|
33
|
+
# Shell is Chef in an IRB session. Shell can interact with a Chef server via the
|
34
|
+
# REST API, and run and debug recipes interactively.
|
35
|
+
module Shell
|
36
|
+
LEADERS = Hash.new("")
|
37
|
+
LEADERS[Chef::Recipe] = ":recipe"
|
38
|
+
LEADERS[Chef::Node] = ":attributes"
|
39
|
+
|
40
|
+
class << self
|
41
|
+
attr_accessor :client_type
|
42
|
+
attr_accessor :options
|
43
|
+
attr_accessor :env
|
44
|
+
attr_writer :editor
|
45
|
+
end
|
46
|
+
|
47
|
+
# Start the irb REPL with chef-shell's customizations
|
48
|
+
def self.start
|
49
|
+
setup_logger
|
50
|
+
# FUGLY HACK: irb gives us no other choice.
|
51
|
+
irb_help = [:help, :irb_help, IRB::ExtendCommandBundle::NO_OVERRIDE]
|
52
|
+
IRB::ExtendCommandBundle.instance_variable_get(:@ALIASES).delete(irb_help)
|
53
|
+
|
54
|
+
parse_opts
|
55
|
+
|
56
|
+
# HACK: this duplicates the functions of IRB.start, but we have to do it
|
57
|
+
# to get access to the main object before irb starts.
|
58
|
+
::IRB.setup(nil)
|
59
|
+
|
60
|
+
irb = IRB::Irb.new
|
61
|
+
|
62
|
+
init(irb.context.main)
|
63
|
+
|
64
|
+
|
65
|
+
irb_conf[:IRB_RC].call(irb.context) if irb_conf[:IRB_RC]
|
66
|
+
irb_conf[:MAIN_CONTEXT] = irb.context
|
67
|
+
|
68
|
+
trap("SIGINT") do
|
69
|
+
irb.signal_handle
|
70
|
+
end
|
71
|
+
|
72
|
+
catch(:IRB_EXIT) do
|
73
|
+
irb.eval_input
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.setup_logger
|
78
|
+
Chef::Config[:log_level] ||= :warn
|
79
|
+
# If log_level is auto, change it to warn
|
80
|
+
Chef::Config[:log_level] = :warn if Chef::Config[:log_level] == :auto
|
81
|
+
Chef::Log.init(STDERR)
|
82
|
+
Mixlib::Authentication::Log.logger = Ohai::Log.logger = Chef::Log.logger
|
83
|
+
Chef::Log.level = Chef::Config[:log_level] || :warn
|
84
|
+
end
|
85
|
+
|
86
|
+
# Shell assumes it's running whenever it is defined
|
87
|
+
def self.running?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Set the irb_conf object to something other than IRB.conf
|
92
|
+
# usful for testing.
|
93
|
+
def self.irb_conf=(conf_hash)
|
94
|
+
@irb_conf = conf_hash
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.irb_conf
|
98
|
+
@irb_conf || IRB.conf
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.configure_irb
|
102
|
+
irb_conf[:HISTORY_FILE] = "~/.chef/chef_shell_history"
|
103
|
+
irb_conf[:SAVE_HISTORY] = 1000
|
104
|
+
|
105
|
+
irb_conf[:IRB_RC] = lambda do |conf|
|
106
|
+
m = conf.main
|
107
|
+
|
108
|
+
conf.prompt_c = "chef#{leader(m)} > "
|
109
|
+
conf.return_format = " => %s \n"
|
110
|
+
conf.prompt_i = "chef#{leader(m)} > "
|
111
|
+
conf.prompt_n = "chef#{leader(m)} ?> "
|
112
|
+
conf.prompt_s = "chef#{leader(m)}%l> "
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.leader(main_object)
|
117
|
+
env_string = Shell.env ? " (#{Shell.env})" : ""
|
118
|
+
LEADERS[main_object.class] + env_string
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.session
|
122
|
+
unless client_type.instance.node_built?
|
123
|
+
puts "Session type: #{client_type.session_type}"
|
124
|
+
client_type.instance.reset!
|
125
|
+
end
|
126
|
+
client_type.instance
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.init(main)
|
130
|
+
parse_json
|
131
|
+
configure_irb
|
132
|
+
|
133
|
+
session # trigger ohai run + session load
|
134
|
+
|
135
|
+
session.node.consume_attributes(@json_attribs)
|
136
|
+
|
137
|
+
Extensions.extend_context_object(main)
|
138
|
+
|
139
|
+
main.version
|
140
|
+
puts
|
141
|
+
|
142
|
+
puts "run `help' for help, `exit' or ^D to quit."
|
143
|
+
puts
|
144
|
+
puts "Ohai2u#{greeting}!"
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.greeting
|
148
|
+
" #{Etc.getlogin}@#{Shell.session.node.fqdn}"
|
149
|
+
rescue NameError, ArgumentError
|
150
|
+
""
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.parse_json
|
154
|
+
# HACK: copied verbatim from chef/application/client, because it's not
|
155
|
+
# reusable as written there :(
|
156
|
+
if Chef::Config[:json_attribs]
|
157
|
+
begin
|
158
|
+
json_io = open(Chef::Config[:json_attribs])
|
159
|
+
rescue SocketError => error
|
160
|
+
fatal!("I cannot connect to #{Chef::Config[:json_attribs]}", 2)
|
161
|
+
rescue Errno::ENOENT => error
|
162
|
+
fatal!("I cannot find #{Chef::Config[:json_attribs]}", 2)
|
163
|
+
rescue Errno::EACCES => error
|
164
|
+
fatal!("Permissions are incorrect on #{Chef::Config[:json_attribs]}. Please chmod a+r #{Chef::Config[:json_attribs]}", 2)
|
165
|
+
rescue Exception => error
|
166
|
+
fatal!("Got an unexpected error reading #{Chef::Config[:json_attribs]}: #{error.message}", 2)
|
167
|
+
end
|
168
|
+
|
169
|
+
begin
|
170
|
+
@json_attribs = Chef::JSONCompat.from_json(json_io.read)
|
171
|
+
rescue JSON::ParserError => error
|
172
|
+
fatal!("Could not parse the provided JSON file (#{Chef::Config[:json_attribs]})!: " + error.message, 2)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def self.fatal!(message, exit_status)
|
178
|
+
Chef::Log.fatal(message)
|
179
|
+
exit exit_status
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.client_type
|
183
|
+
type = Shell::StandAloneSession
|
184
|
+
type = Shell::SoloSession if Chef::Config[:shell_solo]
|
185
|
+
type = Shell::ClientSession if Chef::Config[:client]
|
186
|
+
type = Shell::DoppelGangerSession if Chef::Config[:doppelganger]
|
187
|
+
type
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.parse_opts
|
191
|
+
@options = Options.new
|
192
|
+
@options.parse_opts
|
193
|
+
end
|
194
|
+
|
195
|
+
def self.editor
|
196
|
+
@editor || Chef::Config[:editor] || ENV['EDITOR']
|
197
|
+
end
|
198
|
+
|
199
|
+
class Options
|
200
|
+
include Mixlib::CLI
|
201
|
+
|
202
|
+
def self.footer(text=nil)
|
203
|
+
@footer = text if text
|
204
|
+
@footer
|
205
|
+
end
|
206
|
+
|
207
|
+
banner("chef-shell #{Chef::VERSION}\n\nUsage: chef-shell [NAMED_CONF] (OPTIONS)")
|
208
|
+
|
209
|
+
footer(<<-FOOTER)
|
210
|
+
When no CONFIG is specified, chef-shell attempts to load a default configuration file:
|
211
|
+
* If a NAMED_CONF is given, chef-shell will load ~/.chef/NAMED_CONF/chef_shell.rb
|
212
|
+
* If no NAMED_CONF is given chef-shell will load ~/.chef/chef_shell.rb if it exists
|
213
|
+
* chef-shell falls back to loading /etc/chef/client.rb or /etc/chef/solo.rb if -z or
|
214
|
+
-s options are given and no chef_shell.rb can be found.
|
215
|
+
FOOTER
|
216
|
+
|
217
|
+
option :config_file,
|
218
|
+
:short => "-c CONFIG",
|
219
|
+
:long => "--config CONFIG",
|
220
|
+
:description => "The configuration file to use"
|
221
|
+
|
222
|
+
option :help,
|
223
|
+
:short => "-h",
|
224
|
+
:long => "--help",
|
225
|
+
:description => "Show this message",
|
226
|
+
:on => :tail,
|
227
|
+
:boolean => true,
|
228
|
+
:proc => proc { print_help }
|
229
|
+
|
230
|
+
option :log_level,
|
231
|
+
:short => "-l LOG_LEVEL",
|
232
|
+
:long => '--log-level LOG_LEVEL',
|
233
|
+
:description => "Set the logging level",
|
234
|
+
:proc => proc { |level| Chef::Config.log_level = level.to_sym; Shell.setup_logger }
|
235
|
+
|
236
|
+
option :standalone,
|
237
|
+
:short => "-a",
|
238
|
+
:long => "--standalone",
|
239
|
+
:description => "standalone session",
|
240
|
+
:default => true,
|
241
|
+
:boolean => true
|
242
|
+
|
243
|
+
option :shell_solo,
|
244
|
+
:short => "-s",
|
245
|
+
:long => "--solo",
|
246
|
+
:description => "chef-solo session",
|
247
|
+
:boolean => true,
|
248
|
+
:proc => proc {Chef::Config[:solo] = true}
|
249
|
+
|
250
|
+
option :client,
|
251
|
+
:short => "-z",
|
252
|
+
:long => "--client",
|
253
|
+
:description => "chef-client session",
|
254
|
+
:boolean => true
|
255
|
+
|
256
|
+
option :json_attribs,
|
257
|
+
:short => "-j JSON_ATTRIBS",
|
258
|
+
:long => "--json-attributes JSON_ATTRIBS",
|
259
|
+
:description => "Load attributes from a JSON file or URL",
|
260
|
+
:proc => nil
|
261
|
+
|
262
|
+
option :chef_server_url,
|
263
|
+
:short => "-S CHEFSERVERURL",
|
264
|
+
:long => "--server CHEFSERVERURL",
|
265
|
+
:description => "The chef server URL",
|
266
|
+
:proc => nil
|
267
|
+
|
268
|
+
option :version,
|
269
|
+
:short => "-v",
|
270
|
+
:long => "--version",
|
271
|
+
:description => "Show chef version",
|
272
|
+
:boolean => true,
|
273
|
+
:proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
|
274
|
+
:exit => 0
|
275
|
+
|
276
|
+
def self.print_help
|
277
|
+
instance = new
|
278
|
+
instance.parse_options([])
|
279
|
+
puts instance.opt_parser
|
280
|
+
puts
|
281
|
+
puts footer
|
282
|
+
puts
|
283
|
+
exit 1
|
284
|
+
end
|
285
|
+
|
286
|
+
def self.setup!
|
287
|
+
self.new.parse_opts
|
288
|
+
end
|
289
|
+
|
290
|
+
def parse_opts
|
291
|
+
remainder = parse_options
|
292
|
+
environment = remainder.first
|
293
|
+
# We have to nuke ARGV to make sure irb's option parser never sees it.
|
294
|
+
# otherwise, IRB complains about command line switches it doesn't recognize.
|
295
|
+
ARGV.clear
|
296
|
+
config[:config_file] = config_file_for_shell_mode(environment)
|
297
|
+
config_msg = config[:config_file] || "none (standalone session)"
|
298
|
+
puts "loading configuration: #{config_msg}"
|
299
|
+
Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exists?(config[:config_file]) && File.readable?(config[:config_file])
|
300
|
+
Chef::Config.merge!(config)
|
301
|
+
end
|
302
|
+
|
303
|
+
private
|
304
|
+
|
305
|
+
def config_file_for_shell_mode(environment)
|
306
|
+
if config[:config_file]
|
307
|
+
config[:config_file]
|
308
|
+
elsif environment && ENV['HOME']
|
309
|
+
Shell.env = environment
|
310
|
+
config_file_to_try = ::File.join(ENV['HOME'], '.chef', environment, 'chef_shell.rb')
|
311
|
+
unless ::File.exist?(config_file_to_try)
|
312
|
+
puts "could not find chef-shell config for environment #{environment} at #{config_file_to_try}"
|
313
|
+
exit 1
|
314
|
+
end
|
315
|
+
config_file_to_try
|
316
|
+
elsif ENV['HOME'] && ::File.exist?(File.join(ENV['HOME'], '.chef', 'chef_shell.rb'))
|
317
|
+
File.join(ENV['HOME'], '.chef', 'chef_shell.rb')
|
318
|
+
elsif config[:solo]
|
319
|
+
"/etc/chef/solo.rb"
|
320
|
+
elsif config[:client]
|
321
|
+
"/etc/chef/client.rb"
|
322
|
+
else
|
323
|
+
nil
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
end
|
328
|
+
|
329
|
+
end
|
@@ -0,0 +1,593 @@
|
|
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 'tempfile'
|
20
|
+
require 'chef/recipe'
|
21
|
+
require 'fileutils'
|
22
|
+
require 'chef/dsl/platform_introspection'
|
23
|
+
require 'chef/version'
|
24
|
+
require 'chef/shell/shell_session'
|
25
|
+
require 'chef/shell/model_wrapper'
|
26
|
+
require 'chef/shell/shell_rest'
|
27
|
+
require 'chef/json_compat'
|
28
|
+
|
29
|
+
module Shell
|
30
|
+
module Extensions
|
31
|
+
|
32
|
+
Help = Struct.new(:cmd, :desc, :explanation)
|
33
|
+
|
34
|
+
# Extensions to be included in every 'main' object in chef-shell.
|
35
|
+
# These objects are extended with this module.
|
36
|
+
module ObjectCoreExtensions
|
37
|
+
|
38
|
+
def ensure_session_select_defined
|
39
|
+
# irb breaks if you prematurely define IRB::JobMangager
|
40
|
+
# so these methods need to be defined at the latest possible time.
|
41
|
+
unless jobs.respond_to?(:select_session_by_context)
|
42
|
+
def jobs.select_session_by_context(&block)
|
43
|
+
@jobs.select { |job| block.call(job[1].context.main)}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
unless jobs.respond_to?(:session_select)
|
48
|
+
def jobs.select_shell_session(target_context)
|
49
|
+
session = if target_context.kind_of?(Class)
|
50
|
+
select_session_by_context { |main| main.kind_of?(target_context) }
|
51
|
+
else
|
52
|
+
select_session_by_context { |main| main.equal?(target_context) }
|
53
|
+
end
|
54
|
+
Array(session.first)[1]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_or_create_session_for(context_obj)
|
60
|
+
ensure_session_select_defined
|
61
|
+
if subsession = jobs.select_shell_session(context_obj)
|
62
|
+
jobs.switch(subsession)
|
63
|
+
else
|
64
|
+
irb(context_obj)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def help_banner
|
69
|
+
banner = []
|
70
|
+
banner << ""
|
71
|
+
banner << "chef-shell Help"
|
72
|
+
banner << "".ljust(80, "=")
|
73
|
+
banner << "| " + "Command".ljust(25) + "| " + "Description"
|
74
|
+
banner << "".ljust(80, "=")
|
75
|
+
|
76
|
+
self.all_help_descriptions.each do |help_text|
|
77
|
+
banner << "| " + help_text.cmd.ljust(25) + "| " + help_text.desc
|
78
|
+
end
|
79
|
+
banner << "".ljust(80, "=")
|
80
|
+
banner << "\n"
|
81
|
+
banner << "Use help(:command) to get detailed help with individual commands"
|
82
|
+
banner << "\n"
|
83
|
+
banner.join("\n")
|
84
|
+
end
|
85
|
+
|
86
|
+
def explain_command(method_name)
|
87
|
+
help = self.all_help_descriptions.find { |h| h.cmd.to_s == method_name.to_s }
|
88
|
+
if help
|
89
|
+
puts ""
|
90
|
+
puts "Command: #{method_name}"
|
91
|
+
puts "".ljust(80, "=")
|
92
|
+
puts help.explanation || help.desc
|
93
|
+
puts "".ljust(80, "=")
|
94
|
+
puts ""
|
95
|
+
else
|
96
|
+
puts ""
|
97
|
+
puts "command #{method_name} not found or no help available"
|
98
|
+
puts ""
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# helpfully returns +:on+ so we can have sugary syntax like `tracing on'
|
103
|
+
def on
|
104
|
+
:on
|
105
|
+
end
|
106
|
+
|
107
|
+
# returns +:off+ so you can just do `tracing off'
|
108
|
+
def off
|
109
|
+
:off
|
110
|
+
end
|
111
|
+
|
112
|
+
def help_descriptions
|
113
|
+
@help_descriptions ||= []
|
114
|
+
end
|
115
|
+
|
116
|
+
def all_help_descriptions
|
117
|
+
help_descriptions
|
118
|
+
end
|
119
|
+
|
120
|
+
def desc(help_text)
|
121
|
+
@desc = help_text
|
122
|
+
end
|
123
|
+
|
124
|
+
def explain(explain_text)
|
125
|
+
@explain = explain_text
|
126
|
+
end
|
127
|
+
|
128
|
+
def subcommands(subcommand_help={})
|
129
|
+
@subcommand_help = subcommand_help
|
130
|
+
end
|
131
|
+
|
132
|
+
def singleton_method_added(mname)
|
133
|
+
if @desc
|
134
|
+
help_descriptions << Help.new(mname.to_s, @desc.to_s, @explain)
|
135
|
+
@desc, @explain = nil, nil
|
136
|
+
end
|
137
|
+
if @subcommand_help
|
138
|
+
@subcommand_help.each do |subcommand, text|
|
139
|
+
help_descriptions << Help.new("#{mname}.#{subcommand}", text.to_s, nil)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
@subcommand_help = {}
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
module String
|
148
|
+
def on_off_to_bool
|
149
|
+
case self
|
150
|
+
when "on"
|
151
|
+
true
|
152
|
+
when "off"
|
153
|
+
false
|
154
|
+
else
|
155
|
+
self
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
module Symbol
|
161
|
+
def on_off_to_bool
|
162
|
+
self.to_s.on_off_to_bool
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
module TrueClass
|
167
|
+
def to_on_off_str
|
168
|
+
"on"
|
169
|
+
end
|
170
|
+
|
171
|
+
def on_off_to_bool
|
172
|
+
self
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
module FalseClass
|
177
|
+
def to_on_off_str
|
178
|
+
"off"
|
179
|
+
end
|
180
|
+
|
181
|
+
def on_off_to_bool
|
182
|
+
self
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# Methods that have associated help text need to be dynamically added
|
187
|
+
# to the main irb objects, so we define them in a proc and later
|
188
|
+
# instance_eval the proc in the object.
|
189
|
+
ObjectUIExtensions = Proc.new do
|
190
|
+
extend Shell::Extensions::ObjectCoreExtensions
|
191
|
+
|
192
|
+
desc "prints this help message"
|
193
|
+
explain(<<-E)
|
194
|
+
## SUMMARY ##
|
195
|
+
When called with no argument, +help+ prints a table of all
|
196
|
+
chef-shell commands. When called with an argument COMMAND, +help+
|
197
|
+
prints a detailed explanation of the command if available, or the
|
198
|
+
description if no explanation is available.
|
199
|
+
E
|
200
|
+
def help(commmand=nil)
|
201
|
+
if commmand
|
202
|
+
explain_command(commmand)
|
203
|
+
else
|
204
|
+
puts help_banner
|
205
|
+
end
|
206
|
+
:ucanhaz_halp
|
207
|
+
end
|
208
|
+
alias :halp :help
|
209
|
+
|
210
|
+
desc "prints information about chef"
|
211
|
+
def version
|
212
|
+
puts "This is the chef-shell.\n" +
|
213
|
+
" Chef Version: #{::Chef::VERSION}\n" +
|
214
|
+
" http://www.opscode.com/chef\n" +
|
215
|
+
" http://wiki.opscode.com/display/chef/Home"
|
216
|
+
:ucanhaz_automation
|
217
|
+
end
|
218
|
+
alias :shell :version
|
219
|
+
|
220
|
+
desc "switch to recipe mode"
|
221
|
+
def recipe_mode
|
222
|
+
find_or_create_session_for Shell.session.recipe
|
223
|
+
:recipe
|
224
|
+
end
|
225
|
+
|
226
|
+
desc "switch to attributes mode"
|
227
|
+
def attributes_mode
|
228
|
+
find_or_create_session_for Shell.session.node
|
229
|
+
:attributes
|
230
|
+
end
|
231
|
+
|
232
|
+
desc "run chef using the current recipe"
|
233
|
+
def run_chef
|
234
|
+
Chef::Log.level = :debug
|
235
|
+
session = Shell.session
|
236
|
+
runrun = Chef::Runner.new(session.run_context).converge
|
237
|
+
Chef::Log.level = :info
|
238
|
+
runrun
|
239
|
+
end
|
240
|
+
|
241
|
+
desc "returns an object to control a paused chef run"
|
242
|
+
subcommands :resume => "resume the chef run",
|
243
|
+
:step => "run only the next resource",
|
244
|
+
:skip_back => "move back in the run list",
|
245
|
+
:skip_forward => "move forward in the run list"
|
246
|
+
def chef_run
|
247
|
+
Shell.session.resource_collection.iterator
|
248
|
+
end
|
249
|
+
|
250
|
+
desc "resets the current recipe"
|
251
|
+
def reset
|
252
|
+
Shell.session.reset!
|
253
|
+
end
|
254
|
+
|
255
|
+
desc "assume the identity of another node."
|
256
|
+
def become_node(node_name)
|
257
|
+
Shell::DoppelGangerSession.instance.assume_identity(node_name)
|
258
|
+
:doppelganger
|
259
|
+
end
|
260
|
+
alias :doppelganger :become_node
|
261
|
+
|
262
|
+
desc "turns printout of return values on or off"
|
263
|
+
def echo(on_or_off)
|
264
|
+
conf.echo = on_or_off.on_off_to_bool
|
265
|
+
end
|
266
|
+
|
267
|
+
desc "says if echo is on or off"
|
268
|
+
def echo?
|
269
|
+
puts "echo is #{conf.echo.to_on_off_str}"
|
270
|
+
end
|
271
|
+
|
272
|
+
desc "turns on or off tracing of execution. *verbose*"
|
273
|
+
def tracing(on_or_off)
|
274
|
+
conf.use_tracer = on_or_off.on_off_to_bool
|
275
|
+
tracing?
|
276
|
+
end
|
277
|
+
alias :trace :tracing
|
278
|
+
|
279
|
+
desc "says if tracing is on or off"
|
280
|
+
def tracing?
|
281
|
+
puts "tracing is #{conf.use_tracer.to_on_off_str}"
|
282
|
+
end
|
283
|
+
alias :trace? :tracing?
|
284
|
+
|
285
|
+
desc "simple ls style command"
|
286
|
+
def ls(directory)
|
287
|
+
Dir.entries(directory)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
MainContextExtensions = Proc.new do
|
292
|
+
desc "returns the current node (i.e., this host)"
|
293
|
+
def node
|
294
|
+
Shell.session.node
|
295
|
+
end
|
296
|
+
|
297
|
+
desc "pretty print the node's attributes"
|
298
|
+
def ohai(key=nil)
|
299
|
+
pp(key ? node.attribute[key] : node.attribute)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
RESTApiExtensions = Proc.new do
|
304
|
+
desc "edit an object in your EDITOR"
|
305
|
+
explain(<<-E)
|
306
|
+
## SUMMARY ##
|
307
|
+
+edit(object)+ allows you to edit any object that can be converted to JSON.
|
308
|
+
When finished editing, this method will return the edited object:
|
309
|
+
|
310
|
+
new_node = edit(existing_node)
|
311
|
+
|
312
|
+
## EDITOR SELECTION ##
|
313
|
+
chef-shell looks for an editor using the following logic
|
314
|
+
1. Looks for an EDITOR set by Shell.editor = "EDITOR"
|
315
|
+
2. Looks for an EDITOR configured in your chef-shell config file
|
316
|
+
3. Uses the value of the EDITOR environment variable
|
317
|
+
E
|
318
|
+
def edit(object)
|
319
|
+
unless Shell.editor
|
320
|
+
puts "Please set your editor with Shell.editor = \"vim|emacs|mate|ed\""
|
321
|
+
return :failburger
|
322
|
+
end
|
323
|
+
|
324
|
+
filename = "chef-shell-edit-#{object.class.name}-"
|
325
|
+
if object.respond_to?(:name)
|
326
|
+
filename += object.name
|
327
|
+
elsif object.respond_to?(:id)
|
328
|
+
filename += object.id
|
329
|
+
end
|
330
|
+
|
331
|
+
edited_data = Tempfile.open([filename, ".js"]) do |tempfile|
|
332
|
+
tempfile.sync = true
|
333
|
+
tempfile.puts Chef::JSONCompat.to_json(object)
|
334
|
+
system("#{Shell.editor.to_s} #{tempfile.path}")
|
335
|
+
tempfile.rewind
|
336
|
+
tempfile.read
|
337
|
+
end
|
338
|
+
|
339
|
+
Chef::JSONCompat.from_json(edited_data)
|
340
|
+
end
|
341
|
+
|
342
|
+
desc "Find and edit API clients"
|
343
|
+
explain(<<-E)
|
344
|
+
## SUMMARY ##
|
345
|
+
+clients+ allows you to query you chef server for information about your api
|
346
|
+
clients.
|
347
|
+
|
348
|
+
## LIST ALL CLIENTS ##
|
349
|
+
To see all clients on the system, use
|
350
|
+
|
351
|
+
clients.all #=> [<Chef::ApiClient...>, ...]
|
352
|
+
|
353
|
+
If the output from all is too verbose, or you're only interested in a specific
|
354
|
+
value from each of the objects, you can give a code block to +all+:
|
355
|
+
|
356
|
+
clients.all { |client| client.name } #=> [CLIENT1_NAME, CLIENT2_NAME, ...]
|
357
|
+
|
358
|
+
## SHOW ONE CLIENT ##
|
359
|
+
To see a specific client, use
|
360
|
+
|
361
|
+
clients.show(CLIENT_NAME)
|
362
|
+
|
363
|
+
## SEARCH FOR CLIENTS ##
|
364
|
+
You can also search for clients using +find+ or +search+. You can use the
|
365
|
+
familiar string search syntax:
|
366
|
+
|
367
|
+
clients.search("KEY:VALUE")
|
368
|
+
|
369
|
+
Just as the +all+ subcommand, the +search+ subcommand can use a code block to
|
370
|
+
filter or transform the information returned from the search:
|
371
|
+
|
372
|
+
clients.search("KEY:VALUE") { |c| c.name }
|
373
|
+
|
374
|
+
You can also use a Hash based syntax, multiple search conditions will be
|
375
|
+
joined with AND.
|
376
|
+
|
377
|
+
clients.find :KEY => :VALUE, :KEY2 => :VALUE2, ...
|
378
|
+
|
379
|
+
## BULK-EDIT CLIENTS ##
|
380
|
+
**BE CAREFUL, THIS IS DESTRUCTIVE**
|
381
|
+
You can bulk edit API Clients using the +transform+ subcommand, which requires
|
382
|
+
a code block. Each client will be saved after the code block is run. If the
|
383
|
+
code block returns +nil+ or +false+, that client will be skipped:
|
384
|
+
|
385
|
+
clients.transform("*:*") do |client|
|
386
|
+
if client.name =~ /borat/i
|
387
|
+
client.admin(false)
|
388
|
+
true
|
389
|
+
else
|
390
|
+
nil
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
This will strip the admin privileges from any client named after borat.
|
395
|
+
E
|
396
|
+
subcommands :all => "list all api clients",
|
397
|
+
:show => "load an api client by name",
|
398
|
+
:search => "search for API clients",
|
399
|
+
:transform => "edit all api clients via a code block and save them"
|
400
|
+
def clients
|
401
|
+
@clients ||= Shell::ModelWrapper.new(Chef::ApiClient, :client)
|
402
|
+
end
|
403
|
+
|
404
|
+
desc "Find and edit cookbooks"
|
405
|
+
subcommands :all => "list all cookbooks",
|
406
|
+
:show => "load a cookbook by name",
|
407
|
+
:transform => "edit all cookbooks via a code block and save them"
|
408
|
+
def cookbooks
|
409
|
+
@cookbooks ||= Shell::ModelWrapper.new(Chef::CookbookVersion)
|
410
|
+
end
|
411
|
+
|
412
|
+
desc "Find and edit nodes via the API"
|
413
|
+
explain(<<-E)
|
414
|
+
## SUMMARY ##
|
415
|
+
+nodes+ Allows you to query your chef server for information about your nodes.
|
416
|
+
|
417
|
+
## LIST ALL NODES ##
|
418
|
+
You can list all nodes using +all+ or +list+
|
419
|
+
|
420
|
+
nodes.all #=> [<Chef::Node...>, <Chef::Node...>, ...]
|
421
|
+
|
422
|
+
To limit the information returned for each node, pass a code block to the +all+
|
423
|
+
subcommand:
|
424
|
+
|
425
|
+
nodes.all { |node| node.name } #=> [NODE1_NAME, NODE2_NAME, ...]
|
426
|
+
|
427
|
+
## SHOW ONE NODE ##
|
428
|
+
You can show the data for a single node using the +show+ subcommand:
|
429
|
+
|
430
|
+
nodes.show("NODE_NAME") => <Chef::Node @name="NODE_NAME" ...>
|
431
|
+
|
432
|
+
## SEARCH FOR NODES ##
|
433
|
+
You can search for nodes using the +search+ or +find+ subcommands:
|
434
|
+
|
435
|
+
nodes.find(:name => "app*") #=> [<Chef::Node @name="app1.example.com" ...>, ...]
|
436
|
+
|
437
|
+
Similarly to +all+, you can pass a code block to limit or transform the
|
438
|
+
information returned:
|
439
|
+
|
440
|
+
nodes.find(:name => "app#") { |node| node.ec2 }
|
441
|
+
|
442
|
+
## BULK EDIT NODES ##
|
443
|
+
**BE CAREFUL, THIS OPERATION IS DESTRUCTIVE**
|
444
|
+
|
445
|
+
Bulk edit nodes by passing a code block to the +transform+ or +bulk_edit+
|
446
|
+
subcommand. The block will be applied to each matching node, and then the node
|
447
|
+
will be saved. If the block returns +nil+ or +false+, that node will be
|
448
|
+
skipped.
|
449
|
+
|
450
|
+
nodes.transform do |node|
|
451
|
+
if node.fqdn =~ /.*\\.preprod\\.example\\.com/
|
452
|
+
node.set[:environment] = "preprod"
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
This will assign the attribute to every node with a FQDN matching the regex.
|
457
|
+
E
|
458
|
+
subcommands :all => "list all nodes",
|
459
|
+
:show => "load a node by name",
|
460
|
+
:search => "search for nodes",
|
461
|
+
:transform => "edit all nodes via a code block and save them"
|
462
|
+
def nodes
|
463
|
+
@nodes ||= Shell::ModelWrapper.new(Chef::Node)
|
464
|
+
end
|
465
|
+
|
466
|
+
desc "Find and edit roles via the API"
|
467
|
+
explain(<<-E)
|
468
|
+
## SUMMARY ##
|
469
|
+
+roles+ allows you to query and edit roles on your Chef server.
|
470
|
+
|
471
|
+
## SUBCOMMANDS ##
|
472
|
+
* all (list)
|
473
|
+
* show (load)
|
474
|
+
* search (find)
|
475
|
+
* transform (bulk_edit)
|
476
|
+
|
477
|
+
## SEE ALSO ##
|
478
|
+
See the help for +nodes+ for more information about the subcommands.
|
479
|
+
E
|
480
|
+
subcommands :all => "list all roles",
|
481
|
+
:show => "load a role by name",
|
482
|
+
:search => "search for roles",
|
483
|
+
:transform => "edit all roles via a code block and save them"
|
484
|
+
def roles
|
485
|
+
@roles ||= Shell::ModelWrapper.new(Chef::Role)
|
486
|
+
end
|
487
|
+
|
488
|
+
desc "Find and edit +databag_name+ via the api"
|
489
|
+
explain(<<-E)
|
490
|
+
## SUMMARY ##
|
491
|
+
+databags(DATABAG_NAME)+ allows you to query and edit data bag items on your
|
492
|
+
Chef server. Unlike other commands for working with data on the server,
|
493
|
+
+databags+ requires the databag name as an argument, for example:
|
494
|
+
databags(:users).all
|
495
|
+
|
496
|
+
## SUBCOMMANDS ##
|
497
|
+
* all (list)
|
498
|
+
* show (load)
|
499
|
+
* search (find)
|
500
|
+
* transform (bulk_edit)
|
501
|
+
|
502
|
+
## SEE ALSO ##
|
503
|
+
See the help for +nodes+ for more information about the subcommands.
|
504
|
+
|
505
|
+
E
|
506
|
+
subcommands :all => "list all items in the data bag",
|
507
|
+
:show => "load a data bag item by id",
|
508
|
+
:search => "search for items in the data bag",
|
509
|
+
:transform => "edit all items via a code block and save them"
|
510
|
+
def databags(databag_name)
|
511
|
+
@named_databags_wrappers ||= {}
|
512
|
+
@named_databags_wrappers[databag_name] ||= Shell::NamedDataBagWrapper.new(databag_name)
|
513
|
+
end
|
514
|
+
|
515
|
+
desc "Find and edit environments via the API"
|
516
|
+
explain(<<-E)
|
517
|
+
## SUMMARY ##
|
518
|
+
+environments+ allows you to query and edit environments on your Chef server.
|
519
|
+
|
520
|
+
## SUBCOMMANDS ##
|
521
|
+
* all (list)
|
522
|
+
* show (load)
|
523
|
+
* search (find)
|
524
|
+
* transform (bulk_edit)
|
525
|
+
|
526
|
+
## SEE ALSO ##
|
527
|
+
See the help for +nodes+ for more information about the subcommands.
|
528
|
+
E
|
529
|
+
subcommands :all => "list all environments",
|
530
|
+
:show => "load an environment by name",
|
531
|
+
:search => "search for environments",
|
532
|
+
:transform => "edit all environments via a code block and save them"
|
533
|
+
def environments
|
534
|
+
@environments ||= Shell::ModelWrapper.new(Chef::Environment)
|
535
|
+
end
|
536
|
+
|
537
|
+
desc "A REST Client configured to authenticate with the API"
|
538
|
+
def api
|
539
|
+
@rest = Shell::ShellREST.new(Chef::Config[:chef_server_url])
|
540
|
+
end
|
541
|
+
|
542
|
+
end
|
543
|
+
|
544
|
+
RecipeUIExtensions = Proc.new do
|
545
|
+
alias :original_resources :resources
|
546
|
+
|
547
|
+
desc "list all the resources on the current recipe"
|
548
|
+
def resources(*args)
|
549
|
+
if args.empty?
|
550
|
+
pp run_context.resource_collection.instance_variable_get(:@resources_by_name).keys
|
551
|
+
else
|
552
|
+
pp resources = original_resources(*args)
|
553
|
+
resources
|
554
|
+
end
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
def self.extend_context_object(obj)
|
559
|
+
obj.instance_eval(&ObjectUIExtensions)
|
560
|
+
obj.instance_eval(&MainContextExtensions)
|
561
|
+
obj.instance_eval(&RESTApiExtensions)
|
562
|
+
obj.extend(FileUtils)
|
563
|
+
obj.extend(Chef::DSL::PlatformIntrospection)
|
564
|
+
obj.extend(Chef::DSL::DataQuery)
|
565
|
+
end
|
566
|
+
|
567
|
+
def self.extend_context_node(node_obj)
|
568
|
+
node_obj.instance_eval(&ObjectUIExtensions)
|
569
|
+
end
|
570
|
+
|
571
|
+
def self.extend_context_recipe(recipe_obj)
|
572
|
+
recipe_obj.instance_eval(&ObjectUIExtensions)
|
573
|
+
recipe_obj.instance_eval(&RecipeUIExtensions)
|
574
|
+
end
|
575
|
+
|
576
|
+
end
|
577
|
+
end
|
578
|
+
|
579
|
+
class String
|
580
|
+
include Shell::Extensions::String
|
581
|
+
end
|
582
|
+
|
583
|
+
class Symbol
|
584
|
+
include Shell::Extensions::Symbol
|
585
|
+
end
|
586
|
+
|
587
|
+
class TrueClass
|
588
|
+
include Shell::Extensions::TrueClass
|
589
|
+
end
|
590
|
+
|
591
|
+
class FalseClass
|
592
|
+
include Shell::Extensions::FalseClass
|
593
|
+
end
|