chef 10.34.6 → 11.0.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/chef_fs'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
module ChefFS
|
23
|
+
class PathUtils
|
24
|
+
|
25
|
+
# If you are in 'source', this is what you would have to type to reach 'dest'
|
26
|
+
# relative_to('/a/b/c/d/e', '/a/b/x/y') == '../../c/d/e'
|
27
|
+
# relative_to('/a/b', '/a/b') == ''
|
28
|
+
def self.relative_to(dest, source)
|
29
|
+
# Skip past the common parts
|
30
|
+
source_parts = Chef::ChefFS::PathUtils.split(source)
|
31
|
+
dest_parts = Chef::ChefFS::PathUtils.split(dest)
|
32
|
+
i = 0
|
33
|
+
until i >= source_parts.length || i >= dest_parts.length || source_parts[i] != source_parts[i]
|
34
|
+
i+=1
|
35
|
+
end
|
36
|
+
# dot-dot up from 'source' to the common ancestor, then
|
37
|
+
# descend to 'dest' from the common ancestor
|
38
|
+
result = Chef::ChefFS::PathUtils.join(*(['..']*(source_parts.length-i) + dest_parts[i,dest.length-i]))
|
39
|
+
result == '' ? '.' : result
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.join(*parts)
|
43
|
+
return "" if parts.length == 0
|
44
|
+
# Determine if it started with a slash
|
45
|
+
absolute = parts[0].length == 0 || parts[0].length > 0 && parts[0] =~ /^#{regexp_path_separator}/
|
46
|
+
# Remove leading and trailing slashes from each part so that the join will work (and the slash at the end will go away)
|
47
|
+
parts = parts.map { |part| part.gsub(/^\/|\/$/, "") }
|
48
|
+
# Don't join empty bits
|
49
|
+
result = parts.select { |part| part != "" }.join("/")
|
50
|
+
# Put the / back on
|
51
|
+
absolute ? "/#{result}" : result
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.split(path)
|
55
|
+
path.split(Regexp.new(regexp_path_separator))
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.regexp_path_separator
|
59
|
+
Chef::ChefFS::windows? ? '[/\\]' : '/'
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/chef/client.rb
CHANGED
@@ -24,6 +24,7 @@ require 'chef/mixin/path_sanity'
|
|
24
24
|
require 'chef/log'
|
25
25
|
require 'chef/rest'
|
26
26
|
require 'chef/api_client'
|
27
|
+
require 'chef/api_client/registration'
|
27
28
|
require 'chef/platform'
|
28
29
|
require 'chef/node'
|
29
30
|
require 'chef/role'
|
@@ -41,6 +42,7 @@ require 'chef/formatters/doc'
|
|
41
42
|
require 'chef/formatters/minimal'
|
42
43
|
require 'chef/version'
|
43
44
|
require 'chef/resource_reporter'
|
45
|
+
require 'chef/run_lock'
|
44
46
|
require 'ohai'
|
45
47
|
require 'rbconfig'
|
46
48
|
|
@@ -127,9 +129,9 @@ class Chef
|
|
127
129
|
#--
|
128
130
|
# TODO: timh/cw: 5-19-2010: json_attribs should be moved to RunContext?
|
129
131
|
attr_reader :json_attribs
|
130
|
-
|
131
132
|
attr_reader :run_status
|
132
|
-
|
133
|
+
attr_reader :events
|
134
|
+
|
133
135
|
# Creates a new Chef::Client.
|
134
136
|
def initialize(json_attribs=nil, args={})
|
135
137
|
@json_attribs = json_attribs
|
@@ -138,15 +140,6 @@ class Chef
|
|
138
140
|
@runner = nil
|
139
141
|
@ohai = Ohai::System.new
|
140
142
|
|
141
|
-
# If we want why-run output and user hasn't explicitly specified a format
|
142
|
-
# we need to use a formatter that will render whyrun output.
|
143
|
-
if Chef::Config.why_run
|
144
|
-
if Chef::Config.formatter == "null"
|
145
|
-
Chef::Log.warn("Forcing formatter of 'doc' to capture whyrun output.")
|
146
|
-
Chef::Config[:formatter] = 'doc'
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
143
|
event_handlers = configure_formatters
|
151
144
|
event_handlers += Array(Chef::Config[:event_handlers])
|
152
145
|
|
@@ -156,18 +149,42 @@ class Chef
|
|
156
149
|
end
|
157
150
|
|
158
151
|
def configure_formatters
|
159
|
-
|
152
|
+
formatters_for_run.map do |formatter_name, output_path|
|
153
|
+
if output_path.nil?
|
154
|
+
Chef::Formatters.new(formatter_name, STDOUT, STDERR)
|
155
|
+
else
|
156
|
+
io = File.open(output_path, "a+")
|
157
|
+
io.sync = true
|
158
|
+
Chef::Formatters.new(formatter_name, io, io)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def formatters_for_run
|
164
|
+
if Chef::Config.formatters.empty?
|
165
|
+
[default_formatter]
|
166
|
+
else
|
167
|
+
Chef::Config.formatters
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def default_formatter
|
172
|
+
if (STDOUT.tty? && !Chef::Config[:force_logger]) || Chef::Config[:force_formatter]
|
173
|
+
[:doc]
|
174
|
+
else
|
175
|
+
[:null]
|
176
|
+
end
|
160
177
|
end
|
161
178
|
|
162
179
|
# Do a full run for this Chef::Client. Calls:
|
163
180
|
# * do_run
|
164
181
|
#
|
165
|
-
# This provides a wrapper around #do_run allowing the
|
182
|
+
# This provides a wrapper around #do_run allowing the
|
166
183
|
# run to be optionally forked.
|
167
184
|
# === Returns
|
168
185
|
# boolean:: Return value from #do_run. Should always returns true.
|
169
186
|
def run
|
170
|
-
if(Chef::Config[:client_fork] && Process.respond_to?(:fork)
|
187
|
+
if(Chef::Config[:client_fork] && Process.respond_to?(:fork))
|
171
188
|
Chef::Log.info "Forking chef instance to converge..."
|
172
189
|
pid = fork do
|
173
190
|
Chef::Log.info "Forked instance now converging"
|
@@ -192,7 +209,9 @@ class Chef
|
|
192
209
|
def setup_run_context
|
193
210
|
if Chef::Config[:solo]
|
194
211
|
Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, Chef::Config[:cookbook_path]) }
|
195
|
-
|
212
|
+
cl = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
|
213
|
+
cl.load_cookbooks
|
214
|
+
cookbook_collection = Chef::CookbookCollection.new(cl)
|
196
215
|
run_context = Chef::RunContext.new(node, cookbook_collection, @events)
|
197
216
|
else
|
198
217
|
Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::RemoteFileVendor.new(manifest, rest) }
|
@@ -212,7 +231,7 @@ class Chef
|
|
212
231
|
Chef::Log.debug("Saving the current state of node #{node_name}")
|
213
232
|
if(@original_runlist)
|
214
233
|
@node.run_list(*@original_runlist)
|
215
|
-
@node.
|
234
|
+
@node.automatic_attrs[:runlist_override_history] = {Time.now.to_i => @override_runlist.inspect}
|
216
235
|
end
|
217
236
|
@node.save
|
218
237
|
end
|
@@ -248,7 +267,7 @@ class Chef
|
|
248
267
|
def build_node
|
249
268
|
# Allow user to override the environment of a node by specifying
|
250
269
|
# a config parameter.
|
251
|
-
if Chef::Config[:environment] && !Chef::Config[:environment].
|
270
|
+
if Chef::Config[:environment] && !Chef::Config[:environment].chop.empty?
|
252
271
|
@node.chef_environment(Chef::Config[:environment])
|
253
272
|
end
|
254
273
|
|
@@ -329,7 +348,7 @@ class Chef
|
|
329
348
|
else
|
330
349
|
@events.registration_start(node_name, config)
|
331
350
|
Chef::Log.info("Client key #{config[:client_key]} is not present - registering")
|
332
|
-
Chef::
|
351
|
+
Chef::ApiClient::Registration.new(node_name, config[:client_key]).run
|
333
352
|
@events.registration_completed
|
334
353
|
end
|
335
354
|
# We now have the client key, and should use it from now on.
|
@@ -385,7 +404,7 @@ class Chef
|
|
385
404
|
runner.converge
|
386
405
|
@events.converge_complete
|
387
406
|
true
|
388
|
-
rescue Exception
|
407
|
+
rescue Exception
|
389
408
|
# TODO: should this be a separate #converge_failed(exception) method?
|
390
409
|
@events.converge_complete
|
391
410
|
raise
|
@@ -404,8 +423,10 @@ class Chef
|
|
404
423
|
# === Returns
|
405
424
|
# true:: Always returns true.
|
406
425
|
def do_run
|
407
|
-
|
426
|
+
runlock = RunLock.new(Chef::Config)
|
427
|
+
runlock.acquire
|
408
428
|
|
429
|
+
run_context = nil
|
409
430
|
@events.run_start(Chef::VERSION)
|
410
431
|
Chef::Log.info("*** Chef #{Chef::VERSION} ***")
|
411
432
|
enforce_path_sanity
|
@@ -445,8 +466,9 @@ class Chef
|
|
445
466
|
@events.run_failed(e)
|
446
467
|
raise
|
447
468
|
ensure
|
448
|
-
run_status = nil
|
469
|
+
@run_status = nil
|
449
470
|
run_context = nil
|
471
|
+
runlock.release
|
450
472
|
GC.start
|
451
473
|
end
|
452
474
|
true
|
@@ -503,3 +525,4 @@ end
|
|
503
525
|
require 'chef/cookbook_loader'
|
504
526
|
require 'chef/cookbook_version'
|
505
527
|
require 'chef/cookbook/synchronizer'
|
528
|
+
|
data/lib/chef/config.rb
CHANGED
@@ -48,9 +48,6 @@ class Chef
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.platform_specific_path(path)
|
51
|
-
#10.times { puts "* " * 40}
|
52
|
-
#pp caller
|
53
|
-
|
54
51
|
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
55
52
|
# turns /etc/chef/client.rb into C:/chef/client.rb
|
56
53
|
system_drive = ENV['SYSTEMDRIVE'] ? ENV['SYSTEMDRIVE'] : ""
|
@@ -61,6 +58,14 @@ class Chef
|
|
61
58
|
path
|
62
59
|
end
|
63
60
|
|
61
|
+
def self.add_formatter(name, file_path=nil)
|
62
|
+
formatters << [name, file_path]
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.formatters
|
66
|
+
@formatters ||= []
|
67
|
+
end
|
68
|
+
|
64
69
|
# Override the config dispatch to set the value of multiple server options simultaneously
|
65
70
|
#
|
66
71
|
# === Parameters
|
@@ -104,7 +109,7 @@ class Chef
|
|
104
109
|
begin
|
105
110
|
f = File.new(location.to_str, "a")
|
106
111
|
f.sync = true
|
107
|
-
rescue Errno::ENOENT
|
112
|
+
rescue Errno::ENOENT
|
108
113
|
raise Chef::Exceptions::ConfigurationError("Failed to open or create log file at #{location.to_str}")
|
109
114
|
end
|
110
115
|
f
|
@@ -130,8 +135,6 @@ class Chef
|
|
130
135
|
# Used when OpenID authentication is enabled in the Web UI
|
131
136
|
authorized_openid_identifiers nil
|
132
137
|
authorized_openid_providers nil
|
133
|
-
openid_cstore_couchdb false
|
134
|
-
openid_cstore_path "/var/chef/openid/cstore"
|
135
138
|
|
136
139
|
# The number of times the client should retry when registering with the server
|
137
140
|
client_registration_retries 5
|
@@ -150,29 +153,51 @@ class Chef
|
|
150
153
|
# Where cookbook files are stored on the server (by content checksum)
|
151
154
|
checksum_path "/var/chef/checksums"
|
152
155
|
|
153
|
-
# CouchDB database name to use
|
154
|
-
couchdb_database "chef"
|
155
|
-
|
156
|
-
couchdb_url "http://localhost:5984"
|
157
|
-
|
158
156
|
# Where chef's cache files should be stored
|
159
157
|
file_cache_path platform_specific_path("/var/chef/cache")
|
160
158
|
|
159
|
+
# By default, chef-client (or solo) creates a lockfile in
|
160
|
+
# `file_cache_path`/chef-client-running.pid
|
161
|
+
# If `lockfile` is explicitly set, this path will be used instead.
|
162
|
+
#
|
163
|
+
# If your `file_cache_path` resides on a NFS (or non-flock()-supporting
|
164
|
+
# fs), it's recommended to set this to something like
|
165
|
+
# '/tmp/chef-client-running.pid'
|
166
|
+
lockfile nil
|
167
|
+
|
161
168
|
# Where backups of chef-managed files should go
|
162
169
|
file_backup_path platform_specific_path("/var/chef/backup")
|
163
170
|
|
164
171
|
## Daemonization Settings ##
|
165
172
|
# What user should Chef run as?
|
166
173
|
user nil
|
167
|
-
# What group should the chef-server, -solr, -solr-indexer run as
|
168
174
|
group nil
|
169
175
|
umask 0022
|
170
176
|
|
177
|
+
|
178
|
+
# Valid log_levels are:
|
179
|
+
# * :debug
|
180
|
+
# * :info
|
181
|
+
# * :warn
|
182
|
+
# * :fatal
|
183
|
+
# These work as you'd expect. There is also a special `:auto` setting.
|
184
|
+
# When set to :auto, Chef will auto adjust the log verbosity based on
|
185
|
+
# context. When a tty is available (usually becase the user is running chef
|
186
|
+
# in a console), the log level is set to :warn, and output formatters are
|
187
|
+
# used as the primary mode of output. When a tty is not available, the
|
188
|
+
# logger is the primary mode of output, and the log level is set to :info
|
189
|
+
log_level :auto
|
190
|
+
|
191
|
+
# Using `force_formatter` causes chef to default to formatter output when STDOUT is not a tty
|
192
|
+
force_formatter false
|
193
|
+
|
194
|
+
# Using `force_logger` causes chef to default to logger output when STDOUT is a tty
|
195
|
+
force_logger false
|
196
|
+
|
171
197
|
http_retry_count 5
|
172
198
|
http_retry_delay 5
|
173
199
|
interval nil
|
174
200
|
json_attribs nil
|
175
|
-
log_level :info
|
176
201
|
log_location STDOUT
|
177
202
|
# toggle info level log items that can create a lot of output
|
178
203
|
verbose_logging true
|
@@ -194,7 +219,6 @@ class Chef
|
|
194
219
|
client_url "http://localhost:4042"
|
195
220
|
|
196
221
|
rest_timeout 300
|
197
|
-
yum_timeout 120
|
198
222
|
run_command_stderr_timeout 120
|
199
223
|
run_command_stdout_timeout 120
|
200
224
|
solo false
|
@@ -222,23 +246,6 @@ class Chef
|
|
222
246
|
# Where should chef-solo download recipes from?
|
223
247
|
recipe_url nil
|
224
248
|
|
225
|
-
solr_url "http://localhost:8983/solr"
|
226
|
-
solr_jetty_path "/var/chef/solr-jetty"
|
227
|
-
solr_data_path "/var/chef/solr/data"
|
228
|
-
solr_home_path "/var/chef/solr"
|
229
|
-
solr_heap_size "256M"
|
230
|
-
solr_java_opts nil
|
231
|
-
|
232
|
-
# Parameters for connecting to RabbitMQ
|
233
|
-
amqp_host '0.0.0.0'
|
234
|
-
amqp_port '5672'
|
235
|
-
amqp_user 'chef'
|
236
|
-
amqp_pass 'testing'
|
237
|
-
amqp_vhost '/chef'
|
238
|
-
# Setting this to a UUID string also makes the queue durable
|
239
|
-
# (persist across rabbitmq restarts)
|
240
|
-
amqp_consumer_id "default"
|
241
|
-
|
242
249
|
# Sets the version of the signed header authentication protocol to use (see
|
243
250
|
# the 'mixlib-authorization' project for more detail). Currently, versions
|
244
251
|
# 1.0 and 1.1 are available; however, the chef-server must first be
|
@@ -293,19 +300,25 @@ class Chef
|
|
293
300
|
# Report Handlers
|
294
301
|
report_handlers []
|
295
302
|
|
296
|
-
# Event Handlers
|
297
|
-
event_handlers []
|
298
|
-
|
299
303
|
# Exception Handlers
|
300
304
|
exception_handlers []
|
301
305
|
|
302
306
|
# Start handlers
|
303
307
|
start_handlers []
|
304
308
|
|
305
|
-
#
|
306
|
-
#
|
307
|
-
|
308
|
-
|
309
|
+
# Syntax Check Cache. Knife keeps track of files that is has already syntax
|
310
|
+
# checked by storing files in this directory. `syntax_check_cache_path` is
|
311
|
+
# the new (and preferred) configuration setting. If not set, knife will
|
312
|
+
# fall back to using cache_options[:path].
|
313
|
+
#
|
314
|
+
# Because many users will have knife configs with cache_options (generated
|
315
|
+
# by `knife configure`), the default for now is to *not* set
|
316
|
+
# syntax_check_cache_path, and thus fallback to cache_options[:path]. We
|
317
|
+
# leave that value to the same default as was previously set.
|
318
|
+
syntax_check_cache_path nil
|
319
|
+
|
320
|
+
# Deprecated:
|
321
|
+
cache_options({ :path => platform_specific_path("/var/chef/cache/checksums") })
|
309
322
|
|
310
323
|
# Set to false to silence Chef 11 deprecation warnings:
|
311
324
|
chef11_deprecation_warnings true
|
@@ -328,10 +341,6 @@ class Chef
|
|
328
341
|
|
329
342
|
# returns a platform specific path to the user home dir
|
330
343
|
windows_home_path = ENV['SYSTEMDRIVE'] + ENV['HOMEPATH'] if ENV['SYSTEMDRIVE'] && ENV['HOMEPATH']
|
331
|
-
user_home
|
332
|
-
|
333
|
-
# CHEF-4631
|
334
|
-
# Enables the concatanation behavior instead of merging
|
335
|
-
deep_merge_array_concat true
|
344
|
+
user_home(ENV['HOME'] || windows_home_path || ENV['USERPROFILE'])
|
336
345
|
end
|
337
346
|
end
|
@@ -56,14 +56,12 @@ class Chef
|
|
56
56
|
# Synchronizes the locally cached copies of cookbooks with the files on the
|
57
57
|
# server.
|
58
58
|
class CookbookSynchronizer
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@eager_segments.delete(:templates)
|
64
|
-
end
|
65
|
-
@eager_segments.freeze
|
59
|
+
EAGER_SEGMENTS = Chef::CookbookVersion::COOKBOOK_SEGMENTS.dup
|
60
|
+
EAGER_SEGMENTS.delete(:files)
|
61
|
+
EAGER_SEGMENTS.delete(:templates)
|
62
|
+
EAGER_SEGMENTS.freeze
|
66
63
|
|
64
|
+
def initialize(cookbooks_by_name, events)
|
67
65
|
@cookbooks_by_name, @events = cookbooks_by_name, events
|
68
66
|
end
|
69
67
|
|
@@ -140,7 +138,7 @@ class Chef
|
|
140
138
|
|
141
139
|
# files and templates are lazily loaded, and will be done later.
|
142
140
|
|
143
|
-
|
141
|
+
EAGER_SEGMENTS.each do |segment|
|
144
142
|
segment_filenames = Array.new
|
145
143
|
cookbook.manifest[segment].each do |manifest_record|
|
146
144
|
|
@@ -16,8 +16,8 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/checksum_cache'
|
20
19
|
require 'chef/mixin/shell_out'
|
20
|
+
require 'chef/mixin/checksum'
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
class Cookbook
|
@@ -25,10 +25,65 @@ class Chef
|
|
25
25
|
# Encapsulates the process of validating the ruby syntax of files in Chef
|
26
26
|
# cookbooks.
|
27
27
|
class SyntaxCheck
|
28
|
+
|
29
|
+
# == Chef::Cookbook::SyntaxCheck::PersistentSet
|
30
|
+
# Implements set behavior with disk-based persistence. Objects in the set
|
31
|
+
# are expected to be strings containing only characters that are valid in
|
32
|
+
# filenames.
|
33
|
+
#
|
34
|
+
# This class is used to track which files have been syntax checked so
|
35
|
+
# that known good files are not rechecked.
|
36
|
+
class PersistentSet
|
37
|
+
|
38
|
+
attr_reader :cache_path
|
39
|
+
|
40
|
+
# Create a new PersistentSet. Values in the set are persisted by
|
41
|
+
# creating a file in the +cache_path+ directory. If not given, the
|
42
|
+
# value of Chef::Config[:syntax_check_cache_path] is used; if that
|
43
|
+
# value is not configured, the value of
|
44
|
+
# Chef::Config[:cache_options][:path] is used.
|
45
|
+
#--
|
46
|
+
# history: prior to Chef 11, the cache implementation was based on
|
47
|
+
# moneta and configured via cache_options[:path]. Knife configs
|
48
|
+
# generated with Chef 11 will have `syntax_check_cache_path`, but older
|
49
|
+
# configs will have `cache_options[:path]`. `cache_options` is marked
|
50
|
+
# deprecated in chef/config.rb but doesn't currently trigger a warning.
|
51
|
+
# See also: CHEF-3715
|
52
|
+
def initialize(cache_path=nil)
|
53
|
+
@cache_path = cache_path || Chef::Config[:syntax_check_cache_path] || Chef::Config[:cache_options][:path]
|
54
|
+
@cache_path_created = false
|
55
|
+
end
|
56
|
+
|
57
|
+
# Adds +value+ to the set's collection.
|
58
|
+
def add(value)
|
59
|
+
ensure_cache_path_created
|
60
|
+
FileUtils.touch(File.join(cache_path, value))
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns true if the set includes +value+
|
64
|
+
def include?(value)
|
65
|
+
File.exist?(File.join(cache_path, value))
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def ensure_cache_path_created
|
71
|
+
return true if @cache_path_created
|
72
|
+
FileUtils.mkdir_p(cache_path)
|
73
|
+
@cache_path_created = true
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
28
78
|
include Chef::Mixin::ShellOut
|
79
|
+
include Chef::Mixin::Checksum
|
29
80
|
|
30
81
|
attr_reader :cookbook_path
|
31
82
|
|
83
|
+
# A PersistentSet object that tracks which files have already been
|
84
|
+
# validated.
|
85
|
+
attr_reader :validated_files
|
86
|
+
|
32
87
|
# Creates a new SyntaxCheck given the +cookbook_name+ and a +cookbook_path+.
|
33
88
|
# If no +cookbook_path+ is given, +Chef::Config.cookbook_path+ is used.
|
34
89
|
def self.for_cookbook(cookbook_name, cookbook_path=nil)
|
@@ -44,10 +99,7 @@ class Chef
|
|
44
99
|
# cookbook_path::: the (on disk) path to the cookbook
|
45
100
|
def initialize(cookbook_path)
|
46
101
|
@cookbook_path = cookbook_path
|
47
|
-
|
48
|
-
|
49
|
-
def cache
|
50
|
-
Chef::ChecksumCache.instance
|
102
|
+
@validated_files = PersistentSet.new
|
51
103
|
end
|
52
104
|
|
53
105
|
def ruby_files
|
@@ -81,16 +133,11 @@ class Chef
|
|
81
133
|
end
|
82
134
|
|
83
135
|
def validated?(file)
|
84
|
-
|
136
|
+
validated_files.include?(checksum(file))
|
85
137
|
end
|
86
138
|
|
87
139
|
def validated(file)
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
def cache_key(file)
|
92
|
-
@cache_keys ||= {}
|
93
|
-
@cache_keys[file] ||= cache.generate_key(file, "chef-test")
|
140
|
+
validated_files.add(checksum(file))
|
94
141
|
end
|
95
142
|
|
96
143
|
def validate_ruby_files
|
@@ -118,7 +165,7 @@ class Chef
|
|
118
165
|
result.stderr.each_line { |l| Chef::Log.fatal(l.chomp) }
|
119
166
|
false
|
120
167
|
end
|
121
|
-
|
168
|
+
|
122
169
|
def validate_ruby_file(ruby_file)
|
123
170
|
Chef::Log.debug("Testing #{ruby_file} for syntax errors...")
|
124
171
|
result = shell_out("ruby -c #{ruby_file}")
|
@@ -130,7 +177,7 @@ class Chef
|
|
130
177
|
result.stderr.each_line { |l| Chef::Log.fatal(l.chomp) }
|
131
178
|
false
|
132
179
|
end
|
133
|
-
|
180
|
+
|
134
181
|
end
|
135
182
|
end
|
136
183
|
end
|