chef 11.18.12-x86-mingw32 → 12.0.0.alpha.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +10 -0
- data/README.md +1 -1
- data/distro/common/html/_sources/index.txt +5 -2
- data/distro/common/html/_sources/knife_serve.txt +19 -0
- data/distro/common/html/_sources/knife_ssl_check.txt +2 -2
- data/distro/common/html/_sources/knife_ssl_fetch.txt +2 -2
- data/distro/common/html/_static/basic.css +1 -1
- data/distro/common/html/_static/doctools.js +1 -1
- data/distro/common/html/_static/searchtools.js +1 -1
- data/distro/common/html/_static/websupport.js +1 -1
- data/distro/common/html/ctl_chef_client.html +19 -9
- data/distro/common/html/ctl_chef_server.html +7 -1
- data/distro/common/html/ctl_chef_shell.html +3 -4
- data/distro/common/html/ctl_chef_solo.html +12 -7
- data/distro/common/html/index.html +19 -12
- data/distro/common/html/knife.html +1 -2
- data/distro/common/html/knife_bootstrap.html +16 -5
- data/distro/common/html/knife_client.html +8 -5
- data/distro/common/html/knife_common_options.html +11 -12
- data/distro/common/html/knife_configure.html +2 -3
- data/distro/common/html/knife_cookbook.html +16 -17
- data/distro/common/html/knife_cookbook_site.html +19 -18
- data/distro/common/html/knife_data_bag.html +6 -7
- data/distro/common/html/knife_delete.html +2 -3
- data/distro/common/html/knife_deps.html +2 -3
- data/distro/common/html/knife_diff.html +3 -4
- data/distro/common/html/knife_download.html +6 -7
- data/distro/common/html/knife_edit.html +0 -1
- data/distro/common/html/knife_environment.html +3 -4
- data/distro/common/html/knife_exec.html +0 -1
- data/distro/common/html/knife_index_rebuild.html +0 -1
- data/distro/common/html/knife_list.html +5 -6
- data/distro/common/html/knife_node.html +13 -6
- data/distro/common/html/knife_raw.html +0 -1
- data/distro/common/html/knife_recipe_list.html +0 -1
- data/distro/common/html/knife_role.html +1 -2
- data/distro/common/html/knife_search.html +2 -3
- data/distro/common/html/knife_serve.html +79 -0
- data/distro/common/html/knife_show.html +1 -2
- data/distro/common/html/knife_ssh.html +2 -3
- data/distro/common/html/knife_ssl_check.html +12 -9
- data/distro/common/html/knife_ssl_fetch.html +9 -10
- data/distro/common/html/knife_status.html +2 -3
- data/distro/common/html/knife_tag.html +0 -1
- data/distro/common/html/knife_upload.html +3 -4
- data/distro/common/html/knife_user.html +2 -3
- data/distro/common/html/knife_using.html +0 -1
- data/distro/common/html/knife_xargs.html +3 -4
- data/distro/common/html/search.html +0 -1
- data/distro/common/html/searchindex.js +1 -1
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +24 -67
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -3
- data/lib/chef/chef_fs/command_line.rb +2 -3
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -5
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -5
- data/lib/chef/config.rb +26 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +50 -8
- data/lib/chef/cookbook_uploader.rb +9 -23
- data/lib/chef/cookbook_version.rb +3 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/dsl/recipe.rb +1 -14
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +2 -24
- data/lib/chef/file_content_management/tempfile.rb +8 -1
- data/lib/chef/formatters/base.rb +0 -7
- data/lib/chef/http.rb +12 -19
- data/lib/chef/http/json_input.rb +12 -1
- data/lib/chef/json_compat.rb +45 -64
- data/lib/chef/knife.rb +2 -5
- data/lib/chef/knife/bootstrap.rb +2 -2
- 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-aix.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
- 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/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +10 -34
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +3 -3
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +0 -24
- data/lib/chef/knife/core/ui.rb +8 -7
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/knife/serve.rb +2 -1
- data/lib/chef/local_mode.rb +105 -0
- data/lib/chef/mixin/file_class.rb +1 -4
- data/lib/chef/mixin/shell_out.rb +15 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +0 -16
- data/lib/chef/node.rb +1 -1
- data/lib/chef/platform/query_helpers.rb +1 -5
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/cookbook_file.rb +0 -1
- data/lib/chef/provider/deploy.rb +0 -1
- data/lib/chef/provider/deploy/revision.rb +1 -1
- data/lib/chef/provider/env.rb +10 -25
- data/lib/chef/provider/env/windows.rb +23 -10
- data/lib/chef/provider/execute.rb +0 -3
- data/lib/chef/provider/file.rb +0 -3
- data/lib/chef/provider/git.rb +0 -6
- data/lib/chef/provider/group/dscl.rb +9 -27
- data/lib/chef/provider/group/gpasswd.rb +0 -3
- data/lib/chef/provider/group/groupmod.rb +0 -4
- data/lib/chef/provider/group/suse.rb +0 -3
- data/lib/chef/provider/group/usermod.rb +0 -3
- data/lib/chef/provider/link.rb +22 -5
- data/lib/chef/provider/log.rb +15 -4
- data/lib/chef/provider/mdadm.rb +0 -3
- data/lib/chef/provider/mount/mount.rb +0 -2
- data/lib/chef/provider/mount/solaris.rb +0 -2
- data/lib/chef/provider/package.rb +0 -1
- data/lib/chef/provider/package/apt.rb +0 -3
- data/lib/chef/provider/package/dpkg.rb +0 -1
- data/lib/chef/provider/package/easy_install.rb +0 -4
- data/lib/chef/provider/package/freebsd/base.rb +0 -3
- data/lib/chef/provider/package/freebsd/pkgng.rb +0 -2
- data/lib/chef/provider/package/freebsd/port.rb +0 -2
- data/lib/chef/provider/package/ips.rb +0 -3
- data/lib/chef/provider/package/paludis.rb +0 -5
- data/lib/chef/provider/package/portage.rb +0 -2
- data/lib/chef/provider/package/rpm.rb +2 -4
- data/lib/chef/provider/package/rubygems.rb +0 -4
- data/lib/chef/provider/package/smartos.rb +0 -3
- data/lib/chef/provider/package/windows/msi.rb +0 -2
- data/lib/chef/provider/package/yum.rb +0 -4
- data/lib/chef/provider/package/zypper.rb +0 -3
- data/lib/chef/provider/registry_key.rb +0 -2
- data/lib/chef/provider/remote_directory.rb +0 -1
- data/lib/chef/provider/remote_file.rb +0 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -3
- data/lib/chef/provider/remote_file/content.rb +0 -1
- data/lib/chef/provider/remote_file/fetcher.rb +0 -2
- data/lib/chef/provider/remote_file/ftp.rb +0 -1
- data/lib/chef/provider/resource_update.rb +0 -3
- data/lib/chef/provider/service/freebsd.rb +0 -3
- data/lib/chef/provider/service/init.rb +0 -3
- data/lib/chef/provider/service/macosx.rb +0 -1
- data/lib/chef/provider/service/redhat.rb +0 -2
- data/lib/chef/provider/service/simple.rb +0 -3
- data/lib/chef/provider/service/solaris.rb +0 -3
- data/lib/chef/provider/service/systemd.rb +15 -14
- data/lib/chef/provider/service/windows.rb +0 -3
- data/lib/chef/provider/subversion.rb +0 -2
- data/lib/chef/provider/template.rb +0 -2
- data/lib/chef/provider/template/content.rb +0 -1
- data/lib/chef/provider/user/dscl.rb +156 -549
- data/lib/chef/provider/user/solaris.rb +0 -1
- data/lib/chef/provider/user/useradd.rb +0 -3
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource.rb +1 -4
- data/lib/chef/resource/freebsd_package.rb +2 -10
- data/lib/chef/resource/lwrp_base.rb +1 -12
- data/lib/chef/resource/user.rb +0 -18
- data/lib/chef/resource_collection.rb +1 -1
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +0 -1
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +1 -1
- data/lib/chef/tasks/chef_repo.rake +131 -264
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/path_helper.rb +2 -2
- data/lib/chef/version.rb +9 -1
- data/lib/chef/win32/api/system.rb +0 -9
- data/spec/data/bootstrap/test-hints.erb +1 -1
- data/spec/data/bootstrap/test.erb +1 -1
- data/spec/functional/dsl/reboot_pending_spec.rb +53 -58
- data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
- data/spec/functional/knife/exec_spec.rb +1 -1
- data/spec/functional/mixin/shell_out_spec.rb +48 -0
- data/spec/functional/resource/base.rb +0 -10
- data/spec/functional/resource/group_spec.rb +1 -5
- data/spec/functional/resource/link_spec.rb +8 -0
- data/spec/functional/resource/{user/useradd_spec.rb → user_spec.rb} +1 -1
- data/spec/integration/knife/chef_fs_data_store_spec.rb +3 -3
- data/spec/integration/knife/chef_repo_path_spec.rb +1 -6
- data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
- data/spec/integration/knife/chefignore_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +50 -3
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
- data/spec/integration/knife/delete_spec.rb +1 -1
- data/spec/integration/knife/deps_spec.rb +1 -1
- data/spec/integration/knife/diff_spec.rb +3 -3
- data/spec/integration/knife/download_spec.rb +3 -3
- data/spec/integration/knife/list_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +1 -11
- data/spec/integration/knife/redirection_spec.rb +1 -1
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +1 -1
- data/spec/integration/knife/upload_spec.rb +9 -9
- data/spec/spec_helper.rb +0 -9
- data/spec/support/pedant/pedant_config.rb +2 -1
- data/spec/support/pedant/run_pedant.rb +2 -1
- data/spec/support/platform_helpers.rb +5 -24
- data/spec/support/shared/integration/integration_helper.rb +2 -1
- data/spec/support/shared/matchers.rb +17 -0
- data/spec/tiny_server.rb +1 -2
- data/spec/unit/api_client_spec.rb +3 -3
- data/spec/unit/application_spec.rb +9 -32
- data/spec/unit/config_fetcher_spec.rb +1 -1
- data/spec/unit/cookbook/metadata_spec.rb +3 -7
- data/spec/unit/cookbook/synchronizer_spec.rb +441 -226
- data/spec/unit/cookbook_loader_spec.rb +1 -1
- data/spec/unit/cookbook_uploader_spec.rb +160 -0
- data/spec/unit/cookbook_version_spec.rb +0 -4
- data/spec/unit/data_bag_item_spec.rb +1 -5
- data/spec/unit/data_bag_spec.rb +1 -5
- data/spec/unit/deprecation_spec.rb +1 -1
- data/spec/unit/dsl/recipe_spec.rb +12 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +7 -14
- data/spec/unit/environment_spec.rb +3 -7
- data/spec/unit/exceptions_spec.rb +0 -6
- data/spec/unit/http/json_input_spec.rb +128 -0
- data/spec/unit/json_compat_spec.rb +17 -58
- data/spec/unit/knife/client_create_spec.rb +3 -3
- data/spec/unit/knife/configure_client_spec.rb +6 -5
- data/spec/unit/knife/cookbook_delete_spec.rb +1 -1
- data/spec/unit/knife/cookbook_download_spec.rb +5 -5
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -0
- data/spec/unit/knife/cookbook_metadata_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_download_spec.rb +10 -11
- data/spec/unit/knife/cookbook_site_install_spec.rb +116 -161
- data/spec/unit/knife/cookbook_site_share_spec.rb +8 -8
- data/spec/unit/knife/cookbook_upload_spec.rb +3 -2
- data/spec/unit/knife/core/bootstrap_context_spec.rb +3 -3
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -66
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -1
- data/spec/unit/knife/tag_create_spec.rb +3 -3
- data/spec/unit/knife/tag_delete_spec.rb +3 -3
- data/spec/unit/knife/user_create_spec.rb +1 -1
- data/spec/unit/knife_spec.rb +14 -14
- data/spec/unit/lwrp_spec.rb +1 -21
- data/spec/unit/mixin/shell_out_spec.rb +92 -0
- data/spec/unit/node_spec.rb +0 -4
- data/spec/unit/platform/query_helpers_spec.rb +0 -23
- data/spec/unit/provider/env/windows_spec.rb +34 -70
- data/spec/unit/provider/env_spec.rb +11 -76
- data/spec/unit/provider/group/dscl_spec.rb +1 -38
- data/spec/unit/provider/log_spec.rb +18 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -12
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
- data/spec/unit/provider/service/systemd_service_spec.rb +44 -27
- data/spec/unit/provider/user/dscl_spec.rb +264 -660
- data/spec/unit/provider/user/useradd_spec.rb +0 -1
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/unit/provider_spec.rb +12 -0
- data/spec/unit/recipe_spec.rb +0 -41
- data/spec/unit/resource_collection_spec.rb +1 -5
- data/spec/unit/resource_reporter_spec.rb +3 -51
- data/spec/unit/resource_spec.rb +3 -14
- data/spec/unit/rest_spec.rb +1 -4
- data/spec/unit/role_spec.rb +0 -10
- data/spec/unit/run_list_spec.rb +1 -5
- data/spec/unit/user_spec.rb +1 -5
- metadata +20 -100
- data/lib/chef/mixin/windows_env_helper.rb +0 -56
- data/lib/chef/provider/dsc_script.rb +0 -175
- data/lib/chef/resource/dsc_script.rb +0 -126
- data/lib/chef/streaming_cookbook_uploader.rb +0 -205
- data/lib/chef/util/dsc/configuration_generator.rb +0 -115
- data/lib/chef/util/dsc/lcm_output_parser.rb +0 -133
- data/lib/chef/util/dsc/local_configuration_manager.rb +0 -141
- data/lib/chef/util/dsc/resource_info.rb +0 -26
- data/lib/chef/util/powershell/cmdlet.rb +0 -136
- data/lib/chef/util/powershell/cmdlet_result.rb +0 -46
- 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/provider/whyrun_safe_ruby_block_spec.rb +0 -51
- data/spec/functional/resource/dsc_script_spec.rb +0 -382
- data/spec/functional/resource/env_spec.rb +0 -182
- data/spec/functional/resource/user/dscl_spec.rb +0 -199
- data/spec/functional/util/powershell/cmdlet_spec.rb +0 -113
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -46
- data/spec/support/shared/shared_examples.rb +0 -10
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +0 -63
- data/spec/unit/formatters/base_spec.rb +0 -48
- data/spec/unit/provider/dsc_script_spec.rb +0 -174
- data/spec/unit/resource/dsc_script_spec.rb +0 -98
- data/spec/unit/util/dsc/configuration_generator_spec.rb +0 -171
- data/spec/unit/util/dsc/lcm_output_parser_spec.rb +0 -169
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +0 -139
- data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -19,7 +19,6 @@
|
|
19
19
|
|
20
20
|
require 'chef/chef_fs/file_system/file_system_entry'
|
21
21
|
require 'chef/chef_fs/file_system/not_found_error'
|
22
|
-
require 'chef/json_compat'
|
23
22
|
|
24
23
|
class Chef
|
25
24
|
module ChefFS
|
@@ -42,7 +41,7 @@ class Chef
|
|
42
41
|
|
43
42
|
def chef_object
|
44
43
|
begin
|
45
|
-
return data_handler.chef_object(
|
44
|
+
return data_handler.chef_object(JSON.parse(read, :create_additions => false))
|
46
45
|
rescue
|
47
46
|
Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{$!}")
|
48
47
|
end
|
@@ -106,7 +106,7 @@ class Chef
|
|
106
106
|
cookbook_to_upload.freeze_version if options[:freeze]
|
107
107
|
|
108
108
|
# Instantiate a new uploader based on the proxy loader
|
109
|
-
uploader = Chef::CookbookUploader.new(cookbook_to_upload,
|
109
|
+
uploader = Chef::CookbookUploader.new(cookbook_to_upload, :force => options[:force], :rest => root.chef_rest)
|
110
110
|
|
111
111
|
with_actual_cookbooks_dir(temp_cookbooks_path) do
|
112
112
|
upload_cookbook!(uploader)
|
@@ -128,7 +128,7 @@ class Chef
|
|
128
128
|
def upload_unversioned_cookbook(other, options)
|
129
129
|
cookbook_to_upload = other.chef_object
|
130
130
|
cookbook_to_upload.freeze_version if options[:freeze]
|
131
|
-
uploader = Chef::CookbookUploader.new(cookbook_to_upload,
|
131
|
+
uploader = Chef::CookbookUploader.new(cookbook_to_upload, :force => options[:force], :rest => root.chef_rest)
|
132
132
|
|
133
133
|
with_actual_cookbooks_dir(other.parent.file_path) do
|
134
134
|
upload_cookbook!(uploader)
|
@@ -19,7 +19,6 @@
|
|
19
19
|
require 'chef/chef_fs/file_system/base_fs_dir'
|
20
20
|
require 'chef/chef_fs/file_system/rest_list_entry'
|
21
21
|
require 'chef/chef_fs/file_system/not_found_error'
|
22
|
-
require 'chef/json_compat'
|
23
22
|
|
24
23
|
class Chef
|
25
24
|
module ChefFS
|
@@ -62,8 +61,8 @@ class Chef
|
|
62
61
|
|
63
62
|
def create_child(name, file_contents)
|
64
63
|
begin
|
65
|
-
object =
|
66
|
-
rescue
|
64
|
+
object = JSON.parse(file_contents, :create_additions => false)
|
65
|
+
rescue JSON::ParserError => e
|
67
66
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e), "Parse error reading JSON creating child '#{name}': #{e}"
|
68
67
|
end
|
69
68
|
|
@@ -19,7 +19,6 @@
|
|
19
19
|
require 'chef/chef_fs/file_system/base_fs_object'
|
20
20
|
require 'chef/chef_fs/file_system/not_found_error'
|
21
21
|
require 'chef/chef_fs/file_system/operation_failed_error'
|
22
|
-
require 'chef/json_compat'
|
23
22
|
require 'chef/role'
|
24
23
|
require 'chef/node'
|
25
24
|
|
@@ -129,8 +128,8 @@ class Chef
|
|
129
128
|
value = minimize_value(value)
|
130
129
|
value_json = Chef::JSONCompat.to_json_pretty(value)
|
131
130
|
begin
|
132
|
-
other_value =
|
133
|
-
rescue
|
131
|
+
other_value = JSON.parse(other_value_json, :create_additions => false)
|
132
|
+
rescue JSON::ParserError => e
|
134
133
|
Chef::Log.warn("Parse error reading #{other.path_for_printing} as JSON: #{e}")
|
135
134
|
return [ nil, value_json, other_value_json ]
|
136
135
|
end
|
@@ -146,8 +145,8 @@ class Chef
|
|
146
145
|
|
147
146
|
def write(file_contents)
|
148
147
|
begin
|
149
|
-
object =
|
150
|
-
rescue
|
148
|
+
object = JSON.parse(file_contents, :create_additions => false)
|
149
|
+
rescue JSON::ParserError => e
|
151
150
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, e), "Parse error reading JSON: #{e}"
|
152
151
|
end
|
153
152
|
|
data/lib/chef/config.rb
CHANGED
@@ -325,7 +325,7 @@ class Chef
|
|
325
325
|
config_strict_mode true
|
326
326
|
default(:enabled) { Chef::Config.local_mode }
|
327
327
|
default :host, 'localhost'
|
328
|
-
default :port, 8889
|
328
|
+
default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works
|
329
329
|
end
|
330
330
|
default :chef_server_url, "https://localhost:443"
|
331
331
|
|
@@ -567,7 +567,7 @@ class Chef
|
|
567
567
|
# If false file staging is will be done via tempfiles that are
|
568
568
|
# created under ENV['TMP'] otherwise tempfiles will be created in
|
569
569
|
# the directory that files are going to reside.
|
570
|
-
default :file_staging_uses_destdir,
|
570
|
+
default :file_staging_uses_destdir, true
|
571
571
|
|
572
572
|
# Exit if another run is in progress and the chef-client is unable to
|
573
573
|
# get the lock before time expires. If nil, no timeout is enforced. (Exits
|
@@ -580,6 +580,30 @@ class Chef
|
|
580
580
|
# the number of threads will help.
|
581
581
|
default :cookbook_sync_threads, 10
|
582
582
|
|
583
|
+
# At the beginning of the Chef Client run, the cookbook manifests are downloaded which
|
584
|
+
# contain URLs for every file in every relevant cookbook. Most of the files
|
585
|
+
# (recipes, resources, providers, libraries, etc) are immediately synchronized
|
586
|
+
# at the start of the run. The handling of "files" and "templates" directories,
|
587
|
+
# however, have two modes of operation. They can either all be downloaded immediately
|
588
|
+
# at the start of the run (no_lazy_load==true) or else they can be lazily loaded as
|
589
|
+
# cookbook_file or template resources are converged which require them (no_lazy_load==false).
|
590
|
+
#
|
591
|
+
# The advantage of lazily loading these files is that unnecessary files are not
|
592
|
+
# synchronized. This may be useful to users with large files checked into cookbooks which
|
593
|
+
# are only selectively downloaded to a subset of clients which use the cookbook. However,
|
594
|
+
# better solutions are to either isolate large files into individual cookbooks and only
|
595
|
+
# include those cookbooks in the run lists of the servers that need them -- or move to
|
596
|
+
# using remote_file and a more appropriate backing store like S3 for large file
|
597
|
+
# distribution.
|
598
|
+
#
|
599
|
+
# The disadvantages of lazily loading files are that users some time find it
|
600
|
+
# confusing that their cookbooks are not fully synchronzied to the cache initially,
|
601
|
+
# and more importantly the time-sensitive URLs which are in the manifest may time
|
602
|
+
# out on long Chef runs before the resource that uses the file is converged
|
603
|
+
# (leading to many confusing 403 errors on template/cookbook_file resources).
|
604
|
+
#
|
605
|
+
default :no_lazy_load, true
|
606
|
+
|
583
607
|
# A whitelisted array of attributes you want sent over the wire when node
|
584
608
|
# data is saved.
|
585
609
|
# The default setting is nil, which collects all data. Setting to [] will not
|
data/lib/chef/config_fetcher.rb
CHANGED
@@ -18,7 +18,7 @@ class Chef
|
|
18
18
|
config_data = read_config
|
19
19
|
begin
|
20
20
|
Chef::JSONCompat.from_json(config_data)
|
21
|
-
rescue
|
21
|
+
rescue FFI_Yajl::ParseError => error
|
22
22
|
Chef::Application.fatal!("Could not parse the provided JSON file (#{config_location}): " + error.message, 2)
|
23
23
|
end
|
24
24
|
end
|
@@ -170,7 +170,7 @@ class Chef
|
|
170
170
|
def apply_ruby_metadata(file)
|
171
171
|
begin
|
172
172
|
@metadata.from_file(file)
|
173
|
-
rescue
|
173
|
+
rescue JSON::ParserError
|
174
174
|
Chef::Log.error("Error evaluating metadata.rb for #@cookbook_name in " + file)
|
175
175
|
raise
|
176
176
|
end
|
@@ -179,7 +179,7 @@ class Chef
|
|
179
179
|
def apply_json_metadata(file)
|
180
180
|
begin
|
181
181
|
@metadata.from_json(IO.read(file))
|
182
|
-
rescue
|
182
|
+
rescue JSON::ParserError
|
183
183
|
Chef::Log.error("Couldn't parse cookbook metadata JSON for #@cookbook_name in " + file)
|
184
184
|
raise
|
185
185
|
end
|
@@ -189,7 +189,7 @@ class Chef
|
|
189
189
|
begin
|
190
190
|
data = Chef::JSONCompat.from_json(IO.read(file), :create_additions => false)
|
191
191
|
@metadata.from_hash(data['metadata'])
|
192
|
-
rescue
|
192
|
+
rescue JSON::ParserError
|
193
193
|
Chef::Log.error("Couldn't parse cookbook metadata JSON for #@cookbook_name in " + file)
|
194
194
|
raise
|
195
195
|
end
|
@@ -200,7 +200,7 @@ class Chef
|
|
200
200
|
begin
|
201
201
|
data = Chef::JSONCompat.from_json(IO.read(uploaded_cookbook_version_file), :create_additions => false)
|
202
202
|
@frozen = data['frozen?']
|
203
|
-
rescue
|
203
|
+
rescue JSON::ParserError
|
204
204
|
Chef::Log.error("Couldn't parse cookbook metadata JSON for #@cookbook_name in #{uploaded_cookbook_version_file}")
|
205
205
|
raise
|
206
206
|
end
|
@@ -10,6 +10,8 @@ class Chef
|
|
10
10
|
# cache.
|
11
11
|
class CookbookCacheCleaner
|
12
12
|
|
13
|
+
attr_accessor :skip_removal
|
14
|
+
|
13
15
|
# Setup a notification to clear the valid_cache_entries when a Chef client
|
14
16
|
# run starts
|
15
17
|
Chef::Client.when_run_starts do |run_status|
|
@@ -40,15 +42,17 @@ class Chef
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def cleanup_file_cache
|
43
|
-
unless Chef::Config[:solo]
|
45
|
+
unless Chef::Config[:solo] || skip_removal
|
44
46
|
# Delete each file in the cache that we didn't encounter in the
|
45
47
|
# manifest.
|
46
|
-
cache.find(File.join(%w{cookbooks **
|
48
|
+
cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_filename|
|
47
49
|
unless @valid_cache_entries[cache_filename]
|
48
50
|
Chef::Log.info("Removing #{cache_filename} from the cache; it is no longer needed by chef-client.")
|
49
51
|
cache.delete(cache_filename)
|
50
52
|
end
|
51
53
|
end
|
54
|
+
else
|
55
|
+
Chef::Log.info("Skipping removal of unused files from the cache")
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
@@ -59,6 +63,8 @@ class Chef
|
|
59
63
|
class CookbookSynchronizer
|
60
64
|
CookbookFile = Struct.new(:cookbook, :segment, :manifest_record)
|
61
65
|
|
66
|
+
attr_accessor :remove_obsoleted_files
|
67
|
+
|
62
68
|
def initialize(cookbooks_by_name, events)
|
63
69
|
@eager_segments = Chef::CookbookVersion::COOKBOOK_SEGMENTS.dup
|
64
70
|
unless Chef::Config[:no_lazy_load]
|
@@ -70,6 +76,7 @@ class Chef
|
|
70
76
|
@cookbooks_by_name, @events = cookbooks_by_name, events
|
71
77
|
|
72
78
|
@cookbook_full_file_paths = {}
|
79
|
+
@remove_obsoleted_files = true
|
73
80
|
end
|
74
81
|
|
75
82
|
def cache
|
@@ -92,6 +99,10 @@ class Chef
|
|
92
99
|
@cookbooks_by_name.key?(cookbook_name)
|
93
100
|
end
|
94
101
|
|
102
|
+
def cookbook_segment(cookbook_name, segment)
|
103
|
+
@cookbooks_by_name[cookbook_name].manifest[segment]
|
104
|
+
end
|
105
|
+
|
95
106
|
def files
|
96
107
|
@files ||= cookbooks.inject([]) do |memo, cookbook|
|
97
108
|
@eager_segments.each do |segment|
|
@@ -169,12 +180,10 @@ class Chef
|
|
169
180
|
@cookbook_full_file_paths[file.cookbook][file.segment] << full_path
|
170
181
|
end
|
171
182
|
|
172
|
-
#
|
173
|
-
#
|
174
|
-
def
|
175
|
-
|
176
|
-
# Remove all cookbooks no longer relevant to this node
|
177
|
-
cache.find(File.join(%w{cookbooks ** *})).each do |cache_file|
|
183
|
+
# remove cookbooks that are not referenced in the expanded run_list at all
|
184
|
+
# (if we have an override run_list we may not want to do this)
|
185
|
+
def remove_old_cookbooks
|
186
|
+
cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_file|
|
178
187
|
cache_file =~ /^cookbooks\/([^\/]+)\//
|
179
188
|
unless have_cookbook?($1)
|
180
189
|
Chef::Log.info("Removing #{cache_file} from the cache; its cookbook is no longer needed on this client.")
|
@@ -182,6 +191,39 @@ class Chef
|
|
182
191
|
@events.removed_cookbook_file(cache_file)
|
183
192
|
end
|
184
193
|
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# remove deleted files in cookbooks that are being used on the node
|
197
|
+
def remove_deleted_files
|
198
|
+
cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_file|
|
199
|
+
md = cache_file.match(/^cookbooks\/([^\/]+)\/([^\/]+)\/(.*)/)
|
200
|
+
next unless md
|
201
|
+
( cookbook_name, segment, file ) = md[1..3]
|
202
|
+
if have_cookbook?(cookbook_name)
|
203
|
+
manifest_segment = cookbook_segment(cookbook_name, segment)
|
204
|
+
if manifest_segment.select { |manifest_record| manifest_record["path"] == "#{segment}/#{file}" }.empty?
|
205
|
+
Chef::Log.info("Removing #{cache_file} from the cache; its is no longer in the cookbook manifest.")
|
206
|
+
cache.delete(cache_file)
|
207
|
+
@events.removed_cookbook_file(cache_file)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
# Iterates over cached cookbooks' files, removing files belonging to
|
214
|
+
# cookbooks that don't appear in +cookbook_hash+
|
215
|
+
def clear_obsoleted_cookbooks
|
216
|
+
@events.cookbook_clean_start
|
217
|
+
|
218
|
+
if remove_obsoleted_files
|
219
|
+
remove_old_cookbooks
|
220
|
+
else
|
221
|
+
Chef::Log.info("Skipping removal of obsoleted cookbooks from the cache")
|
222
|
+
CookbookCacheCleaner.instance.skip_removal = true
|
223
|
+
end
|
224
|
+
|
225
|
+
remove_deleted_files
|
226
|
+
|
185
227
|
@events.cookbook_clean_complete
|
186
228
|
end
|
187
229
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
|
2
2
|
require 'set'
|
3
|
-
require 'rest_client'
|
4
3
|
require 'chef/exceptions'
|
5
4
|
require 'chef/knife/cookbook_metadata'
|
6
5
|
require 'chef/digester'
|
@@ -36,8 +35,8 @@ class Chef
|
|
36
35
|
# in Chef::Config.
|
37
36
|
# * :concurrency An integer that decided how many threads will be used to
|
38
37
|
# perform concurrent uploads
|
39
|
-
def initialize(cookbooks,
|
40
|
-
@
|
38
|
+
def initialize(cookbooks, opts={})
|
39
|
+
@opts = opts
|
41
40
|
@cookbooks = Array(cookbooks)
|
42
41
|
@rest = opts[:rest] || Chef::REST.new(Chef::Config[:chef_server_url])
|
43
42
|
@concurrency = opts[:concurrency] || 10
|
@@ -54,7 +53,7 @@ class Chef
|
|
54
53
|
end
|
55
54
|
|
56
55
|
checksums = checksum_files.inject({}){|memo,elt| memo[elt.first]=nil ; memo}
|
57
|
-
new_sandbox = rest.
|
56
|
+
new_sandbox = rest.post("sandboxes", { :checksums => checksums })
|
58
57
|
|
59
58
|
Chef::Log.info("Uploading files")
|
60
59
|
|
@@ -81,7 +80,7 @@ class Chef
|
|
81
80
|
# in eventual consistency)
|
82
81
|
retries = 0
|
83
82
|
begin
|
84
|
-
rest.
|
83
|
+
rest.put(sandbox_url, {:is_completed => true})
|
85
84
|
rescue Net::HTTPServerException => e
|
86
85
|
if e.message =~ /^400/ && (retries += 1) <= 5
|
87
86
|
sleep 2
|
@@ -95,7 +94,7 @@ class Chef
|
|
95
94
|
cookbooks.each do |cb|
|
96
95
|
save_url = opts[:force] ? cb.force_save_url : cb.save_url
|
97
96
|
begin
|
98
|
-
rest.
|
97
|
+
rest.put(save_url, cb)
|
99
98
|
rescue Net::HTTPServerException => e
|
100
99
|
case e.response.code
|
101
100
|
when "409"
|
@@ -109,32 +108,19 @@ class Chef
|
|
109
108
|
Chef::Log.info("Upload complete!")
|
110
109
|
end
|
111
110
|
|
112
|
-
def worker_thread(work_queue)
|
113
|
-
end
|
114
|
-
|
115
111
|
def uploader_function_for(file, checksum, url, checksums_to_upload)
|
116
112
|
lambda do
|
117
113
|
# Checksum is the hexadecimal representation of the md5,
|
118
114
|
# but we need the base64 encoding for the content-md5
|
119
115
|
# header
|
120
116
|
checksum64 = Base64.encode64([checksum].pack("H*")).strip
|
121
|
-
timestamp = Time.now.utc.iso8601
|
122
117
|
file_contents = File.open(file, "rb") {|f| f.read}
|
123
|
-
|
118
|
+
|
119
|
+
# Custom headers. 'content-type' disables JSON serialization of the request body.
|
124
120
|
headers = { 'content-type' => 'application/x-binary', 'content-md5' => checksum64, "accept" => 'application/json' }
|
125
|
-
if rest.signing_key
|
126
|
-
sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(
|
127
|
-
:http_method => :put,
|
128
|
-
:path => URI.parse(url).path,
|
129
|
-
:body => file_contents,
|
130
|
-
:timestamp => timestamp,
|
131
|
-
:user_id => rest.client_name
|
132
|
-
)
|
133
|
-
headers.merge!(sign_obj.sign(OpenSSL::PKey::RSA.new(rest.signing_key)))
|
134
|
-
end
|
135
121
|
|
136
122
|
begin
|
137
|
-
|
123
|
+
rest.put(url, file_contents, headers)
|
138
124
|
checksums_to_upload.delete(checksum)
|
139
125
|
rescue Net::HTTPServerException, Net::HTTPFatalError, Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError => e
|
140
126
|
error_message = "Failed to upload #{file} (#{checksum}) to #{url} : #{e.message}"
|
@@ -147,7 +133,7 @@ class Chef
|
|
147
133
|
|
148
134
|
def validate_cookbooks
|
149
135
|
cookbooks.each do |cb|
|
150
|
-
syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cb.name
|
136
|
+
syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cb.name)
|
151
137
|
Chef::Log.info("Validating ruby files")
|
152
138
|
exit(1) unless syntax_checker.validate_ruby_files
|
153
139
|
Chef::Log.info("Validating templates")
|
@@ -25,6 +25,7 @@ require 'chef/cookbook/metadata'
|
|
25
25
|
require 'chef/version_class'
|
26
26
|
require 'pathname'
|
27
27
|
require 'chef/monkey_patches/pathname'
|
28
|
+
require 'chef/digester'
|
28
29
|
|
29
30
|
class Chef
|
30
31
|
|
@@ -459,7 +460,7 @@ class Chef
|
|
459
460
|
def to_json(*a)
|
460
461
|
result = self.to_hash
|
461
462
|
result['json_class'] = self.class.name
|
462
|
-
|
463
|
+
result.to_json(*a)
|
463
464
|
end
|
464
465
|
|
465
466
|
def self.json_create(o)
|
@@ -469,7 +470,7 @@ class Chef
|
|
469
470
|
cookbook_version.manifest = o
|
470
471
|
|
471
472
|
# We don't need the following step when we decide to stop supporting deprecated operators in the metadata (e.g. <<, >>)
|
472
|
-
cookbook_version.manifest["metadata"] = Chef::JSONCompat.from_json(
|
473
|
+
cookbook_version.manifest["metadata"] = Chef::JSONCompat.from_json(cookbook_version.metadata.to_json)
|
473
474
|
|
474
475
|
cookbook_version.freeze_version if o["frozen?"]
|
475
476
|
cookbook_version
|
data/lib/chef/data_bag.rb
CHANGED
data/lib/chef/data_bag_item.rb
CHANGED
data/lib/chef/dsl/recipe.rb
CHANGED
@@ -28,6 +28,7 @@ class Chef
|
|
28
28
|
# objects via method calls.
|
29
29
|
module Recipe
|
30
30
|
|
31
|
+
include Chef::Mixin::ShellOut
|
31
32
|
include Chef::Mixin::ConvertToClassName
|
32
33
|
|
33
34
|
def method_missing(method_symbol, *args, &block)
|
@@ -84,20 +85,6 @@ class Chef
|
|
84
85
|
|
85
86
|
resource = build_resource(type, name, created_at, &resource_attrs_block)
|
86
87
|
|
87
|
-
# Some resources (freebsd_package) can be invoked with multiple names
|
88
|
-
# (package || freebsd_package).
|
89
|
-
# https://github.com/opscode/chef/issues/1773
|
90
|
-
# For these resources we want to make sure
|
91
|
-
# their key in resource collection is same as the name they are declared
|
92
|
-
# as. Since this might be a breaking change for resources that define
|
93
|
-
# customer to_s methods, we are working around the issue by letting
|
94
|
-
# resources know of their created_as_type until this issue is fixed in
|
95
|
-
# Chef 12:
|
96
|
-
# https://github.com/opscode/chef/issues/1817
|
97
|
-
if resource.respond_to?(:created_as_type=)
|
98
|
-
resource.created_as_type = type
|
99
|
-
end
|
100
|
-
|
101
88
|
run_context.resource_collection.insert(resource)
|
102
89
|
resource
|
103
90
|
end
|