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
data/lib/chef/recipe.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
#--
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008, 2009 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
|
21
|
+
require 'chef/dsl/recipe'
|
22
|
+
require 'chef/dsl/data_query'
|
23
|
+
require 'chef/dsl/platform_introspection'
|
24
|
+
require 'chef/dsl/include_recipe'
|
25
|
+
require 'chef/dsl/registry_helper'
|
26
|
+
|
27
|
+
require 'chef/mixin/from_file'
|
28
|
+
|
29
|
+
require 'chef/mixin/deprecation'
|
30
|
+
|
31
|
+
class Chef
|
32
|
+
# == Chef::Recipe
|
33
|
+
# A Recipe object is the context in which Chef recipes are evaluated.
|
34
|
+
class Recipe
|
35
|
+
|
36
|
+
include Chef::DSL::DataQuery
|
37
|
+
include Chef::DSL::PlatformIntrospection
|
38
|
+
include Chef::DSL::IncludeRecipe
|
39
|
+
include Chef::DSL::Recipe
|
40
|
+
include Chef::DSL::RegistryHelper
|
41
|
+
|
42
|
+
include Chef::Mixin::FromFile
|
43
|
+
include Chef::Mixin::Deprecation
|
44
|
+
|
45
|
+
attr_accessor :cookbook_name, :recipe_name, :recipe, :params, :run_context
|
46
|
+
|
47
|
+
# Parses a potentially fully-qualified recipe name into its
|
48
|
+
# cookbook name and recipe short name.
|
49
|
+
#
|
50
|
+
# For example:
|
51
|
+
# "aws::elastic_ip" returns [:aws, "elastic_ip"]
|
52
|
+
# "aws" returns [:aws, "default"]
|
53
|
+
#--
|
54
|
+
# TODO: Duplicates functionality of RunListItem
|
55
|
+
def self.parse_recipe_name(recipe_name)
|
56
|
+
rmatch = recipe_name.match(/(.+?)::(.+)/)
|
57
|
+
if rmatch
|
58
|
+
[ rmatch[1].to_sym, rmatch[2] ]
|
59
|
+
else
|
60
|
+
[ recipe_name.to_sym, "default" ]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize(cookbook_name, recipe_name, run_context)
|
65
|
+
@cookbook_name = cookbook_name
|
66
|
+
@recipe_name = recipe_name
|
67
|
+
@run_context = run_context
|
68
|
+
# TODO: 5/19/2010 cw/tim: determine whether this can be removed
|
69
|
+
@params = Hash.new
|
70
|
+
@node = deprecated_ivar(run_context.node, :node, :warn)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Used in DSL mixins
|
74
|
+
def node
|
75
|
+
run_context.node
|
76
|
+
end
|
77
|
+
|
78
|
+
# Used by the DSL to look up resources when executing in the context of a
|
79
|
+
# recipe.
|
80
|
+
def resources(*args)
|
81
|
+
run_context.resource_collection.find(*args)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Sets a tag, or list of tags, for this node. Syntactic sugar for
|
85
|
+
# run_context.node[:tags].
|
86
|
+
#
|
87
|
+
# With no arguments, returns the list of tags.
|
88
|
+
#
|
89
|
+
# === Parameters
|
90
|
+
# tags<Array>:: A list of tags to add - can be a single string
|
91
|
+
#
|
92
|
+
# === Returns
|
93
|
+
# tags<Array>:: The contents of run_context.node[:tags]
|
94
|
+
def tag(*tags)
|
95
|
+
if tags.length > 0
|
96
|
+
tags.each do |tag|
|
97
|
+
tag = tag.to_s
|
98
|
+
run_context.node.normal[:tags] << tag unless run_context.node[:tags].include?(tag)
|
99
|
+
end
|
100
|
+
run_context.node[:tags]
|
101
|
+
else
|
102
|
+
run_context.node[:tags]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Returns true if the node is tagged with *all* of the supplied +tags+.
|
107
|
+
#
|
108
|
+
# === Parameters
|
109
|
+
# tags<Array>:: A list of tags
|
110
|
+
#
|
111
|
+
# === Returns
|
112
|
+
# true<TrueClass>:: If all the parameters are present
|
113
|
+
# false<FalseClass>:: If any of the parameters are missing
|
114
|
+
def tagged?(*tags)
|
115
|
+
tags.each do |tag|
|
116
|
+
return false unless run_context.node[:tags].include?(tag)
|
117
|
+
end
|
118
|
+
true
|
119
|
+
end
|
120
|
+
|
121
|
+
# Removes the list of tags from the node.
|
122
|
+
#
|
123
|
+
# === Parameters
|
124
|
+
# tags<Array>:: A list of tags
|
125
|
+
#
|
126
|
+
# === Returns
|
127
|
+
# tags<Array>:: The current list of run_context.node[:tags]
|
128
|
+
def untag(*tags)
|
129
|
+
tags.each do |tag|
|
130
|
+
run_context.node.normal[:tags].delete(tag)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class Chef
|
2
|
+
|
3
|
+
# This module exists to hide conflicting constant names from the DSL.
|
4
|
+
# Hopefully we'll have a better/prettier/more sustainable solution in the
|
5
|
+
# future, but for now this will fix a regression introduced in Chef 0.10.10
|
6
|
+
# (conflict with the Win32 namespace)
|
7
|
+
module ReservedNames
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,794 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef/mixin/params_validate'
|
21
|
+
require 'chef/dsl/platform_introspection'
|
22
|
+
require 'chef/dsl/data_query'
|
23
|
+
require 'chef/dsl/registry_helper'
|
24
|
+
require 'chef/mixin/convert_to_class_name'
|
25
|
+
require 'chef/resource/conditional'
|
26
|
+
require 'chef/resource_collection'
|
27
|
+
require 'chef/resource_platform_map'
|
28
|
+
require 'chef/node'
|
29
|
+
|
30
|
+
require 'chef/mixin/deprecation'
|
31
|
+
|
32
|
+
class Chef
|
33
|
+
class Resource
|
34
|
+
class Notification < Struct.new(:resource, :action, :notifying_resource)
|
35
|
+
|
36
|
+
def duplicates?(other_notification)
|
37
|
+
unless other_notification.respond_to?(:resource) && other_notification.respond_to?(:action)
|
38
|
+
msg = "only duck-types of Chef::Resource::Notification can be checked for duplication "\
|
39
|
+
"you gave #{other_notification.inspect}"
|
40
|
+
raise ArgumentError, msg
|
41
|
+
end
|
42
|
+
other_notification.resource == resource && other_notification.action == action
|
43
|
+
end
|
44
|
+
|
45
|
+
# If resource and/or notifying_resource is not a resource object, this will look them up in the resource collection
|
46
|
+
# and fix the references from strings to actual Resource objects.
|
47
|
+
def resolve_resource_reference(resource_collection)
|
48
|
+
return resource if resource.kind_of?(Chef::Resource) && notifying_resource.kind_of?(Chef::Resource)
|
49
|
+
|
50
|
+
if not(resource.kind_of?(Chef::Resource))
|
51
|
+
fix_resource_reference(resource_collection)
|
52
|
+
end
|
53
|
+
|
54
|
+
if not(notifying_resource.kind_of?(Chef::Resource))
|
55
|
+
fix_notifier_reference(resource_collection)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# This will look up the resource if it is not a Resource Object. It will complain if it finds multiple
|
60
|
+
# resources, can't find a resource, or gets invalid syntax.
|
61
|
+
def fix_resource_reference(resource_collection)
|
62
|
+
matching_resource = resource_collection.find(resource)
|
63
|
+
if Array(matching_resource).size > 1
|
64
|
+
msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple resources, "\
|
65
|
+
"but can only notify one resource. Notifying resource was defined on #{notifying_resource.source_line}"
|
66
|
+
raise Chef::Exceptions::InvalidResourceReference, msg
|
67
|
+
end
|
68
|
+
self.resource = matching_resource
|
69
|
+
|
70
|
+
rescue Chef::Exceptions::ResourceNotFound => e
|
71
|
+
err = Chef::Exceptions::ResourceNotFound.new(<<-FAIL)
|
72
|
+
resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \
|
73
|
+
but #{resource} cannot be found in the resource collection. #{notifying_resource} is defined in \
|
74
|
+
#{notifying_resource.source_line}
|
75
|
+
FAIL
|
76
|
+
err.set_backtrace(e.backtrace)
|
77
|
+
raise err
|
78
|
+
rescue Chef::Exceptions::InvalidResourceSpecification => e
|
79
|
+
err = Chef::Exceptions::InvalidResourceSpecification.new(<<-F)
|
80
|
+
Resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \
|
81
|
+
but #{resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \
|
82
|
+
is defined near #{notifying_resource.source_line}
|
83
|
+
F
|
84
|
+
err.set_backtrace(e.backtrace)
|
85
|
+
raise err
|
86
|
+
end
|
87
|
+
|
88
|
+
# This will look up the notifying_resource if it is not a Resource Object. It will complain if it finds multiple
|
89
|
+
# resources, can't find a resource, or gets invalid syntax.
|
90
|
+
def fix_notifier_reference(resource_collection)
|
91
|
+
matching_notifier = resource_collection.find(notifying_resource)
|
92
|
+
if Array(matching_notifier).size > 1
|
93
|
+
msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple notifying "\
|
94
|
+
"resources, but can only originate from one resource. Destination resource was defined "\
|
95
|
+
"on #{resource.source_line}"
|
96
|
+
raise Chef::Exceptions::InvalidResourceReference, msg
|
97
|
+
end
|
98
|
+
self.notifying_resource = matching_notifier
|
99
|
+
|
100
|
+
rescue Chef::Exceptions::ResourceNotFound => e
|
101
|
+
err = Chef::Exceptions::ResourceNotFound.new(<<-FAIL)
|
102
|
+
Resource #{resource} is configured to receive notifications from #{notifying_resource} with action #{action}, \
|
103
|
+
but #{notifying_resource} cannot be found in the resource collection. #{resource} is defined in \
|
104
|
+
#{resource.source_line}
|
105
|
+
FAIL
|
106
|
+
err.set_backtrace(e.backtrace)
|
107
|
+
raise err
|
108
|
+
rescue Chef::Exceptions::InvalidResourceSpecification => e
|
109
|
+
err = Chef::Exceptions::InvalidResourceSpecification.new(<<-F)
|
110
|
+
Resource #{resource} is configured to receive notifications from #{notifying_resource} with action #{action}, \
|
111
|
+
but #{notifying_resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \
|
112
|
+
is defined near #{resource.source_line}
|
113
|
+
F
|
114
|
+
err.set_backtrace(e.backtrace)
|
115
|
+
raise err
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
FORBIDDEN_IVARS = [:@run_context, :@node, :@not_if, :@only_if, :@enclosing_provider]
|
121
|
+
HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@node, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider]
|
122
|
+
|
123
|
+
include Chef::DSL::DataQuery
|
124
|
+
include Chef::Mixin::ParamsValidate
|
125
|
+
include Chef::DSL::PlatformIntrospection
|
126
|
+
include Chef::DSL::RegistryHelper
|
127
|
+
include Chef::Mixin::ConvertToClassName
|
128
|
+
include Chef::Mixin::Deprecation
|
129
|
+
|
130
|
+
extend Chef::Mixin::ConvertToClassName
|
131
|
+
|
132
|
+
# Track all subclasses of Resource. This is used so names can be looked up
|
133
|
+
# when attempting to deserialize from JSON. (See: json_compat)
|
134
|
+
def self.resource_classes
|
135
|
+
@resource_classes ||= []
|
136
|
+
end
|
137
|
+
|
138
|
+
# Callback when subclass is defined. Adds subclass to list of subclasses.
|
139
|
+
def self.inherited(subclass)
|
140
|
+
resource_classes << subclass
|
141
|
+
end
|
142
|
+
|
143
|
+
# Look up a subclass by +class_name+ which should be a string that matches
|
144
|
+
# `Subclass.name`
|
145
|
+
def self.find_subclass_by_name(class_name)
|
146
|
+
resource_classes.first {|c| c.name == class_name }
|
147
|
+
end
|
148
|
+
|
149
|
+
# Set or return the list of "state attributes" implemented by the Resource
|
150
|
+
# subclass. State attributes are attributes that describe the desired state
|
151
|
+
# of the system, such as file permissions or ownership. In general, state
|
152
|
+
# attributes are attributes that could be populated by examining the state
|
153
|
+
# of the system (e.g., File.stat can tell you the permissions on an
|
154
|
+
# existing file). Contrarily, attributes that are not "state attributes"
|
155
|
+
# usually modify the way Chef itself behaves, for example by providing
|
156
|
+
# additional options for a package manager to use when installing a
|
157
|
+
# package.
|
158
|
+
#
|
159
|
+
# This list is used by the Chef client auditing system to extract
|
160
|
+
# information from resources to describe changes made to the system.
|
161
|
+
def self.state_attrs(*attr_names)
|
162
|
+
@state_attrs ||= []
|
163
|
+
@state_attrs = attr_names unless attr_names.empty?
|
164
|
+
|
165
|
+
# Return *all* state_attrs that this class has, including inherited ones
|
166
|
+
if superclass.respond_to?(:state_attrs)
|
167
|
+
superclass.state_attrs + @state_attrs
|
168
|
+
else
|
169
|
+
@state_attrs
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# Set or return the "identity attribute" for this resource class. This is
|
174
|
+
# generally going to be the "name attribute" for this resource. In other
|
175
|
+
# words, the resource type plus this attribute uniquely identify a given
|
176
|
+
# bit of state that chef manages. For a File resource, this would be the
|
177
|
+
# path, for a package resource, it will be the package name. This will show
|
178
|
+
# up in chef-client's audit records as a searchable field.
|
179
|
+
def self.identity_attr(attr_name=nil)
|
180
|
+
@identity_attr ||= nil
|
181
|
+
@identity_attr = attr_name if attr_name
|
182
|
+
|
183
|
+
# If this class doesn't have an identity attr, we'll defer to the superclass:
|
184
|
+
if @identity_attr || !superclass.respond_to?(:identity_attr)
|
185
|
+
@identity_attr
|
186
|
+
else
|
187
|
+
superclass.identity_attr
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def self.dsl_name
|
192
|
+
convert_to_snake_case(name, 'Chef::Resource')
|
193
|
+
end
|
194
|
+
|
195
|
+
attr_accessor :params
|
196
|
+
attr_accessor :provider
|
197
|
+
attr_accessor :allowed_actions
|
198
|
+
attr_accessor :run_context
|
199
|
+
attr_accessor :cookbook_name
|
200
|
+
attr_accessor :recipe_name
|
201
|
+
attr_accessor :enclosing_provider
|
202
|
+
attr_accessor :source_line
|
203
|
+
attr_accessor :retries
|
204
|
+
attr_accessor :retry_delay
|
205
|
+
|
206
|
+
attr_reader :updated
|
207
|
+
|
208
|
+
attr_reader :resource_name
|
209
|
+
attr_reader :not_if_args
|
210
|
+
attr_reader :only_if_args
|
211
|
+
|
212
|
+
attr_reader :elapsed_time
|
213
|
+
|
214
|
+
# Each notify entry is a resource/action pair, modeled as an
|
215
|
+
# Struct with a #resource and #action member
|
216
|
+
|
217
|
+
def initialize(name, run_context=nil)
|
218
|
+
@name = name
|
219
|
+
@run_context = run_context
|
220
|
+
@noop = nil
|
221
|
+
@before = nil
|
222
|
+
@params = Hash.new
|
223
|
+
@provider = nil
|
224
|
+
@allowed_actions = [ :nothing ]
|
225
|
+
@action = :nothing
|
226
|
+
@updated = false
|
227
|
+
@updated_by_last_action = false
|
228
|
+
@supports = {}
|
229
|
+
@ignore_failure = false
|
230
|
+
@retries = 0
|
231
|
+
@retry_delay = 2
|
232
|
+
@not_if = []
|
233
|
+
@only_if = []
|
234
|
+
@source_line = nil
|
235
|
+
@elapsed_time = 0
|
236
|
+
|
237
|
+
@node = run_context ? deprecated_ivar(run_context.node, :node, :warn) : nil
|
238
|
+
end
|
239
|
+
|
240
|
+
# Returns a Hash of attribute => value for the state attributes declared in
|
241
|
+
# the resource's class definition.
|
242
|
+
def state
|
243
|
+
self.class.state_attrs.inject({}) do |state_attrs, attr_name|
|
244
|
+
state_attrs[attr_name] = send(attr_name)
|
245
|
+
state_attrs
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# Returns the value of the identity attribute, if declared. Falls back to
|
250
|
+
# #name if no identity attribute is declared.
|
251
|
+
def identity
|
252
|
+
if identity_attr = self.class.identity_attr
|
253
|
+
send(identity_attr)
|
254
|
+
else
|
255
|
+
name
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
def updated=(true_or_false)
|
261
|
+
Chef::Log.warn("Chef::Resource#updated=(true|false) is deprecated. Please call #updated_by_last_action(true|false) instead.")
|
262
|
+
Chef::Log.warn("Called from:")
|
263
|
+
caller[0..3].each {|line| Chef::Log.warn(line)}
|
264
|
+
updated_by_last_action(true_or_false)
|
265
|
+
@updated = true_or_false
|
266
|
+
end
|
267
|
+
|
268
|
+
def node
|
269
|
+
run_context && run_context.node
|
270
|
+
end
|
271
|
+
|
272
|
+
# If an unknown method is invoked, determine whether the enclosing Provider's
|
273
|
+
# lexical scope can fulfill the request. E.g. This happens when the Resource's
|
274
|
+
# block invokes new_resource.
|
275
|
+
def method_missing(method_symbol, *args, &block)
|
276
|
+
if enclosing_provider && enclosing_provider.respond_to?(method_symbol)
|
277
|
+
enclosing_provider.send(method_symbol, *args, &block)
|
278
|
+
else
|
279
|
+
raise NoMethodError, "undefined method `#{method_symbol.to_s}' for #{self.class.to_s}"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def load_prior_resource
|
284
|
+
begin
|
285
|
+
prior_resource = run_context.resource_collection.lookup(self.to_s)
|
286
|
+
# if we get here, there is a prior resource (otherwise we'd have jumped
|
287
|
+
# to the rescue clause).
|
288
|
+
Chef::Log.warn("Cloning resource attributes for #{self.to_s} from prior resource (CHEF-3694)")
|
289
|
+
Chef::Log.warn("Previous #{prior_resource}: #{prior_resource.source_line}") if prior_resource.source_line
|
290
|
+
Chef::Log.warn("Current #{self}: #{self.source_line}") if self.source_line
|
291
|
+
prior_resource.instance_variables.each do |iv|
|
292
|
+
unless iv.to_sym == :@source_line || iv.to_sym == :@action || iv.to_sym == :@not_if || iv.to_sym == :@only_if
|
293
|
+
self.instance_variable_set(iv, prior_resource.instance_variable_get(iv))
|
294
|
+
end
|
295
|
+
end
|
296
|
+
true
|
297
|
+
rescue Chef::Exceptions::ResourceNotFound
|
298
|
+
true
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
def supports(args={})
|
303
|
+
if args.any?
|
304
|
+
@supports = args
|
305
|
+
else
|
306
|
+
@supports
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def provider(arg=nil)
|
311
|
+
klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
|
312
|
+
lookup_provider_constant(arg)
|
313
|
+
else
|
314
|
+
arg
|
315
|
+
end
|
316
|
+
set_or_return(
|
317
|
+
:provider,
|
318
|
+
klass,
|
319
|
+
:kind_of => [ Class ]
|
320
|
+
)
|
321
|
+
end
|
322
|
+
|
323
|
+
def action(arg=nil)
|
324
|
+
if arg
|
325
|
+
action_list = arg.kind_of?(Array) ? arg : [ arg ]
|
326
|
+
action_list = action_list.collect { |a| a.to_sym }
|
327
|
+
action_list.each do |action|
|
328
|
+
validate(
|
329
|
+
{
|
330
|
+
:action => action,
|
331
|
+
},
|
332
|
+
{
|
333
|
+
:action => { :kind_of => Symbol, :equal_to => @allowed_actions },
|
334
|
+
}
|
335
|
+
)
|
336
|
+
end
|
337
|
+
@action = action_list
|
338
|
+
else
|
339
|
+
@action
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
def name(name=nil)
|
344
|
+
if !name.nil?
|
345
|
+
raise ArgumentError, "name must be a string!" unless name.kind_of?(String)
|
346
|
+
@name = name
|
347
|
+
end
|
348
|
+
@name
|
349
|
+
end
|
350
|
+
|
351
|
+
def noop(tf=nil)
|
352
|
+
if !tf.nil?
|
353
|
+
raise ArgumentError, "noop must be true or false!" unless tf == true || tf == false
|
354
|
+
@noop = tf
|
355
|
+
end
|
356
|
+
@noop
|
357
|
+
end
|
358
|
+
|
359
|
+
def ignore_failure(arg=nil)
|
360
|
+
set_or_return(
|
361
|
+
:ignore_failure,
|
362
|
+
arg,
|
363
|
+
:kind_of => [ TrueClass, FalseClass ]
|
364
|
+
)
|
365
|
+
end
|
366
|
+
|
367
|
+
def retries(arg=nil)
|
368
|
+
set_or_return(
|
369
|
+
:retries,
|
370
|
+
arg,
|
371
|
+
:kind_of => Integer
|
372
|
+
)
|
373
|
+
end
|
374
|
+
|
375
|
+
def retry_delay(arg=nil)
|
376
|
+
set_or_return(
|
377
|
+
:retry_delay,
|
378
|
+
arg,
|
379
|
+
:kind_of => Integer
|
380
|
+
)
|
381
|
+
end
|
382
|
+
|
383
|
+
def epic_fail(arg=nil)
|
384
|
+
ignore_failure(arg)
|
385
|
+
end
|
386
|
+
|
387
|
+
# Sets up a notification from this resource to the resource specified by +resource_spec+.
|
388
|
+
def notifies(action, resource_spec, timing=:delayed)
|
389
|
+
# when using old-style resources(:template => "/foo.txt") style, you
|
390
|
+
# could end up with multiple resources.
|
391
|
+
resources = [ resource_spec ].flatten
|
392
|
+
resources.each do |resource|
|
393
|
+
case timing.to_s
|
394
|
+
when 'delayed'
|
395
|
+
notifies_delayed(action, resource)
|
396
|
+
when 'immediate', 'immediately'
|
397
|
+
notifies_immediately(action, resource)
|
398
|
+
else
|
399
|
+
raise ArgumentError, "invalid timing: #{timing} for notifies(#{action}, #{resources.inspect}, #{timing}) resource #{self} "\
|
400
|
+
"Valid timings are: :delayed, :immediate, :immediately"
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
true
|
405
|
+
end
|
406
|
+
|
407
|
+
# Iterates over all immediate and delayed notifications, calling
|
408
|
+
# resolve_resource_reference on each in turn, causing them to
|
409
|
+
# resolve lazy/forward references.
|
410
|
+
def resolve_notification_references
|
411
|
+
run_context.immediate_notifications(self).each { |n| n.resolve_resource_reference(run_context.resource_collection) }
|
412
|
+
run_context.delayed_notifications(self).each {|n| n.resolve_resource_reference(run_context.resource_collection) }
|
413
|
+
end
|
414
|
+
|
415
|
+
def notifies_immediately(action, resource_spec)
|
416
|
+
run_context.notifies_immediately(Notification.new(resource_spec, action, self))
|
417
|
+
end
|
418
|
+
|
419
|
+
def notifies_delayed(action, resource_spec)
|
420
|
+
run_context.notifies_delayed(Notification.new(resource_spec, action, self))
|
421
|
+
end
|
422
|
+
|
423
|
+
def immediate_notifications
|
424
|
+
run_context.immediate_notifications(self)
|
425
|
+
end
|
426
|
+
|
427
|
+
def delayed_notifications
|
428
|
+
run_context.delayed_notifications(self)
|
429
|
+
end
|
430
|
+
|
431
|
+
def resources(*args)
|
432
|
+
run_context.resource_collection.find(*args)
|
433
|
+
end
|
434
|
+
|
435
|
+
def subscribes(action, resources, timing=:delayed)
|
436
|
+
resources = [resources].flatten
|
437
|
+
resources.each do |resource|
|
438
|
+
if resource.is_a?(String)
|
439
|
+
resource = Chef::Resource.new(resource, run_context)
|
440
|
+
end
|
441
|
+
if resource.run_context.nil?
|
442
|
+
resource.run_context = run_context
|
443
|
+
end
|
444
|
+
resource.notifies(action, self, timing)
|
445
|
+
end
|
446
|
+
true
|
447
|
+
end
|
448
|
+
|
449
|
+
def is(*args)
|
450
|
+
if args.size == 1
|
451
|
+
args.first
|
452
|
+
else
|
453
|
+
return *args
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
def to_s
|
458
|
+
"#{@resource_name}[#{@name}]"
|
459
|
+
end
|
460
|
+
|
461
|
+
def to_text
|
462
|
+
ivars = instance_variables.map { |ivar| ivar.to_sym } - HIDDEN_IVARS
|
463
|
+
text = "# Declared in #{@source_line}\n\n"
|
464
|
+
text << self.class.dsl_name + "(\"#{name}\") do\n"
|
465
|
+
ivars.each do |ivar|
|
466
|
+
if (value = instance_variable_get(ivar)) && !(value.respond_to?(:empty?) && value.empty?)
|
467
|
+
value_string = value.respond_to?(:to_text) ? value.to_text : value.inspect
|
468
|
+
text << " #{ivar.to_s.sub(/^@/,'')} #{value_string}\n"
|
469
|
+
end
|
470
|
+
end
|
471
|
+
[@not_if, @only_if].flatten.each do |conditional|
|
472
|
+
text << " #{conditional.to_text}\n"
|
473
|
+
end
|
474
|
+
text << "end\n"
|
475
|
+
end
|
476
|
+
|
477
|
+
def inspect
|
478
|
+
ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
|
479
|
+
ivars.inject("<#{to_s}") do |str, ivar|
|
480
|
+
str << " #{ivar}: #{instance_variable_get(ivar).inspect}"
|
481
|
+
end << ">"
|
482
|
+
end
|
483
|
+
|
484
|
+
# as_json does most of the to_json heavy lifted. It exists here in case activesupport
|
485
|
+
# is loaded. activesupport will call as_json and skip over to_json. This ensure
|
486
|
+
# json is encoded as expected
|
487
|
+
def as_json(*a)
|
488
|
+
safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
|
489
|
+
instance_vars = Hash.new
|
490
|
+
safe_ivars.each do |iv|
|
491
|
+
instance_vars[iv.to_s.sub(/^@/, '')] = instance_variable_get(iv)
|
492
|
+
end
|
493
|
+
{
|
494
|
+
'json_class' => self.class.name,
|
495
|
+
'instance_vars' => instance_vars
|
496
|
+
}
|
497
|
+
end
|
498
|
+
|
499
|
+
# Serialize this object as a hash
|
500
|
+
def to_json(*a)
|
501
|
+
results = as_json
|
502
|
+
results.to_json(*a)
|
503
|
+
end
|
504
|
+
|
505
|
+
def to_hash
|
506
|
+
safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
|
507
|
+
instance_vars = Hash.new
|
508
|
+
safe_ivars.each do |iv|
|
509
|
+
key = iv.to_s.sub(/^@/,'').to_sym
|
510
|
+
instance_vars[key] = instance_variable_get(iv)
|
511
|
+
end
|
512
|
+
instance_vars
|
513
|
+
end
|
514
|
+
|
515
|
+
# If command is a block, returns true if the block returns true, false if it returns false.
|
516
|
+
# ("Only run this resource if the block is true")
|
517
|
+
#
|
518
|
+
# If the command is not a block, executes the command. If it returns any status other than
|
519
|
+
# 0, it returns false (clearly, a 0 status code is true)
|
520
|
+
#
|
521
|
+
# === Parameters
|
522
|
+
# command<String>:: A a string to execute.
|
523
|
+
# opts<Hash>:: Options control the execution of the command
|
524
|
+
# block<Proc>:: A ruby block to run. Ignored if a command is given.
|
525
|
+
#
|
526
|
+
# === Evaluation
|
527
|
+
# * evaluates to true if the block is true, or if the command returns 0
|
528
|
+
# * evaluates to false if the block is false, or if the command returns a non-zero exit code.
|
529
|
+
def only_if(command=nil, opts={}, &block)
|
530
|
+
if command || block_given?
|
531
|
+
@only_if << Conditional.only_if(command, opts, &block)
|
532
|
+
end
|
533
|
+
@only_if
|
534
|
+
end
|
535
|
+
|
536
|
+
# If command is a block, returns false if the block returns true, true if it returns false.
|
537
|
+
# ("Do not run this resource if the block is true")
|
538
|
+
#
|
539
|
+
# If the command is not a block, executes the command. If it returns a 0 exitstatus, returns false.
|
540
|
+
# ("Do not run this resource if the command returns 0")
|
541
|
+
#
|
542
|
+
# === Parameters
|
543
|
+
# command<String>:: A a string to execute.
|
544
|
+
# opts<Hash>:: Options control the execution of the command
|
545
|
+
# block<Proc>:: A ruby block to run. Ignored if a command is given.
|
546
|
+
#
|
547
|
+
# === Evaluation
|
548
|
+
# * evaluates to true if the block is false, or if the command returns a non-zero exit status.
|
549
|
+
# * evaluates to false if the block is true, or if the command returns a 0 exit status.
|
550
|
+
def not_if(command=nil, opts={}, &block)
|
551
|
+
if command || block_given?
|
552
|
+
@not_if << Conditional.not_if(command, opts, &block)
|
553
|
+
end
|
554
|
+
@not_if
|
555
|
+
end
|
556
|
+
|
557
|
+
def defined_at
|
558
|
+
# The following regexp should match these two sourceline formats:
|
559
|
+
# /some/path/to/file.rb:80:in `wombat_tears'
|
560
|
+
# C:/some/path/to/file.rb:80 in 1`wombat_tears'
|
561
|
+
# extracting the path to the source file and the line number.
|
562
|
+
(file, line_no) = source_line.match(/(.*):(\d+):?.*$/).to_a[1,2] if source_line
|
563
|
+
if cookbook_name && recipe_name && source_line
|
564
|
+
"#{cookbook_name}::#{recipe_name} line #{line_no}"
|
565
|
+
elsif source_line
|
566
|
+
"#{file} line #{line_no}"
|
567
|
+
else
|
568
|
+
"dynamically defined"
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
def cookbook_version
|
573
|
+
if cookbook_name
|
574
|
+
run_context.cookbook_collection[cookbook_name]
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
def events
|
579
|
+
run_context.events
|
580
|
+
end
|
581
|
+
|
582
|
+
def run_action(action, notification_type=nil, notifying_resource=nil)
|
583
|
+
# reset state in case of multiple actions on the same resource.
|
584
|
+
@elapsed_time = 0
|
585
|
+
start_time = Time.now
|
586
|
+
events.resource_action_start(self, action, notification_type, notifying_resource)
|
587
|
+
# Try to resolve lazy/forward references in notifications again to handle
|
588
|
+
# the case where the resource was defined lazily (ie. in a ruby_block)
|
589
|
+
resolve_notification_references
|
590
|
+
validate_action(action)
|
591
|
+
|
592
|
+
if Chef::Config[:verbose_logging] || Chef::Log.level == :debug
|
593
|
+
# This can be noisy
|
594
|
+
Chef::Log.info("Processing #{self} action #{action} (#{defined_at})")
|
595
|
+
end
|
596
|
+
|
597
|
+
# ensure that we don't leave @updated_by_last_action set to true
|
598
|
+
# on accident
|
599
|
+
updated_by_last_action(false)
|
600
|
+
|
601
|
+
begin
|
602
|
+
return if should_skip?(action)
|
603
|
+
provider_for_action(action).run_action
|
604
|
+
rescue Exception => e
|
605
|
+
if ignore_failure
|
606
|
+
Chef::Log.error("#{self} (#{defined_at}) had an error: #{e.message}; ignore_failure is set, continuing")
|
607
|
+
events.resource_failed(self, action, e)
|
608
|
+
elsif retries > 0
|
609
|
+
events.resource_failed_retriable(self, action, retries, e)
|
610
|
+
@retries -= 1
|
611
|
+
Chef::Log.info("Retrying execution of #{self}, #{retries} attempt(s) left")
|
612
|
+
sleep retry_delay
|
613
|
+
retry
|
614
|
+
else
|
615
|
+
events.resource_failed(self, action, e)
|
616
|
+
raise customize_exception(e)
|
617
|
+
end
|
618
|
+
ensure
|
619
|
+
@elapsed_time = Time.now - start_time
|
620
|
+
events.resource_completed(self)
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
def validate_action(action)
|
625
|
+
raise ArgumentError, "nil is not a valid action for resource #{self}" if action.nil?
|
626
|
+
end
|
627
|
+
|
628
|
+
def provider_for_action(action)
|
629
|
+
# leverage new platform => short_name => resource
|
630
|
+
# which requires explicitly setting provider in
|
631
|
+
# resource class
|
632
|
+
if self.provider
|
633
|
+
provider = self.provider.new(self, self.run_context)
|
634
|
+
provider.action = action
|
635
|
+
provider
|
636
|
+
else # fall back to old provider resolution
|
637
|
+
Chef::Platform.provider_for_resource(self, action)
|
638
|
+
end
|
639
|
+
end
|
640
|
+
|
641
|
+
def customize_exception(e)
|
642
|
+
new_exception = e.exception("#{self} (#{defined_at}) had an error: #{e.class.name}: #{e.message}")
|
643
|
+
new_exception.set_backtrace(e.backtrace)
|
644
|
+
new_exception
|
645
|
+
end
|
646
|
+
# Evaluates not_if and only_if conditionals. Returns a falsey value if any
|
647
|
+
# of the conditionals indicate that this resource should be skipped, i.e.,
|
648
|
+
# if an only_if evaluates to false or a not_if evaluates to true.
|
649
|
+
#
|
650
|
+
# If this resource should be skipped, returns the first conditional that
|
651
|
+
# "fails" its check. Subsequent conditionals are not evaluated, so in
|
652
|
+
# general it's not a good idea to rely on side effects from not_if or
|
653
|
+
# only_if commands/blocks being evaluated.
|
654
|
+
def should_skip?(action)
|
655
|
+
conditionals = only_if + not_if
|
656
|
+
return false if conditionals.empty?
|
657
|
+
|
658
|
+
conditionals.find do |conditional|
|
659
|
+
if conditional.continue?
|
660
|
+
false
|
661
|
+
else
|
662
|
+
events.resource_skipped(self, action, conditional)
|
663
|
+
Chef::Log.debug("Skipping #{self} due to #{conditional.description}")
|
664
|
+
true
|
665
|
+
end
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
def updated_by_last_action(true_or_false)
|
670
|
+
@updated ||= true_or_false
|
671
|
+
@updated_by_last_action = true_or_false
|
672
|
+
end
|
673
|
+
|
674
|
+
def updated_by_last_action?
|
675
|
+
@updated_by_last_action
|
676
|
+
end
|
677
|
+
|
678
|
+
def updated?
|
679
|
+
updated
|
680
|
+
end
|
681
|
+
|
682
|
+
def self.json_create(o)
|
683
|
+
resource = self.new(o["instance_vars"]["@name"])
|
684
|
+
o["instance_vars"].each do |k,v|
|
685
|
+
resource.instance_variable_set("@#{k}".to_sym, v)
|
686
|
+
end
|
687
|
+
resource
|
688
|
+
end
|
689
|
+
|
690
|
+
# Hook to allow a resource to run specific code after creation
|
691
|
+
def after_created
|
692
|
+
nil
|
693
|
+
end
|
694
|
+
|
695
|
+
# Resources that want providers namespaced somewhere other than
|
696
|
+
# Chef::Provider can set the namespace with +provider_base+
|
697
|
+
# Ex:
|
698
|
+
# class MyResource < Chef::Resource
|
699
|
+
# provider_base Chef::Provider::Deploy
|
700
|
+
# # ...other stuff
|
701
|
+
# end
|
702
|
+
def self.provider_base(arg=nil)
|
703
|
+
@provider_base ||= arg
|
704
|
+
@provider_base ||= Chef::Provider
|
705
|
+
end
|
706
|
+
|
707
|
+
def self.platform_map
|
708
|
+
@@platform_map ||= PlatformMap.new
|
709
|
+
end
|
710
|
+
|
711
|
+
# Maps a short_name (and optionally a platform and version) to a
|
712
|
+
# Chef::Resource. This allows finer grained per platform resource
|
713
|
+
# attributes and the end of overloaded resource definitions
|
714
|
+
# (I'm looking at you Chef::Resource::Package)
|
715
|
+
# Ex:
|
716
|
+
# class WindowsFile < Chef::Resource
|
717
|
+
# provides :file, :on_platforms => ["windows"]
|
718
|
+
# # ...other stuff
|
719
|
+
# end
|
720
|
+
#
|
721
|
+
# TODO: 2011-11-02 schisamo - platform_version support
|
722
|
+
def self.provides(short_name, opts={})
|
723
|
+
short_name_sym = short_name
|
724
|
+
if short_name.kind_of?(String)
|
725
|
+
short_name.downcase!
|
726
|
+
short_name.gsub!(/\s/, "_")
|
727
|
+
short_name_sym = short_name.to_sym
|
728
|
+
end
|
729
|
+
if opts.has_key?(:on_platforms)
|
730
|
+
platforms = [opts[:on_platforms]].flatten
|
731
|
+
platforms.each do |p|
|
732
|
+
p = :default if :all == p.to_sym
|
733
|
+
platform_map.set(
|
734
|
+
:platform => p.to_sym,
|
735
|
+
:short_name => short_name_sym,
|
736
|
+
:resource => self
|
737
|
+
)
|
738
|
+
end
|
739
|
+
else
|
740
|
+
platform_map.set(
|
741
|
+
:short_name => short_name_sym,
|
742
|
+
:resource => self
|
743
|
+
)
|
744
|
+
end
|
745
|
+
end
|
746
|
+
|
747
|
+
# Returns a resource based on a short_name anda platform and version.
|
748
|
+
#
|
749
|
+
#
|
750
|
+
# ==== Parameters
|
751
|
+
# short_name<Symbol>:: short_name of the resource (ie :directory)
|
752
|
+
# platform<Symbol,String>:: platform name
|
753
|
+
# version<String>:: platform version
|
754
|
+
#
|
755
|
+
# === Returns
|
756
|
+
# <Chef::Resource>:: returns the proper Chef::Resource class
|
757
|
+
def self.resource_for_platform(short_name, platform=nil, version=nil)
|
758
|
+
platform_map.get(short_name, platform, version)
|
759
|
+
end
|
760
|
+
|
761
|
+
# Returns a resource based on a short_name and a node's
|
762
|
+
# platform and version.
|
763
|
+
#
|
764
|
+
# ==== Parameters
|
765
|
+
# short_name<Symbol>:: short_name of the resource (ie :directory)
|
766
|
+
# node<Chef::Node>:: Node object to look up platform and version in
|
767
|
+
#
|
768
|
+
# === Returns
|
769
|
+
# <Chef::Resource>:: returns the proper Chef::Resource class
|
770
|
+
def self.resource_for_node(short_name, node)
|
771
|
+
begin
|
772
|
+
platform, version = Chef::Platform.find_platform_and_version(node)
|
773
|
+
rescue ArgumentError
|
774
|
+
end
|
775
|
+
resource = resource_for_platform(short_name, platform, version)
|
776
|
+
resource
|
777
|
+
end
|
778
|
+
|
779
|
+
private
|
780
|
+
|
781
|
+
def lookup_provider_constant(name)
|
782
|
+
begin
|
783
|
+
self.class.provider_base.const_get(convert_to_class_name(name.to_s))
|
784
|
+
rescue NameError => e
|
785
|
+
if e.to_s =~ /#{Regexp.escape(self.class.provider_base.to_s)}/
|
786
|
+
raise ArgumentError, "No provider found to match '#{name}'"
|
787
|
+
else
|
788
|
+
raise e
|
789
|
+
end
|
790
|
+
end
|
791
|
+
end
|
792
|
+
|
793
|
+
end
|
794
|
+
end
|