chef 10.34.6 → 11.0.0.beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +155 -0
- data/README.md +89 -0
- data/Rakefile +4 -12
- data/bin/chef-apply +25 -0
- data/bin/chef-shell +34 -0
- data/bin/shef +6 -5
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/chef-expander.8.html +4 -4
- data/distro/common/html/chef-expanderctl.8.html +4 -4
- data/distro/common/html/chef-server-webui.8.html +4 -4
- data/distro/common/html/chef-server.8.html +4 -4
- data/distro/common/html/{shef.1.html → chef-shell.1.html} +49 -46
- data/distro/common/html/chef-solo.8.html +18 -12
- data/distro/common/html/chef-solr.8.html +4 -4
- data/distro/common/html/knife-bootstrap.1.html +4 -4
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +4 -4
- data/distro/common/html/knife-cookbook-site.1.html +4 -4
- data/distro/common/html/knife-cookbook.1.html +10 -7
- data/distro/common/html/knife-data-bag.1.html +10 -7
- data/distro/common/html/knife-environment.1.html +8 -6
- data/distro/common/html/knife-exec.1.html +9 -9
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +4 -4
- data/distro/common/html/knife-role.1.html +4 -4
- data/distro/common/html/knife-search.1.html +4 -4
- data/distro/common/html/knife-ssh.1.html +4 -4
- data/distro/common/html/knife-status.1.html +4 -4
- data/distro/common/html/knife-tag.1.html +4 -4
- data/distro/common/html/knife.1.html +8 -13
- data/distro/common/man/man1/{shef.1 → chef-shell.1} +21 -57
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +15 -2
- data/distro/common/man/man1/knife-data-bag.1 +15 -2
- data/distro/common/man/man1/knife-environment.1 +12 -2
- data/distro/common/man/man1/knife-exec.1 +4 -7
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +3 -6
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +36 -4
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/distro/common/markdown/man1/{shef.mkd → chef-shell.mkd} +49 -43
- data/distro/common/markdown/man1/knife-exec.mkd +11 -6
- data/distro/common/markdown/man1/knife.mkd +4 -9
- data/distro/debian/etc/default/chef-client +0 -1
- data/distro/debian/etc/init.d/chef-client +2 -2
- data/lib/chef.rb +2 -5
- data/lib/chef/api_client.rb +20 -130
- data/lib/chef/api_client/registration.rb +126 -0
- data/lib/chef/application.rb +71 -14
- data/lib/chef/application/apply.rb +160 -0
- data/lib/chef/application/client.rb +25 -18
- data/lib/chef/application/knife.rb +0 -2
- data/lib/chef/application/solo.rb +23 -8
- data/lib/chef/application/windows_service.rb +5 -2
- data/lib/chef/applications.rb +1 -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/{spec/unit/monkey_patches/uri_spec.rb → lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb} +12 -15
- 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/{index_queue.rb → chef_fs/file_system/file_system_error.rb} +14 -12
- data/lib/chef/{resource/whyrun_safe_ruby_block.rb → chef_fs/file_system/file_system_root_dir.rb} +10 -10
- 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/{provider/whyrun_safe_ruby_block.rb → chef_fs/file_system/nonexistent_fs_object.rb} +19 -9
- 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 +44 -21
- data/lib/chef/config.rb +52 -43
- data/lib/chef/cookbook/synchronizer.rb +6 -8
- data/lib/chef/cookbook/syntax_check.rb +61 -14
- data/lib/chef/cookbook_loader.rb +39 -26
- data/lib/chef/cookbook_uploader.rb +17 -19
- data/lib/chef/cookbook_version.rb +3 -302
- data/lib/chef/daemon.rb +3 -18
- data/lib/chef/data_bag.rb +4 -97
- data/lib/chef/data_bag_item.rb +2 -65
- data/lib/chef/digester.rb +73 -0
- data/lib/chef/dsl.rb +6 -0
- data/lib/chef/dsl/data_query.rb +66 -0
- data/lib/chef/dsl/include_attribute.rb +60 -0
- data/lib/chef/dsl/include_recipe.rb +42 -0
- data/lib/chef/dsl/platform_introspection.rb +213 -0
- data/lib/chef/dsl/recipe.rb +84 -0
- data/lib/chef/dsl/registry_helper.rb +59 -0
- data/lib/chef/encrypted_data_bag_item.rb +74 -19
- data/lib/chef/environment.rb +9 -180
- data/lib/chef/exceptions.rb +87 -14
- data/lib/chef/formatters/base.rb +4 -1
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +0 -4
- data/lib/chef/json_compat.rb +1 -97
- data/lib/chef/knife.rb +90 -41
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +3 -3
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
- data/lib/chef/knife/configure.rb +1 -2
- data/lib/chef/knife/cookbook_metadata.rb +1 -0
- data/lib/chef/knife/cookbook_test.rb +3 -2
- data/lib/chef/knife/cookbook_upload.rb +12 -7
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/generic_presenter.rb +26 -13
- data/lib/chef/knife/core/node_editor.rb +36 -16
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/core/text_formatter.rb +23 -37
- data/lib/chef/knife/core/ui.rb +15 -9
- 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_show.rb +7 -0
- data/lib/chef/knife/exec.rb +5 -5
- data/lib/chef/knife/help_topics.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +91 -7
- data/lib/chef/knife/list.rb +109 -0
- data/lib/chef/knife/raw.rb +108 -0
- data/lib/chef/knife/search.rb +40 -22
- data/lib/chef/knife/show.rb +32 -0
- data/lib/chef/knife/ssh.rb +6 -2
- data/lib/chef/knife/upload.rb +50 -0
- data/lib/chef/mixin/checksum.rb +3 -3
- data/lib/chef/mixin/deep_merge.rb +55 -197
- data/lib/chef/mixin/language.rb +9 -222
- data/lib/chef/mixin/language_include_attribute.rb +6 -38
- data/lib/chef/mixin/language_include_recipe.rb +3 -35
- data/lib/chef/mixin/params_validate.rb +6 -19
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +8 -61
- data/lib/chef/mixin/securable.rb +32 -7
- data/lib/chef/mixin/template.rb +40 -0
- data/lib/chef/mixins.rb +0 -4
- data/lib/chef/monkey_patches/net_http.rb +0 -34
- data/lib/chef/node.rb +133 -309
- data/lib/chef/node/attribute.rb +333 -473
- data/lib/chef/node/attribute_collections.rb +199 -0
- data/lib/chef/node/immutable_collections.rb +186 -0
- data/lib/chef/platform.rb +7 -22
- data/lib/chef/provider.rb +2 -49
- data/lib/chef/provider/breakpoint.rb +6 -6
- data/lib/chef/provider/cookbook_file.rb +5 -33
- data/lib/chef/provider/deploy.rb +2 -1
- data/lib/chef/provider/directory.rb +14 -17
- data/lib/chef/provider/file.rb +19 -52
- data/lib/chef/provider/group.rb +31 -51
- data/lib/chef/provider/group/dscl.rb +13 -53
- data/lib/chef/provider/group/gpasswd.rb +19 -14
- data/lib/chef/provider/group/groupadd.rb +1 -41
- data/lib/chef/provider/group/groupmod.rb +36 -46
- data/lib/chef/provider/group/pw.rb +16 -59
- data/lib/chef/provider/group/suse.rb +13 -16
- data/lib/chef/provider/group/usermod.rb +18 -40
- data/lib/chef/provider/group/windows.rb +6 -13
- data/lib/chef/provider/http_request.rb +25 -42
- data/lib/chef/provider/link.rb +2 -0
- data/lib/chef/provider/lwrp_base.rb +150 -0
- data/lib/chef/provider/package/portage.rb +4 -9
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +9 -41
- data/lib/chef/provider/package/yum.rb +12 -19
- data/lib/chef/provider/registry_key.rb +156 -0
- data/lib/chef/provider/remote_directory.rb +2 -0
- data/lib/chef/provider/remote_file.rb +21 -12
- data/lib/chef/provider/ruby_block.rb +5 -2
- data/lib/chef/provider/service.rb +15 -0
- data/lib/chef/provider/service/init.rb +9 -7
- data/lib/chef/provider/service/macosx.rb +15 -73
- data/lib/chef/provider/service/simple.rb +1 -1
- data/lib/chef/provider/service/solaris.rb +3 -3
- data/lib/chef/provider/template.rb +22 -25
- data/lib/chef/provider/template_finder.rb +61 -0
- data/lib/chef/provider/user.rb +0 -1
- data/lib/chef/provider/user/dscl.rb +175 -568
- data/lib/chef/provider/user/useradd.rb +30 -47
- data/lib/chef/providers.rb +3 -2
- data/lib/chef/recipe.rb +14 -8
- data/lib/chef/resource.rb +13 -154
- data/lib/chef/resource/group.rb +1 -11
- data/lib/chef/resource/http_request.rb +2 -1
- data/lib/chef/resource/lwrp_base.rb +127 -0
- data/lib/chef/resource/mount.rb +10 -11
- data/lib/chef/resource/registry_key.rb +86 -0
- data/lib/chef/resource/remote_directory.rb +6 -5
- data/lib/chef/resource/remote_file.rb +22 -31
- data/lib/chef/resource/ruby_block.rb +2 -2
- data/lib/chef/resource/service.rb +14 -0
- data/lib/chef/resource/user.rb +0 -18
- data/lib/chef/resource_collection.rb +25 -21
- data/lib/chef/resources.rb +2 -1
- data/lib/chef/rest.rb +50 -131
- data/lib/chef/rest/auth_credentials.rb +4 -20
- data/lib/chef/rest/rest_request.rb +2 -7
- data/lib/chef/role.rb +1 -97
- data/lib/chef/run_context.rb +108 -130
- data/lib/chef/run_context/cookbook_compiler.rb +280 -0
- data/lib/chef/run_list.rb +0 -2
- data/lib/chef/run_list/run_list_expansion.rb +0 -15
- data/lib/chef/run_lock.rb +90 -0
- data/lib/chef/runner.rb +28 -5
- data/lib/chef/sandbox.rb +15 -148
- data/lib/chef/scan_access_control.rb +2 -4
- data/lib/chef/shef/ext.rb +3 -575
- data/lib/chef/{shef.rb → shell.rb} +35 -40
- data/lib/chef/shell/ext.rb +593 -0
- data/lib/chef/{shef → shell}/model_wrapper.rb +3 -3
- data/lib/chef/{shef/shef_rest.rb → shell/shell_rest.rb} +4 -4
- data/lib/chef/{shef/shef_session.rb → shell/shell_session.rb} +17 -15
- data/lib/chef/shell_out.rb +7 -0
- data/lib/chef/util/windows/net_group.rb +1 -5
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api/process.rb +0 -1
- data/lib/chef/win32/handle.rb +1 -8
- data/lib/chef/win32/registry.rb +371 -0
- data/spec/data/big_json.json +1 -2
- data/spec/data/big_json_plus_one.json +1 -2
- data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
- data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
- data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
- data/spec/data/nodes/default.rb +3 -3
- data/spec/data/nodes/test.example.com.rb +3 -3
- data/spec/data/nodes/test.rb +3 -3
- data/spec/data/partial_one.erb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
- data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
- data/spec/data/{knife-home/.chef/plugins/knife/example_home_subcommand.rb → run_context/cookbooks/circular-dep1/recipes/default.rb} +0 -0
- data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
- data/spec/data/{lwrp_const_scoping/resources/conflict.rb → run_context/cookbooks/circular-dep2/recipes/default.rb} +0 -0
- data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
- data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
- data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
- data/spec/data/shef-config.rb +7 -0
- data/spec/functional/dsl/registry_helper_spec.rb +63 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +1 -1
- data/spec/functional/knife/exec_spec.rb +2 -2
- data/spec/functional/knife/ssh_spec.rb +5 -1
- data/spec/functional/resource/cookbook_file_spec.rb +7 -19
- data/spec/functional/resource/directory_spec.rb +4 -0
- data/spec/functional/resource/file_spec.rb +56 -22
- data/spec/functional/resource/link_spec.rb +2 -0
- data/spec/functional/resource/registry_spec.rb +576 -0
- data/spec/functional/resource/remote_directory_spec.rb +142 -36
- data/spec/functional/resource/remote_file_spec.rb +18 -0
- data/spec/functional/resource/template_spec.rb +23 -2
- data/spec/functional/run_lock_spec.rb +106 -0
- data/spec/functional/shell_spec.rb +100 -0
- data/spec/functional/win32/registry_helper_spec.rb +632 -0
- data/spec/spec_helper.rb +5 -29
- data/spec/stress/win32/security_spec.rb +1 -1
- data/spec/support/chef_helpers.rb +0 -2
- data/spec/support/platform_helpers.rb +8 -15
- data/spec/support/shared/functional/directory_resource.rb +84 -22
- data/spec/support/shared/functional/file_resource.rb +169 -71
- data/spec/support/shared/functional/securable_resource.rb +143 -119
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
- data/spec/support/shared/unit/file_system_support.rb +110 -0
- data/spec/support/shared/unit/platform_introspector.rb +162 -0
- data/spec/unit/api_client/registration_spec.rb +175 -0
- data/spec/unit/api_client_spec.rb +78 -156
- data/spec/unit/application/apply.rb +84 -0
- data/spec/unit/application/client_spec.rb +1 -37
- data/spec/unit/application/knife_spec.rb +5 -0
- data/spec/unit/application_spec.rb +57 -2
- data/spec/unit/checksum/storage/filesystem_spec.rb +1 -1
- data/spec/unit/chef_fs/diff_spec.rb +328 -0
- data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
- data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
- data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
- data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
- data/spec/unit/chef_fs/file_system_spec.rb +136 -0
- data/spec/unit/client_spec.rb +124 -33
- data/spec/unit/config_spec.rb +46 -13
- data/spec/unit/cookbook/synchronizer_spec.rb +1 -49
- data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
- data/spec/unit/cookbook_loader_spec.rb +153 -91
- data/spec/unit/cookbook_manifest_spec.rb +81 -81
- data/spec/unit/cookbook_spec.rb +3 -20
- data/spec/unit/cookbook_version_spec.rb +23 -122
- data/spec/unit/daemon_spec.rb +3 -24
- data/spec/unit/data_bag_spec.rb +6 -4
- data/spec/unit/digester_spec.rb +50 -0
- data/spec/unit/dsl/data_query_spec.rb +66 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
- data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +50 -105
- data/spec/unit/environment_spec.rb +0 -130
- data/spec/unit/exceptions_spec.rb +2 -3
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +3 -3
- data/spec/unit/json_compat_spec.rb +15 -7
- data/spec/unit/knife/bootstrap_spec.rb +2 -0
- data/spec/unit/knife/configure_spec.rb +20 -14
- data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
- data/spec/unit/knife/cookbook_test_spec.rb +1 -0
- data/spec/unit/knife/cookbook_upload_spec.rb +43 -8
- data/spec/unit/knife/core/bootstrap_context_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +156 -125
- data/spec/unit/knife/data_bag_create_spec.rb +9 -0
- data/spec/unit/knife/data_bag_edit_spec.rb +1 -4
- data/spec/unit/knife/data_bag_from_file_spec.rb +4 -6
- data/spec/unit/knife/data_bag_show_spec.rb +11 -4
- data/spec/unit/knife/index_rebuild_spec.rb +96 -33
- data/spec/unit/knife/knife_help.rb +7 -7
- data/spec/unit/knife/node_edit_spec.rb +6 -33
- data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
- data/spec/unit/knife/ssh_spec.rb +12 -15
- data/spec/unit/knife/status_spec.rb +2 -2
- data/spec/unit/knife_spec.rb +53 -0
- data/spec/unit/lwrp_spec.rb +59 -42
- data/spec/unit/mixin/checksum_spec.rb +2 -2
- data/spec/unit/mixin/deep_merge_spec.rb +101 -799
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
- data/spec/unit/mixin/params_validate_spec.rb +4 -37
- data/spec/unit/mixin/securable_spec.rb +5 -3
- data/spec/unit/mixin/template_spec.rb +119 -0
- data/spec/unit/node/attribute_spec.rb +195 -173
- data/spec/unit/node/immutable_collections_spec.rb +139 -0
- data/spec/unit/node_spec.rb +366 -370
- data/spec/unit/platform_spec.rb +9 -10
- data/spec/unit/provider/breakpoint_spec.rb +8 -8
- data/spec/unit/provider/cookbook_file_spec.rb +4 -8
- data/spec/unit/provider/directory_spec.rb +96 -64
- data/spec/unit/provider/env_spec.rb +2 -2
- data/spec/unit/provider/file_spec.rb +48 -39
- data/spec/unit/provider/group/dscl_spec.rb +0 -36
- data/spec/unit/provider/group/gpasswd_spec.rb +9 -16
- data/spec/unit/provider/group/groupadd_spec.rb +4 -3
- data/spec/unit/provider/group/groupmod_spec.rb +1 -0
- data/spec/unit/provider/group/pw_spec.rb +15 -12
- data/spec/unit/provider/group/usermod_spec.rb +6 -21
- data/spec/unit/provider/group/windows_spec.rb +8 -0
- data/spec/unit/provider/group_spec.rb +6 -28
- data/spec/unit/provider/http_request_spec.rb +28 -69
- data/spec/unit/provider/ifconfig_spec.rb +2 -2
- data/spec/unit/provider/ohai_spec.rb +4 -4
- data/spec/unit/provider/package/apt_spec.rb +0 -1
- data/spec/unit/provider/package/ips_spec.rb +0 -1
- data/spec/unit/provider/package/portage_spec.rb +0 -44
- data/spec/unit/provider/package/rpm_spec.rb +0 -12
- data/spec/unit/provider/package/rubygems_spec.rb +1 -44
- data/spec/unit/provider/package/yum_spec.rb +39 -36
- data/spec/unit/provider/package_spec.rb +7 -5
- data/spec/unit/provider/registry_key_spec.rb +269 -0
- data/spec/unit/provider/remote_directory_spec.rb +7 -3
- data/spec/unit/provider/remote_file_spec.rb +36 -0
- data/spec/unit/provider/route_spec.rb +4 -3
- data/spec/unit/provider/ruby_block_spec.rb +8 -0
- data/spec/unit/provider/service/arch_service_spec.rb +5 -5
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +5 -5
- data/spec/unit/provider/service/init_service_spec.rb +27 -4
- data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
- data/spec/unit/provider/service/invokercd_service_spec.rb +4 -4
- data/spec/unit/provider/service/macosx_spec.rb +11 -66
- data/spec/unit/provider/service/redhat_spec.rb +1 -1
- data/spec/unit/provider/service/simple_service_spec.rb +3 -3
- data/spec/unit/provider/service/upstart_service_spec.rb +9 -9
- data/spec/unit/provider/subversion_spec.rb +1 -1
- data/spec/unit/provider/template_spec.rb +35 -11
- data/spec/unit/provider/user/dscl_spec.rb +285 -681
- data/spec/unit/provider/user/useradd_spec.rb +1 -22
- data/spec/unit/provider/user_spec.rb +1 -1
- data/spec/unit/recipe_spec.rb +10 -8
- data/spec/unit/registry_helper_spec.rb +374 -0
- data/spec/unit/resource/mount_spec.rb +0 -11
- data/spec/unit/resource/registry_key_spec.rb +171 -0
- data/spec/unit/resource/remote_file_spec.rb +21 -23
- data/spec/unit/resource/ruby_block_spec.rb +7 -3
- data/spec/unit/resource/service_spec.rb +11 -0
- data/spec/unit/resource_spec.rb +4 -19
- data/spec/unit/rest/auth_credentials_spec.rb +2 -19
- data/spec/unit/rest_spec.rb +130 -284
- data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
- data/spec/unit/run_context_spec.rb +18 -4
- data/spec/unit/run_list_spec.rb +0 -209
- data/spec/unit/run_lock_spec.rb +37 -0
- data/spec/unit/runner_spec.rb +101 -2
- data/spec/unit/scan_access_control_spec.rb +4 -4
- data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
- data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
- data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +14 -69
- data/spec/unit/shell_out_spec.rb +18 -0
- data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
- metadata +275 -234
- checksums.yaml +0 -15
- data/README.rdoc +0 -177
- data/distro/common/html/knife-recipe.1.html +0 -92
- data/lib/chef/certificate.rb +0 -161
- data/lib/chef/checksum.rb +0 -167
- data/lib/chef/checksum_cache.rb +0 -190
- data/lib/chef/cookbook_version_selector.rb +0 -168
- data/lib/chef/couchdb.rb +0 -246
- data/lib/chef/index_queue/amqp_client.rb +0 -116
- data/lib/chef/index_queue/consumer.rb +0 -76
- data/lib/chef/index_queue/indexable.rb +0 -109
- data/lib/chef/knife/bootstrap/ubuntu12.10-gems.erb +0 -60
- data/lib/chef/monkey_patches/moneta.rb +0 -50
- data/lib/chef/monkey_patches/uri.rb +0 -70
- data/lib/chef/openid_registration.rb +0 -187
- data/lib/chef/provider/user/solaris.rb +0 -90
- data/lib/chef/solr_query.rb +0 -187
- data/lib/chef/solr_query/lucene.treetop +0 -150
- data/lib/chef/solr_query/lucene_nodes.rb +0 -285
- data/lib/chef/solr_query/query_transform.rb +0 -65
- data/lib/chef/solr_query/solr_http_request.rb +0 -132
- data/lib/chef/webui_user.rb +0 -231
- data/spec/data/cookbooks/openldap/files/default/.dotfile +0 -1
- data/spec/data/cookbooks/openldap/files/default/.ssh/id_rsa +0 -1
- data/spec/data/cookbooks/openldap/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir +0 -1
- data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/.a_dotfile +0 -1
- data/spec/data/mac_users/10.7-8.plist.xml +0 -559
- data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
- data/spec/data/mac_users/10.7.plist.xml +0 -559
- data/spec/data/mac_users/10.7.shadow.xml +0 -11
- data/spec/data/mac_users/10.8.plist.xml +0 -559
- data/spec/data/mac_users/10.8.shadow.xml +0 -21
- data/spec/data/mac_users/10.9.plist.xml +0 -560
- data/spec/data/mac_users/10.9.shadow.xml +0 -21
- data/spec/functional/resource/base.rb +0 -40
- data/spec/functional/resource/group_spec.rb +0 -343
- data/spec/functional/resource/user/dscl_spec.rb +0 -199
- data/spec/unit/certificate_spec.rb +0 -76
- data/spec/unit/checksum_cache_spec.rb +0 -209
- data/spec/unit/checksum_spec.rb +0 -94
- data/spec/unit/couchdb_spec.rb +0 -274
- data/spec/unit/index_queue_spec.rb +0 -391
- data/spec/unit/mixin/language_spec.rb +0 -305
- data/spec/unit/openid_registration_spec.rb +0 -153
- data/spec/unit/provider/user/solaris_spec.rb +0 -414
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +0 -47
- data/spec/unit/solr_query/query_transform_spec.rb +0 -454
- data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
- data/spec/unit/solr_query_spec.rb +0 -203
- data/spec/unit/webui_user_spec.rb +0 -238
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
|
8
8
|
# You may obtain a copy of the License at
|
|
9
|
-
#
|
|
9
|
+
#
|
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
@@ -16,46 +16,14 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
18
|
|
|
19
|
-
require 'chef/
|
|
19
|
+
require 'chef/dsl/include_attribute'
|
|
20
20
|
|
|
21
21
|
class Chef
|
|
22
22
|
module Mixin
|
|
23
|
-
module LanguageIncludeAttribute
|
|
24
|
-
|
|
25
|
-
# Loads the attribute file specified by the short name of the
|
|
26
|
-
# file, e.g., loads specified cookbook's
|
|
27
|
-
# "attributes/mailservers.rb"
|
|
28
|
-
# if passed
|
|
29
|
-
# "mailservers"
|
|
30
|
-
def include_attribute(*fully_qualified_attribute_short_filenames)
|
|
31
|
-
if self.kind_of?(Chef::Node)
|
|
32
|
-
node = self
|
|
33
|
-
else
|
|
34
|
-
node = @node
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
fully_qualified_attribute_short_filenames.flatten.each do |fully_qualified_attribute_short_filename|
|
|
38
|
-
if node.run_state[:seen_attributes].has_key?(fully_qualified_attribute_short_filename)
|
|
39
|
-
Chef::Log.debug("I am not loading attribute file #{fully_qualified_attribute_short_filename}, because I have already seen it.")
|
|
40
|
-
next
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
Chef::Log.debug("Loading Attribute #{fully_qualified_attribute_short_filename}")
|
|
44
|
-
node.run_state[:seen_attributes][fully_qualified_attribute_short_filename] = true
|
|
45
|
-
|
|
46
|
-
if amatch = fully_qualified_attribute_short_filename.match(/(.+?)::(.+)/)
|
|
47
|
-
cookbook_name = amatch[1].to_sym
|
|
48
|
-
node.load_attribute_by_short_filename(amatch[2], cookbook_name)
|
|
49
|
-
else
|
|
50
|
-
cookbook_name = fully_qualified_attribute_short_filename.to_sym
|
|
51
|
-
node.load_attribute_by_short_filename("default", cookbook_name)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
true
|
|
55
|
-
end
|
|
56
23
|
|
|
57
|
-
|
|
24
|
+
# DEPRECATED: This is just here for compatibility, use
|
|
25
|
+
# Chef::DSL::IncludeAttribute instead.
|
|
26
|
+
LanguageIncludeAttribute = Chef::DSL::IncludeAttribute
|
|
58
27
|
end
|
|
59
28
|
end
|
|
60
|
-
|
|
61
29
|
|
|
@@ -16,43 +16,11 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
18
|
|
|
19
|
-
require 'chef/
|
|
19
|
+
require 'chef/dsl/include_recipe'
|
|
20
20
|
|
|
21
21
|
class Chef
|
|
22
22
|
module Mixin
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def include_recipe(*recipe_names)
|
|
26
|
-
result_recipes = Array.new
|
|
27
|
-
recipe_names.flatten.each do |recipe_name|
|
|
28
|
-
if node.run_state[:seen_recipes].has_key?(recipe_name) or node.run_state[:seen_recipes].has_key?(recipe_name + "::default")
|
|
29
|
-
Chef::Log.debug("I am not loading #{recipe_name}, because I have already seen it.")
|
|
30
|
-
next
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
result_recipes << load_recipe(recipe_name)
|
|
34
|
-
end
|
|
35
|
-
result_recipes
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def load_recipe(recipe_name)
|
|
39
|
-
Chef::Log.debug("Loading Recipe #{recipe_name} via include_recipe")
|
|
40
|
-
node.run_state[:seen_recipes][recipe_name] = true
|
|
41
|
-
|
|
42
|
-
cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name)
|
|
43
|
-
|
|
44
|
-
run_context = self.is_a?(Chef::RunContext) ? self : self.run_context
|
|
45
|
-
cookbook = run_context.cookbook_collection[cookbook_name]
|
|
46
|
-
cookbook.load_recipe(recipe_short_name, run_context)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def require_recipe(*args)
|
|
51
|
-
Chef::Log.warn("require_recipe is deprecated and will be removed in a future release, please use include_recipe")
|
|
52
|
-
include_recipe(*args)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
end
|
|
23
|
+
LanguageIncludeRecipe = Chef::DSL::IncludeRecipe
|
|
56
24
|
end
|
|
57
25
|
end
|
|
58
|
-
|
|
26
|
+
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
18
|
class Chef
|
|
19
|
-
|
|
20
|
-
end
|
|
19
|
+
|
|
21
20
|
module Mixin
|
|
22
21
|
module ParamsValidate
|
|
23
22
|
|
|
@@ -76,30 +75,18 @@ class Chef
|
|
|
76
75
|
end
|
|
77
76
|
opts
|
|
78
77
|
end
|
|
79
|
-
|
|
80
|
-
def lazy(&block)
|
|
81
|
-
DelayedEvaluator.new(&block)
|
|
82
|
-
end
|
|
83
|
-
|
|
78
|
+
|
|
84
79
|
def set_or_return(symbol, arg, validation)
|
|
85
80
|
iv_symbol = "@#{symbol.to_s}".to_sym
|
|
86
81
|
map = {
|
|
87
82
|
symbol => validation
|
|
88
83
|
}
|
|
84
|
+
|
|
89
85
|
if arg == nil && self.instance_variable_defined?(iv_symbol) == true
|
|
90
|
-
|
|
91
|
-
if(ivar.is_a?(DelayedEvaluator))
|
|
92
|
-
validate({ symbol => ivar.call }, { symbol => validation })[symbol]
|
|
93
|
-
else
|
|
94
|
-
ivar
|
|
95
|
-
end
|
|
86
|
+
self.instance_variable_get(iv_symbol)
|
|
96
87
|
else
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
else
|
|
100
|
-
val = validate({ symbol => arg }, { symbol => validation })[symbol]
|
|
101
|
-
end
|
|
102
|
-
self.instance_variable_set(iv_symbol, val)
|
|
88
|
+
opts = validate({ symbol => arg }, { symbol => validation })
|
|
89
|
+
self.instance_variable_set(iv_symbol, opts[symbol])
|
|
103
90
|
end
|
|
104
91
|
end
|
|
105
92
|
|
|
@@ -17,70 +17,17 @@
|
|
|
17
17
|
# limitations under the License.
|
|
18
18
|
#
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
###
|
|
21
|
+
# NOTE: This file and constant are here only for backwards compatibility.
|
|
22
|
+
# New code should use Chef::DSL::Recipe instead.
|
|
23
|
+
#
|
|
24
|
+
# This constant (module name) will eventually be deprecated and then removed.
|
|
25
|
+
###
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
# UGH. this is a circular require that will cause an uninitialized constant
|
|
27
|
-
# error, but this file really does depend on Chef::Recipe. oh well.
|
|
28
|
-
# require 'chef/recipe'
|
|
27
|
+
require 'chef/dsl/recipe'
|
|
29
28
|
|
|
30
29
|
class Chef
|
|
31
30
|
module Mixin
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
include Chef::Mixin::ConvertToClassName
|
|
35
|
-
include Chef::Mixin::Language
|
|
36
|
-
|
|
37
|
-
def method_missing(method_symbol, *args, &block)
|
|
38
|
-
# If we have a definition that matches, we want to use that instead. This should
|
|
39
|
-
# let you do some really crazy over-riding of "native" types, if you really want
|
|
40
|
-
# to.
|
|
41
|
-
if run_context.definitions.has_key?(method_symbol)
|
|
42
|
-
# This dupes the high level object, but we still need to dup the params
|
|
43
|
-
new_def = run_context.definitions[method_symbol].dup
|
|
44
|
-
new_def.params = new_def.params.dup
|
|
45
|
-
new_def.node = run_context.node
|
|
46
|
-
# This sets up the parameter overrides
|
|
47
|
-
new_def.instance_eval(&block) if block
|
|
48
|
-
new_recipe = Chef::Recipe.new(cookbook_name, @recipe_name, run_context)
|
|
49
|
-
new_recipe.params = new_def.params
|
|
50
|
-
new_recipe.params[:name] = args[0]
|
|
51
|
-
new_recipe.instance_eval(&new_def.recipe)
|
|
52
|
-
else
|
|
53
|
-
# Otherwise, we're rocking the regular resource call route.
|
|
54
|
-
|
|
55
|
-
# Checks the new platform => short_name => resource mapping initially
|
|
56
|
-
# then fall back to the older approach (Chef::Resource.const_get) for
|
|
57
|
-
# backward compatibility
|
|
58
|
-
resource_class = Chef::Resource.resource_for_node(method_symbol, run_context.node)
|
|
59
|
-
|
|
60
|
-
super unless resource_class
|
|
61
|
-
raise ArgumentError, "You must supply a name when declaring a #{method_symbol} resource" unless args.size > 0
|
|
62
|
-
|
|
63
|
-
# If we have a resource like this one, we want to steal its state
|
|
64
|
-
args << run_context
|
|
65
|
-
resource = resource_class.new(*args)
|
|
66
|
-
resource.source_line = caller[0]
|
|
67
|
-
resource.load_prior_resource
|
|
68
|
-
resource.cookbook_name = cookbook_name
|
|
69
|
-
resource.recipe_name = @recipe_name
|
|
70
|
-
resource.params = @params
|
|
71
|
-
# Determine whether this resource is being created in the context of an enclosing Provider
|
|
72
|
-
resource.enclosing_provider = self.is_a?(Chef::Provider) ? self : nil
|
|
73
|
-
# Evaluate resource attribute DSL
|
|
74
|
-
resource.instance_eval(&block) if block
|
|
75
|
-
|
|
76
|
-
# Run optional resource hook
|
|
77
|
-
resource.after_created
|
|
78
|
-
|
|
79
|
-
run_context.resource_collection.insert(resource)
|
|
80
|
-
resource
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
end
|
|
31
|
+
RecipeDefinitionDSLCore = Chef::DSL::Recipe
|
|
85
32
|
end
|
|
86
33
|
end
|
data/lib/chef/mixin/securable.rb
CHANGED
|
@@ -59,9 +59,17 @@ class Chef
|
|
|
59
59
|
)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
# TODO should this be separated into different files?
|
|
63
|
-
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
|
64
62
|
|
|
63
|
+
#==WindowsMacros
|
|
64
|
+
# Defines methods for adding attributes to a chef resource to describe
|
|
65
|
+
# Windows file security metadata.
|
|
66
|
+
#
|
|
67
|
+
# This module is meant to be used to extend a class (instead of
|
|
68
|
+
# `include`-ing). A class is automatically extended with this module when
|
|
69
|
+
# it includes WindowsSecurableAttributes.
|
|
70
|
+
# --
|
|
71
|
+
# TODO should this be separated into different files?
|
|
72
|
+
module WindowsMacros
|
|
65
73
|
# === rights_attribute
|
|
66
74
|
# "meta-method" for dynamically creating rights attributes on resources.
|
|
67
75
|
#
|
|
@@ -99,7 +107,7 @@ class Chef
|
|
|
99
107
|
# * `:applies_to_self` (optional): Boolean
|
|
100
108
|
# * `:one_level_deep` (optional): Boolean
|
|
101
109
|
#
|
|
102
|
-
def
|
|
110
|
+
def rights_attribute(name)
|
|
103
111
|
|
|
104
112
|
# equivalent to something like:
|
|
105
113
|
# def rights(permissions=nil, principals=nil, args_hash=nil)
|
|
@@ -160,10 +168,13 @@ class Chef
|
|
|
160
168
|
)
|
|
161
169
|
end
|
|
162
170
|
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
#==WindowsSecurableAttributes
|
|
174
|
+
# Defines #inherits to describe Windows file security ACLs on the
|
|
175
|
+
# including class
|
|
176
|
+
module WindowsSecurableAttributes
|
|
163
177
|
|
|
164
|
-
# create a default 'rights' attribute
|
|
165
|
-
rights_attribute(:rights)
|
|
166
|
-
rights_attribute(:deny_rights)
|
|
167
178
|
|
|
168
179
|
def inherits(arg=nil)
|
|
169
180
|
set_or_return(
|
|
@@ -172,8 +183,22 @@ class Chef
|
|
|
172
183
|
:kind_of => [ TrueClass, FalseClass ]
|
|
173
184
|
)
|
|
174
185
|
end
|
|
186
|
+
end
|
|
175
187
|
|
|
176
|
-
|
|
188
|
+
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
|
189
|
+
include WindowsSecurableAttributes
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Callback that fires when included; will extend the including class
|
|
193
|
+
# with WindowsMacros and define #rights and #deny_rights on it.
|
|
194
|
+
def self.included(including_class)
|
|
195
|
+
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
|
196
|
+
including_class.extend(WindowsMacros)
|
|
197
|
+
# create a default 'rights' attribute
|
|
198
|
+
including_class.rights_attribute(:rights)
|
|
199
|
+
including_class.rights_attribute(:deny_rights)
|
|
200
|
+
end
|
|
201
|
+
end
|
|
177
202
|
|
|
178
203
|
end
|
|
179
204
|
end
|
data/lib/chef/mixin/template.rb
CHANGED
|
@@ -29,6 +29,46 @@ class Chef
|
|
|
29
29
|
raise "Could not find a value for node. If you are explicitly setting variables in a template, " +
|
|
30
30
|
"include a node variable if you plan to use it."
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Takes the name of the partial, plus a hash of options. Returns a
|
|
35
|
+
# string that contains the result of the evaluation of the partial.
|
|
36
|
+
#
|
|
37
|
+
# All variables from the parent template will be propagated down to
|
|
38
|
+
# the partial, unless you pass the +variables+ option (see below).
|
|
39
|
+
#
|
|
40
|
+
# Valid options are:
|
|
41
|
+
#
|
|
42
|
+
# :local:: If true then the partial name will be interpreted as the
|
|
43
|
+
# path to a file on the local filesystem; if false (the
|
|
44
|
+
# default) it will be looked up in the cookbook according to
|
|
45
|
+
# the normal rules for templates.
|
|
46
|
+
# :source:: If specified then the partial will be looked up with this
|
|
47
|
+
# name or path (according to the +local+ option) instead of
|
|
48
|
+
# +partial_name+.
|
|
49
|
+
# :cookbook:: Search for the partial in the provided cookbook instead
|
|
50
|
+
# of the cookbook that contains the top-level template.
|
|
51
|
+
# :variables:: A Hash of variable_name => value that will be made
|
|
52
|
+
# available to the partial. If specified, none of the
|
|
53
|
+
# variables from the master template will be, so if you
|
|
54
|
+
# need them you will need to propagate them explicitly.
|
|
55
|
+
#
|
|
56
|
+
def render(partial_name, options = {})
|
|
57
|
+
raise "You cannot render partials in this context" unless @template_finder
|
|
58
|
+
|
|
59
|
+
if variables = options.delete(:variables)
|
|
60
|
+
context = {}
|
|
61
|
+
context.merge!(variables)
|
|
62
|
+
context[:node] = @node
|
|
63
|
+
context[:template_finder] = @template_finder
|
|
64
|
+
else
|
|
65
|
+
context = self.dup
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
template_location = @template_finder.find(partial_name, options)
|
|
69
|
+
eruby = Erubis::Eruby.new(IO.read(template_location))
|
|
70
|
+
output = eruby.evaluate(context)
|
|
71
|
+
end
|
|
32
72
|
end
|
|
33
73
|
|
|
34
74
|
::Erubis::Context.send(:include, ChefContext)
|
data/lib/chef/mixins.rb
CHANGED
|
@@ -7,12 +7,8 @@ require 'chef/mixin/create_path'
|
|
|
7
7
|
require 'chef/mixin/deep_merge'
|
|
8
8
|
require 'chef/mixin/enforce_ownership_and_permissions'
|
|
9
9
|
require 'chef/mixin/from_file'
|
|
10
|
-
require 'chef/mixin/language'
|
|
11
|
-
require 'chef/mixin/language_include_attribute'
|
|
12
|
-
require 'chef/mixin/language_include_recipe'
|
|
13
10
|
require 'chef/mixin/params_validate'
|
|
14
11
|
require 'chef/mixin/path_sanity'
|
|
15
|
-
require 'chef/mixin/recipe_definition_dsl_core'
|
|
16
12
|
require 'chef/mixin/template'
|
|
17
13
|
require 'chef/mixin/securable'
|
|
18
14
|
require 'chef/mixin/xml_escape'
|
|
@@ -20,37 +20,3 @@ module Net
|
|
|
20
20
|
include ChefNetHTTPExceptionExtensions
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
|
-
|
|
24
|
-
if Net::HTTP.instance_methods.map {|m| m.to_s}.include?("proxy_uri")
|
|
25
|
-
begin
|
|
26
|
-
# Ruby 2.0 changes the way proxy support is implemented in Net::HTTP.
|
|
27
|
-
# The implementation does not work correctly with IPv6 literals because it
|
|
28
|
-
# concatenates the address into a URI without adding square brackets for
|
|
29
|
-
# IPv6 addresses.
|
|
30
|
-
#
|
|
31
|
-
# If the bug is present, a call to Net::HTTP#proxy_uri when the host is an
|
|
32
|
-
# IPv6 address will fail by creating an invalid URI, like so:
|
|
33
|
-
#
|
|
34
|
-
# ruby -r'net/http' -e 'Net::HTTP.new("::1", 80).proxy_uri'
|
|
35
|
-
# /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize': the scheme http does not accept registry part: ::1:80 (or bad hostname?) (URI::InvalidURIError)
|
|
36
|
-
# from /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/uri/http.rb:84:in `initialize'
|
|
37
|
-
# from /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/uri/common.rb:214:in `new'
|
|
38
|
-
# from /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/uri/common.rb:214:in `parse'
|
|
39
|
-
# from /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/uri/common.rb:747:in `parse'
|
|
40
|
-
# from /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/uri/common.rb:994:in `URI'
|
|
41
|
-
# from /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1027:in `proxy_uri'
|
|
42
|
-
# from -e:1:in `<main>'
|
|
43
|
-
#
|
|
44
|
-
# https://bugs.ruby-lang.org/issues/9129
|
|
45
|
-
Net::HTTP.new("::1", 80).proxy_uri
|
|
46
|
-
rescue URI::InvalidURIError
|
|
47
|
-
class Net::HTTP
|
|
48
|
-
|
|
49
|
-
def proxy_uri # :nodoc:
|
|
50
|
-
ipv6_safe_addr = address.to_s.include?(":") ? "[#{address}]" : address
|
|
51
|
-
@proxy_uri ||= URI("http://#{ipv6_safe_addr}:#{port}").find_proxy
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
data/lib/chef/node.rb
CHANGED
|
@@ -21,19 +21,17 @@
|
|
|
21
21
|
|
|
22
22
|
require 'forwardable'
|
|
23
23
|
require 'chef/config'
|
|
24
|
-
require 'chef/cookbook/cookbook_collection'
|
|
25
24
|
require 'chef/nil_argument'
|
|
26
25
|
require 'chef/mixin/check_helper'
|
|
27
26
|
require 'chef/mixin/params_validate'
|
|
28
27
|
require 'chef/mixin/from_file'
|
|
29
|
-
require 'chef/mixin/language_include_attribute'
|
|
30
28
|
require 'chef/mixin/deep_merge'
|
|
29
|
+
require 'chef/dsl/include_attribute'
|
|
30
|
+
require 'chef/dsl/platform_introspection'
|
|
31
31
|
require 'chef/environment'
|
|
32
|
-
require 'chef/couchdb'
|
|
33
32
|
require 'chef/rest'
|
|
34
33
|
require 'chef/run_list'
|
|
35
34
|
require 'chef/node/attribute'
|
|
36
|
-
require 'chef/index_queue'
|
|
37
35
|
require 'chef/mash'
|
|
38
36
|
require 'chef/json_compat'
|
|
39
37
|
require 'chef/search/query'
|
|
@@ -43,144 +41,35 @@ class Chef
|
|
|
43
41
|
|
|
44
42
|
extend Forwardable
|
|
45
43
|
|
|
46
|
-
def_delegators :
|
|
44
|
+
def_delegators :attributes, :keys, :each_key, :each_value, :key?, :has_key?
|
|
47
45
|
|
|
48
|
-
attr_accessor :recipe_list, :
|
|
49
|
-
attr_accessor :override_attrs, :default_attrs, :normal_attrs, :automatic_attrs
|
|
50
|
-
attr_reader :couchdb_id
|
|
46
|
+
attr_accessor :recipe_list, :run_state, :run_list
|
|
51
47
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
|
|
48
|
+
# RunContext will set itself as run_context via this setter when
|
|
49
|
+
# initialized. This is needed so DSL::IncludeAttribute (in particular,
|
|
50
|
+
# #include_recipe) can access the run_context to determine if an attributes
|
|
51
|
+
# file has been seen yet.
|
|
52
|
+
#--
|
|
53
|
+
# TODO: This is a pretty ugly way to solve that problem.
|
|
54
|
+
attr_accessor :run_context
|
|
56
55
|
|
|
57
|
-
include Chef::Mixin::CheckHelper
|
|
58
56
|
include Chef::Mixin::FromFile
|
|
57
|
+
include Chef::DSL::IncludeAttribute
|
|
58
|
+
include Chef::DSL::PlatformIntrospection
|
|
59
|
+
|
|
60
|
+
include Chef::Mixin::CheckHelper
|
|
59
61
|
include Chef::Mixin::ParamsValidate
|
|
60
|
-
include Chef::Mixin::LanguageIncludeAttribute
|
|
61
|
-
include Chef::IndexQueue::Indexable
|
|
62
|
-
|
|
63
|
-
DESIGN_DOCUMENT = {
|
|
64
|
-
"version" => 11,
|
|
65
|
-
"language" => "javascript",
|
|
66
|
-
"views" => {
|
|
67
|
-
"all" => {
|
|
68
|
-
"map" => <<-EOJS
|
|
69
|
-
function(doc) {
|
|
70
|
-
if (doc.chef_type == "node") {
|
|
71
|
-
emit(doc.name, doc);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
EOJS
|
|
75
|
-
},
|
|
76
|
-
"all_id" => {
|
|
77
|
-
"map" => <<-EOJS
|
|
78
|
-
function(doc) {
|
|
79
|
-
if (doc.chef_type == "node") {
|
|
80
|
-
emit(doc.name, doc.name);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
EOJS
|
|
84
|
-
},
|
|
85
|
-
"status" => {
|
|
86
|
-
"map" => <<-EOJS
|
|
87
|
-
function(doc) {
|
|
88
|
-
if (doc.chef_type == "node") {
|
|
89
|
-
var to_emit = { "name": doc.name, "chef_environment": doc.chef_environment };
|
|
90
|
-
if (doc["attributes"]["fqdn"]) {
|
|
91
|
-
to_emit["fqdn"] = doc["attributes"]["fqdn"];
|
|
92
|
-
} else {
|
|
93
|
-
to_emit["fqdn"] = "Undefined";
|
|
94
|
-
}
|
|
95
|
-
if (doc["attributes"]["ipaddress"]) {
|
|
96
|
-
to_emit["ipaddress"] = doc["attributes"]["ipaddress"];
|
|
97
|
-
} else {
|
|
98
|
-
to_emit["ipaddress"] = "Undefined";
|
|
99
|
-
}
|
|
100
|
-
if (doc["attributes"]["ohai_time"]) {
|
|
101
|
-
to_emit["ohai_time"] = doc["attributes"]["ohai_time"];
|
|
102
|
-
} else {
|
|
103
|
-
to_emit["ohai_time"] = "Undefined";
|
|
104
|
-
}
|
|
105
|
-
if (doc["attributes"]["uptime"]) {
|
|
106
|
-
to_emit["uptime"] = doc["attributes"]["uptime"];
|
|
107
|
-
} else {
|
|
108
|
-
to_emit["uptime"] = "Undefined";
|
|
109
|
-
}
|
|
110
|
-
if (doc["attributes"]["platform"]) {
|
|
111
|
-
to_emit["platform"] = doc["attributes"]["platform"];
|
|
112
|
-
} else {
|
|
113
|
-
to_emit["platform"] = "Undefined";
|
|
114
|
-
}
|
|
115
|
-
if (doc["attributes"]["platform_version"]) {
|
|
116
|
-
to_emit["platform_version"] = doc["attributes"]["platform_version"];
|
|
117
|
-
} else {
|
|
118
|
-
to_emit["platform_version"] = "Undefined";
|
|
119
|
-
}
|
|
120
|
-
if (doc["run_list"]) {
|
|
121
|
-
to_emit["run_list"] = doc["run_list"];
|
|
122
|
-
} else {
|
|
123
|
-
to_emit["run_list"] = "Undefined";
|
|
124
|
-
}
|
|
125
|
-
emit(doc.name, to_emit);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
EOJS
|
|
129
|
-
},
|
|
130
|
-
"by_run_list" => {
|
|
131
|
-
"map" => <<-EOJS
|
|
132
|
-
function(doc) {
|
|
133
|
-
if (doc.chef_type == "node") {
|
|
134
|
-
if (doc['run_list']) {
|
|
135
|
-
for (var i=0; i < doc.run_list.length; i++) {
|
|
136
|
-
emit(doc['run_list'][i], doc.name);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
EOJS
|
|
142
|
-
},
|
|
143
|
-
"by_environment" => {
|
|
144
|
-
"map" => <<-EOJS
|
|
145
|
-
function(doc) {
|
|
146
|
-
if (doc.chef_type == "node") {
|
|
147
|
-
var env = (doc['chef_environment'] == null ? "_default" : doc['chef_environment']);
|
|
148
|
-
emit(env, doc.name);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
EOJS
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
}
|
|
155
62
|
|
|
156
63
|
# Create a new Chef::Node object.
|
|
157
|
-
def initialize
|
|
64
|
+
def initialize
|
|
158
65
|
@name = nil
|
|
159
66
|
|
|
160
67
|
@chef_environment = '_default'
|
|
161
|
-
@normal_attrs = Mash.new
|
|
162
|
-
@override_attrs = Mash.new
|
|
163
|
-
@default_attrs = Mash.new
|
|
164
|
-
@automatic_attrs = Mash.new
|
|
165
68
|
@run_list = Chef::RunList.new
|
|
166
69
|
|
|
167
|
-
@
|
|
168
|
-
@couchdb_id = nil
|
|
169
|
-
@couchdb = couchdb || Chef::CouchDB.new
|
|
170
|
-
|
|
171
|
-
@run_state = {
|
|
172
|
-
:template_cache => Hash.new,
|
|
173
|
-
:seen_recipes => Hash.new,
|
|
174
|
-
:seen_attributes => Hash.new
|
|
175
|
-
}
|
|
176
|
-
# TODO: 5/20/2010 need this here as long as other objects try to access
|
|
177
|
-
# the cookbook collection via Node, otherwise get NoMethodError on nil.
|
|
178
|
-
@cookbook_collection = CookbookCollection.new
|
|
179
|
-
end
|
|
70
|
+
@attributes = Chef::Node::Attribute.new({}, {}, {}, {})
|
|
180
71
|
|
|
181
|
-
|
|
182
|
-
@couchdb_id = value
|
|
183
|
-
@index_id = value
|
|
72
|
+
@run_state = {}
|
|
184
73
|
end
|
|
185
74
|
|
|
186
75
|
# Used by DSL
|
|
@@ -192,24 +81,6 @@ class Chef
|
|
|
192
81
|
Chef::REST.new(Chef::Config[:chef_server_url])
|
|
193
82
|
end
|
|
194
83
|
|
|
195
|
-
# Find a recipe for this Chef::Node by fqdn. Will search first for
|
|
196
|
-
# Chef::Config["node_path"]/fqdn.rb, then hostname.rb, then default.rb.
|
|
197
|
-
#
|
|
198
|
-
# Returns a new Chef::Node object.
|
|
199
|
-
#
|
|
200
|
-
# Raises an ArgumentError if it cannot find the node.
|
|
201
|
-
def find_file(fqdn)
|
|
202
|
-
host_parts = fqdn.split(".")
|
|
203
|
-
hostname = host_parts[0]
|
|
204
|
-
|
|
205
|
-
[fqdn, hostname, "default"].each { |fname|
|
|
206
|
-
node_file = File.join(Chef::Config[:node_path], "#{fname.to_s}.rb")
|
|
207
|
-
return self.from_file(node_file) if File.exists?(node_file)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
raise ArgumentError, "Cannot find a node matching #{fqdn}, not even with default.rb!"
|
|
211
|
-
end
|
|
212
|
-
|
|
213
84
|
# Set the name of this Node, or return the current name.
|
|
214
85
|
def name(arg=nil)
|
|
215
86
|
if arg != nil
|
|
@@ -233,91 +104,109 @@ class Chef
|
|
|
233
104
|
)
|
|
234
105
|
end
|
|
235
106
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
construct_attributes
|
|
107
|
+
def chef_environment=(environment)
|
|
108
|
+
chef_environment(environment)
|
|
239
109
|
end
|
|
240
110
|
|
|
241
|
-
|
|
242
|
-
Chef::Node::Attribute.new(normal_attrs, default_attrs, override_attrs, automatic_attrs)
|
|
243
|
-
end
|
|
111
|
+
alias :environment :chef_environment
|
|
244
112
|
|
|
245
|
-
def
|
|
246
|
-
|
|
113
|
+
def attributes
|
|
114
|
+
@attributes
|
|
247
115
|
end
|
|
248
116
|
|
|
117
|
+
alias :attribute :attributes
|
|
118
|
+
alias :construct_attributes :attributes
|
|
119
|
+
|
|
249
120
|
# Return an attribute of this node. Returns nil if the attribute is not found.
|
|
250
121
|
def [](attrib)
|
|
251
|
-
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
# Set an attribute of this node
|
|
255
|
-
def []=(attrib, value)
|
|
256
|
-
construct_attributes[attrib] = value
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
def store(attrib, value)
|
|
260
|
-
self[attrib] = value
|
|
122
|
+
attributes[attrib]
|
|
261
123
|
end
|
|
262
124
|
|
|
263
|
-
# Set a normal attribute of this node, but auto-
|
|
125
|
+
# Set a normal attribute of this node, but auto-vivify any Mashes that
|
|
264
126
|
# might be missing
|
|
265
127
|
def normal
|
|
266
|
-
|
|
267
|
-
attrs.set_type = :normal
|
|
268
|
-
attrs.auto_vivifiy_on_read = true
|
|
269
|
-
attrs
|
|
128
|
+
attributes.normal
|
|
270
129
|
end
|
|
271
130
|
|
|
272
131
|
alias_method :set, :normal
|
|
273
132
|
|
|
274
|
-
# Set a normal attribute of this node, auto-
|
|
133
|
+
# Set a normal attribute of this node, auto-vivifying any mashes that are
|
|
275
134
|
# missing, but if the final value already exists, don't set it
|
|
276
135
|
def normal_unless
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
attrs.auto_vivifiy_on_read = true
|
|
280
|
-
attrs.set_unless_value_present = true
|
|
281
|
-
attrs
|
|
136
|
+
attributes.set_unless_value_present = true
|
|
137
|
+
attributes.normal
|
|
282
138
|
end
|
|
283
139
|
alias_method :set_unless, :normal_unless
|
|
284
140
|
|
|
285
|
-
# Set a default of this node, but auto-
|
|
141
|
+
# Set a default of this node, but auto-vivify any Mashes that might
|
|
286
142
|
# be missing
|
|
287
143
|
def default
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
144
|
+
attributes.default
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Set a force default attribute. Intermediate mashes will be created by
|
|
148
|
+
# auto-vivify if necessary.
|
|
149
|
+
def default!
|
|
150
|
+
attributes.default!
|
|
292
151
|
end
|
|
293
152
|
|
|
294
|
-
# Set a default attribute of this node, auto-
|
|
153
|
+
# Set a default attribute of this node, auto-vivifying any mashes that are
|
|
295
154
|
# missing, but if the final value already exists, don't set it
|
|
296
155
|
def default_unless
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
attrs.auto_vivifiy_on_read = true
|
|
300
|
-
attrs.set_unless_value_present = true
|
|
301
|
-
attrs
|
|
156
|
+
attributes.set_unless_value_present = true
|
|
157
|
+
attributes.default
|
|
302
158
|
end
|
|
303
159
|
|
|
304
|
-
# Set an override attribute of this node, but auto-
|
|
160
|
+
# Set an override attribute of this node, but auto-vivify any Mashes that
|
|
305
161
|
# might be missing
|
|
306
162
|
def override
|
|
307
|
-
|
|
308
|
-
attrs.set_type = :override
|
|
309
|
-
attrs.auto_vivifiy_on_read = true
|
|
310
|
-
attrs
|
|
163
|
+
attributes.override
|
|
311
164
|
end
|
|
312
165
|
|
|
313
|
-
# Set
|
|
166
|
+
# Set a force override attribute. Intermediate mashes will be created by
|
|
167
|
+
# auto-vivify if needed.
|
|
168
|
+
def override!
|
|
169
|
+
attributes.override!
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Set an override attribute of this node, auto-vivifying any mashes that
|
|
314
173
|
# are missing, but if the final value already exists, don't set it
|
|
315
174
|
def override_unless
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
175
|
+
attributes.set_unless_value_present = true
|
|
176
|
+
attributes.override
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def override_attrs
|
|
181
|
+
attributes.override
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def override_attrs=(new_values)
|
|
185
|
+
attributes.override = new_values
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def default_attrs
|
|
189
|
+
attributes.default
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def default_attrs=(new_values)
|
|
193
|
+
attributes.default = new_values
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def normal_attrs
|
|
197
|
+
attributes.normal
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def normal_attrs=(new_values)
|
|
201
|
+
attributes.normal = new_values
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def automatic_attrs
|
|
205
|
+
attributes.automatic
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def automatic_attrs=(new_values)
|
|
209
|
+
attributes.automatic = new_values
|
|
321
210
|
end
|
|
322
211
|
|
|
323
212
|
# Return true if this Node has a given attribute, false if not. Takes either a symbol or
|
|
@@ -326,36 +215,33 @@ class Chef
|
|
|
326
215
|
# Only works on the top level. Preferred way is to use the normal [] style
|
|
327
216
|
# lookup and call attribute?()
|
|
328
217
|
def attribute?(attrib)
|
|
329
|
-
|
|
218
|
+
attributes.attribute?(attrib)
|
|
330
219
|
end
|
|
331
220
|
|
|
332
221
|
# Yield each key of the top level to the block.
|
|
333
222
|
def each(&block)
|
|
334
|
-
|
|
223
|
+
attributes.each(&block)
|
|
335
224
|
end
|
|
336
225
|
|
|
337
226
|
# Iterates over each attribute, passing the attribute and value to the block.
|
|
338
227
|
def each_attribute(&block)
|
|
339
|
-
|
|
228
|
+
attributes.each_attribute(&block)
|
|
340
229
|
end
|
|
341
230
|
|
|
342
|
-
#
|
|
343
|
-
# as using the normal/default/override interface.
|
|
231
|
+
# Only works for attribute fetches, setting is no longer supported
|
|
344
232
|
def method_missing(symbol, *args)
|
|
345
|
-
|
|
346
|
-
attrs.send(symbol, *args)
|
|
233
|
+
attributes.send(symbol, *args)
|
|
347
234
|
end
|
|
348
235
|
|
|
349
236
|
# Returns true if this Node expects a given recipe, false if not.
|
|
350
237
|
#
|
|
351
238
|
# First, the run list is consulted to see whether the recipe is
|
|
352
239
|
# explicitly included. If it's not there, it looks in
|
|
353
|
-
#
|
|
354
|
-
# statements in the DSL (and thus would not be in the run list).
|
|
240
|
+
# `node[:recipes]`, which is populated when the run_list is expanded
|
|
355
241
|
#
|
|
356
242
|
# NOTE: It's used by cookbook authors
|
|
357
243
|
def recipe?(recipe_name)
|
|
358
|
-
run_list.include?(recipe_name) ||
|
|
244
|
+
run_list.include?(recipe_name) || Array(self[:recipes]).include?(recipe_name)
|
|
359
245
|
end
|
|
360
246
|
|
|
361
247
|
# Returns true if this Node expects a given role, false if not.
|
|
@@ -379,26 +265,26 @@ class Chef
|
|
|
379
265
|
Chef::Log.debug("Extracting run list from JSON attributes provided on command line")
|
|
380
266
|
consume_attributes(json_cli_attrs)
|
|
381
267
|
|
|
382
|
-
|
|
268
|
+
self.automatic_attrs = ohai_data
|
|
383
269
|
|
|
384
270
|
platform, version = Chef::Platform.find_platform_and_version(self)
|
|
385
271
|
Chef::Log.debug("Platform is #{platform} version #{version}")
|
|
386
|
-
|
|
387
|
-
|
|
272
|
+
self.automatic[:platform] = platform
|
|
273
|
+
self.automatic[:platform_version] = version
|
|
388
274
|
end
|
|
389
275
|
|
|
390
276
|
# Consumes the combined run_list and other attributes in +attrs+
|
|
391
277
|
def consume_attributes(attrs)
|
|
392
278
|
normal_attrs_to_merge = consume_run_list(attrs)
|
|
393
279
|
Chef::Log.debug("Applying attributes from json file")
|
|
394
|
-
|
|
280
|
+
self.normal_attrs = Chef::Mixin::DeepMerge.merge(normal_attrs,normal_attrs_to_merge)
|
|
395
281
|
self.tags # make sure they're defined
|
|
396
282
|
end
|
|
397
283
|
|
|
398
284
|
# Lazy initializer for tags attribute
|
|
399
285
|
def tags
|
|
400
|
-
|
|
401
|
-
|
|
286
|
+
normal[:tags] = [] unless attribute?(:tags)
|
|
287
|
+
normal[:tags]
|
|
402
288
|
end
|
|
403
289
|
|
|
404
290
|
# Extracts the run list from +attrs+ and applies it. Returns the remaining attributes
|
|
@@ -417,8 +303,8 @@ class Chef
|
|
|
417
303
|
# Clear defaults and overrides, so that any deleted attributes
|
|
418
304
|
# between runs are still gone.
|
|
419
305
|
def reset_defaults_and_overrides
|
|
420
|
-
|
|
421
|
-
|
|
306
|
+
self.default.clear
|
|
307
|
+
self.override.clear
|
|
422
308
|
end
|
|
423
309
|
|
|
424
310
|
# Expands the node's run list and sets the default and override
|
|
@@ -439,8 +325,10 @@ class Chef
|
|
|
439
325
|
|
|
440
326
|
self.tags # make sure they're defined
|
|
441
327
|
|
|
442
|
-
|
|
443
|
-
|
|
328
|
+
automatic_attrs[:recipes] = expansion.recipes
|
|
329
|
+
automatic_attrs[:roles] = expansion.roles
|
|
330
|
+
|
|
331
|
+
apply_expansion_attributes(expansion)
|
|
444
332
|
|
|
445
333
|
expansion
|
|
446
334
|
end
|
|
@@ -448,13 +336,17 @@ class Chef
|
|
|
448
336
|
# Apply the default and overrides attributes from the expansion
|
|
449
337
|
# passed in, which came from roles.
|
|
450
338
|
def apply_expansion_attributes(expansion)
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
339
|
+
loaded_environment = if chef_environment == "_default"
|
|
340
|
+
Chef::Environment.new.tap {|e| e.name("_default")}
|
|
341
|
+
else
|
|
342
|
+
Chef::Environment.load(chef_environment)
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
attributes.env_default = loaded_environment.default_attributes
|
|
346
|
+
attributes.env_override = loaded_environment.override_attributes
|
|
347
|
+
|
|
348
|
+
attribute.role_default = expansion.default_attrs
|
|
349
|
+
attributes.role_override = expansion.override_attrs
|
|
458
350
|
end
|
|
459
351
|
|
|
460
352
|
# Transform the node to a Hash
|
|
@@ -478,36 +370,39 @@ class Chef
|
|
|
478
370
|
display["chef_environment"] = chef_environment
|
|
479
371
|
display["automatic"] = automatic_attrs
|
|
480
372
|
display["normal"] = normal_attrs
|
|
481
|
-
display["default"] =
|
|
482
|
-
display["override"] =
|
|
373
|
+
display["default"] = attributes.combined_default
|
|
374
|
+
display["override"] = attributes.combined_override
|
|
483
375
|
display["run_list"] = run_list.run_list
|
|
484
376
|
display
|
|
485
377
|
end
|
|
486
378
|
|
|
487
379
|
# Serialize this object as a hash
|
|
488
380
|
def to_json(*a)
|
|
381
|
+
for_json.to_json(*a)
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def for_json
|
|
489
385
|
result = {
|
|
490
386
|
"name" => name,
|
|
491
387
|
"chef_environment" => chef_environment,
|
|
492
388
|
'json_class' => self.class.name,
|
|
493
|
-
"automatic" =>
|
|
494
|
-
"normal" =>
|
|
389
|
+
"automatic" => attributes.automatic,
|
|
390
|
+
"normal" => attributes.normal,
|
|
495
391
|
"chef_type" => "node",
|
|
496
|
-
"default" =>
|
|
497
|
-
"override" =>
|
|
392
|
+
"default" => attributes.combined_default,
|
|
393
|
+
"override" => attributes.combined_override,
|
|
498
394
|
#Render correctly for run_list items so malformed json does not result
|
|
499
395
|
"run_list" => run_list.run_list.map { |item| item.to_s }
|
|
500
396
|
}
|
|
501
|
-
result
|
|
502
|
-
result.to_json(*a)
|
|
397
|
+
result
|
|
503
398
|
end
|
|
504
399
|
|
|
505
400
|
def update_from!(o)
|
|
506
401
|
run_list.reset!(o.run_list)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
402
|
+
self.automatic_attrs = o.automatic_attrs
|
|
403
|
+
self.normal_attrs = o.normal_attrs
|
|
404
|
+
self.override_attrs = o.override_attrs
|
|
405
|
+
self.default_attrs = o.default_attrs
|
|
511
406
|
chef_environment(o.chef_environment)
|
|
512
407
|
self
|
|
513
408
|
end
|
|
@@ -530,17 +425,9 @@ class Chef
|
|
|
530
425
|
else
|
|
531
426
|
o["recipes"].each { |r| node.recipes << r }
|
|
532
427
|
end
|
|
533
|
-
node.couchdb_rev = o["_rev"] if o.has_key?("_rev")
|
|
534
|
-
node.couchdb_id = o["_id"] if o.has_key?("_id")
|
|
535
|
-
node.index_id = node.couchdb_id
|
|
536
428
|
node
|
|
537
429
|
end
|
|
538
430
|
|
|
539
|
-
def self.cdb_list_by_environment(environment, inflate=false, couchdb=nil)
|
|
540
|
-
rs = (couchdb || Chef::CouchDB.new).get_view("nodes", "by_environment", :include_docs => inflate, :startkey => environment, :endkey => environment)
|
|
541
|
-
inflate ? rs["rows"].collect {|r| r["doc"]} : rs["rows"].collect {|r| r["value"]}
|
|
542
|
-
end
|
|
543
|
-
|
|
544
431
|
def self.list_by_environment(environment, inflate=false)
|
|
545
432
|
if inflate
|
|
546
433
|
response = Hash.new
|
|
@@ -551,14 +438,6 @@ class Chef
|
|
|
551
438
|
end
|
|
552
439
|
end
|
|
553
440
|
|
|
554
|
-
# List all the Chef::Node objects in the CouchDB. If inflate is set to true, you will get
|
|
555
|
-
# the full list of all Nodes, fully inflated.
|
|
556
|
-
def self.cdb_list(inflate=false, couchdb=nil)
|
|
557
|
-
rs =(couchdb || Chef::CouchDB.new).list("nodes", inflate)
|
|
558
|
-
lookup = (inflate ? "value" : "key")
|
|
559
|
-
rs["rows"].collect { |r| r[lookup] }
|
|
560
|
-
end
|
|
561
|
-
|
|
562
441
|
def self.list(inflate=false)
|
|
563
442
|
if inflate
|
|
564
443
|
response = Hash.new
|
|
@@ -571,19 +450,6 @@ class Chef
|
|
|
571
450
|
end
|
|
572
451
|
end
|
|
573
452
|
|
|
574
|
-
# Load a node by name from CouchDB
|
|
575
|
-
def self.cdb_load(name, couchdb=nil)
|
|
576
|
-
(couchdb || Chef::CouchDB.new).load("node", name)
|
|
577
|
-
end
|
|
578
|
-
|
|
579
|
-
def self.exists?(nodename, couchdb)
|
|
580
|
-
begin
|
|
581
|
-
self.cdb_load(nodename, couchdb)
|
|
582
|
-
rescue Chef::Exceptions::CouchDBNotFound
|
|
583
|
-
nil
|
|
584
|
-
end
|
|
585
|
-
end
|
|
586
|
-
|
|
587
453
|
def self.find_or_create(node_name)
|
|
588
454
|
load(node_name)
|
|
589
455
|
rescue Net::HTTPServerException => e
|
|
@@ -595,7 +461,7 @@ class Chef
|
|
|
595
461
|
def self.build(node_name)
|
|
596
462
|
node = new
|
|
597
463
|
node.name(node_name)
|
|
598
|
-
node.chef_environment(Chef::Config[:environment]) unless Chef::Config[:environment].nil? || Chef::Config[:environment].
|
|
464
|
+
node.chef_environment(Chef::Config[:environment]) unless Chef::Config[:environment].nil? || Chef::Config[:environment].chop.empty?
|
|
599
465
|
node
|
|
600
466
|
end
|
|
601
467
|
|
|
@@ -604,21 +470,11 @@ class Chef
|
|
|
604
470
|
Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("nodes/#{name}")
|
|
605
471
|
end
|
|
606
472
|
|
|
607
|
-
# Remove this node from the CouchDB
|
|
608
|
-
def cdb_destroy
|
|
609
|
-
couchdb.delete("node", name, couchdb_rev)
|
|
610
|
-
end
|
|
611
|
-
|
|
612
473
|
# Remove this node via the REST API
|
|
613
474
|
def destroy
|
|
614
475
|
chef_server_rest.delete_rest("nodes/#{name}")
|
|
615
476
|
end
|
|
616
477
|
|
|
617
|
-
# Save this node to the CouchDB
|
|
618
|
-
def cdb_save
|
|
619
|
-
@couchdb_rev = couchdb.store("node", name, self)["rev"]
|
|
620
|
-
end
|
|
621
|
-
|
|
622
478
|
# Save this node via the REST API
|
|
623
479
|
def save
|
|
624
480
|
# Try PUT. If the node doesn't yet exist, PUT will return 404,
|
|
@@ -642,41 +498,9 @@ class Chef
|
|
|
642
498
|
self
|
|
643
499
|
end
|
|
644
500
|
|
|
645
|
-
# Set up our CouchDB design document
|
|
646
|
-
def self.create_design_document(couchdb=nil)
|
|
647
|
-
(couchdb || Chef::CouchDB.new).create_design_document("nodes", DESIGN_DOCUMENT)
|
|
648
|
-
end
|
|
649
|
-
|
|
650
501
|
def to_s
|
|
651
502
|
"node[#{name}]"
|
|
652
503
|
end
|
|
653
504
|
|
|
654
|
-
# Load all attribute files for all cookbooks associated with this
|
|
655
|
-
# node.
|
|
656
|
-
def load_attributes
|
|
657
|
-
cookbook_collection.values.each do |cookbook|
|
|
658
|
-
cookbook.segment_filenames(:attributes).each do |segment_filename|
|
|
659
|
-
Chef::Log.debug("Node #{name} loading cookbook #{cookbook.name}'s attribute file #{segment_filename}")
|
|
660
|
-
self.from_file(segment_filename)
|
|
661
|
-
end
|
|
662
|
-
end
|
|
663
|
-
end
|
|
664
|
-
|
|
665
|
-
# Used by DSL.
|
|
666
|
-
# Loads the attribute file specified by the short name of the
|
|
667
|
-
# file, e.g., loads specified cookbook's
|
|
668
|
-
# "attributes/mailservers.rb"
|
|
669
|
-
# if passed
|
|
670
|
-
# "mailservers"
|
|
671
|
-
def load_attribute_by_short_filename(name, src_cookbook_name)
|
|
672
|
-
src_cookbook = cookbook_collection[src_cookbook_name]
|
|
673
|
-
raise Chef::Exceptions::CookbookNotFound, "could not find cookbook #{src_cookbook_name} while loading attribute #{name}" unless src_cookbook
|
|
674
|
-
|
|
675
|
-
attribute_filename = src_cookbook.attribute_filenames_by_short_filename[name]
|
|
676
|
-
raise Chef::Exceptions::AttributeNotFound, "could not find filename for attribute #{name} in cookbook #{src_cookbook_name}" unless attribute_filename
|
|
677
|
-
|
|
678
|
-
self.from_file(attribute_filename)
|
|
679
|
-
self
|
|
680
|
-
end
|
|
681
505
|
end
|
|
682
506
|
end
|