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
@@ -17,10 +17,10 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'yaml'
|
20
|
+
require 'ffi_yajl'
|
20
21
|
require 'openssl'
|
21
22
|
require 'base64'
|
22
23
|
require 'digest/sha2'
|
23
|
-
require 'chef/json_compat'
|
24
24
|
require 'chef/encrypted_data_bag_item'
|
25
25
|
require 'chef/encrypted_data_bag_item/unsupported_encrypted_data_bag_item_format'
|
26
26
|
require 'chef/encrypted_data_bag_item/unacceptable_encrypted_data_bag_item_format'
|
@@ -121,8 +121,8 @@ class Chef::EncryptedDataBagItem
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def for_decrypted_item
|
124
|
-
|
125
|
-
rescue
|
124
|
+
FFI_Yajl::Parser.parse(decrypted_data)["json_wrapper"]
|
125
|
+
rescue FFI_Yajl::ParseError
|
126
126
|
# convert to a DecryptionFailure error because the most likely scenario
|
127
127
|
# here is that the decryption step was unsuccessful but returned bad
|
128
128
|
# data rather than raising an error.
|
data/lib/chef/environment.rb
CHANGED
data/lib/chef/exceptions.rb
CHANGED
@@ -83,7 +83,6 @@ class Chef
|
|
83
83
|
class RequestedUIDUnavailable < RuntimeError; end
|
84
84
|
class InvalidHomeDirectory < ArgumentError; end
|
85
85
|
class DsclCommandFailed < RuntimeError; end
|
86
|
-
class PlistUtilCommandFailed < RuntimeError; end
|
87
86
|
class UserIDNotFound < ArgumentError; end
|
88
87
|
class GroupIDNotFound < ArgumentError; end
|
89
88
|
class ConflictingMembersInGroup < ArgumentError; end
|
@@ -117,8 +116,6 @@ class Chef
|
|
117
116
|
class ObsoleteDependencySyntax < ArgumentError; end
|
118
117
|
class InvalidDataBagPath < ArgumentError; end
|
119
118
|
|
120
|
-
class PowershellCmdletException < RuntimeError; end
|
121
|
-
|
122
119
|
# A different version of a cookbook was added to a
|
123
120
|
# VersionedRecipeList than the one already there.
|
124
121
|
class CookbookVersionConflict < ArgumentError ; end
|
@@ -134,17 +131,6 @@ class Chef
|
|
134
131
|
# Version constraints are not allowed in chef-solo
|
135
132
|
class IllegalVersionConstraint < NotImplementedError; end
|
136
133
|
|
137
|
-
class MetadataNotValid < StandardError; end
|
138
|
-
class MetadataNotFound < StandardError
|
139
|
-
attr_reader :install_path
|
140
|
-
attr_reader :cookbook_name
|
141
|
-
def initialize(install_path, cookbook_name)
|
142
|
-
@install_path = install_path
|
143
|
-
@cookbook_name = cookbook_name
|
144
|
-
super "No metadata.rb or metadata.json found for cookbook #{@cookbook_name} in #{@install_path}"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
134
|
# File operation attempted but no permissions to perform it
|
149
135
|
class InsufficientPermissions < RuntimeError; end
|
150
136
|
|
@@ -189,8 +175,6 @@ class Chef
|
|
189
175
|
|
190
176
|
class ChildConvergeError < RuntimeError; end
|
191
177
|
|
192
|
-
class NoProviderAvailable < RuntimeError; end
|
193
|
-
|
194
178
|
class MissingRole < RuntimeError
|
195
179
|
NULL = Object.new
|
196
180
|
|
@@ -278,7 +262,7 @@ class Chef
|
|
278
262
|
"non_existent_cookbooks" => non_existent_cookbooks,
|
279
263
|
"cookbooks_with_no_versions" => cookbooks_with_no_matching_versions
|
280
264
|
}
|
281
|
-
|
265
|
+
result.to_json(*a)
|
282
266
|
end
|
283
267
|
end
|
284
268
|
|
@@ -313,7 +297,7 @@ class Chef
|
|
313
297
|
"non_existent_cookbooks" => non_existent_cookbooks,
|
314
298
|
"most_constrained_cookbooks" => most_constrained_cookbooks
|
315
299
|
}
|
316
|
-
|
300
|
+
result.to_json(*a)
|
317
301
|
end
|
318
302
|
end
|
319
303
|
|
@@ -348,11 +332,5 @@ class Chef
|
|
348
332
|
end
|
349
333
|
|
350
334
|
class BadProxyURI < RuntimeError; end
|
351
|
-
|
352
|
-
# Raised by Chef::JSONCompat
|
353
|
-
class JSON
|
354
|
-
class EncodeError < RuntimeError; end
|
355
|
-
class ParseError < RuntimeError; end
|
356
|
-
end
|
357
335
|
end
|
358
336
|
end
|
@@ -54,7 +54,14 @@ class Chef
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def tempfile_dirname
|
57
|
-
|
57
|
+
# in why-run mode we need to create a Tempfile to compare against, which we will never
|
58
|
+
# wind up deploying, but our enclosing directory for the destdir may not exist yet, so
|
59
|
+
# instead we can reliably always create a Tempfile to compare against in Dir::tmpdir
|
60
|
+
if Chef::Config[:file_staging_uses_destdir] && !Chef::Config[:why_run]
|
61
|
+
::File.dirname(@new_resource.path)
|
62
|
+
else
|
63
|
+
Dir::tmpdir
|
64
|
+
end
|
58
65
|
end
|
59
66
|
end
|
60
67
|
end
|
data/lib/chef/formatters/base.rb
CHANGED
@@ -93,13 +93,6 @@ class Chef
|
|
93
93
|
|
94
94
|
def indent_by(amount)
|
95
95
|
@output.indent += amount
|
96
|
-
if @output.indent < 0
|
97
|
-
# This is left commented out for now. We need to uncomment it and fix at least one bug in
|
98
|
-
# the formatter, and then leave this line uncommented in the future.
|
99
|
-
#Chef::Log.warn "Internal Formatter Error -- Attempt to indent by negative number of spaces"
|
100
|
-
@output.indent = 0
|
101
|
-
end
|
102
|
-
@output.indent
|
103
96
|
end
|
104
97
|
|
105
98
|
# Input: a Formatters::ErrorDescription object.
|
data/lib/chef/http.rb
CHANGED
@@ -289,26 +289,11 @@ class Chef
|
|
289
289
|
def retrying_http_errors(url)
|
290
290
|
http_attempts = 0
|
291
291
|
begin
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
if response.kind_of?(Net::HTTPServerError)
|
297
|
-
if http_retry_count - http_attempts + 1 > 0
|
298
|
-
sleep_time = 1 + (2 ** http_attempts) + rand(2 ** http_attempts)
|
299
|
-
Chef::Log.error("Server returned error #{response.code} for #{url}, retrying #{http_attempts}/#{http_retry_count} in #{sleep_time}s")
|
300
|
-
sleep(sleep_time)
|
301
|
-
redo
|
302
|
-
end
|
303
|
-
end
|
304
|
-
return [response, request, return_value]
|
305
|
-
end
|
292
|
+
http_attempts += 1
|
293
|
+
|
294
|
+
yield
|
295
|
+
|
306
296
|
rescue SocketError, Errno::ETIMEDOUT => e
|
307
|
-
if http_retry_count - http_attempts + 1 > 0
|
308
|
-
Chef::Log.error("Error connecting to #{url}, retry #{http_attempts}/#{http_retry_count}")
|
309
|
-
sleep(http_retry_delay)
|
310
|
-
retry
|
311
|
-
end
|
312
297
|
e.message.replace "Error connecting to #{url} - #{e.message}"
|
313
298
|
raise e
|
314
299
|
rescue Errno::ECONNREFUSED
|
@@ -325,6 +310,14 @@ class Chef
|
|
325
310
|
retry
|
326
311
|
end
|
327
312
|
raise Timeout::Error, "Timeout connecting to #{url}, giving up"
|
313
|
+
rescue Net::HTTPFatalError => e
|
314
|
+
if http_retry_count - http_attempts + 1 > 0
|
315
|
+
sleep_time = 1 + (2 ** http_attempts) + rand(2 ** http_attempts)
|
316
|
+
Chef::Log.error("Server returned error for #{url}, retrying #{http_attempts}/#{http_retry_count} in #{sleep_time}s")
|
317
|
+
sleep(sleep_time)
|
318
|
+
retry
|
319
|
+
end
|
320
|
+
raise
|
328
321
|
end
|
329
322
|
end
|
330
323
|
|
data/lib/chef/http/json_input.rb
CHANGED
@@ -29,7 +29,8 @@ class Chef
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def handle_request(method, url, headers={}, data=false)
|
32
|
-
if data
|
32
|
+
if data && should_encode_as_json?(headers)
|
33
|
+
headers.delete_if { |key, _value| key.downcase == 'content-type' }
|
33
34
|
headers["Content-Type"] = 'application/json'
|
34
35
|
data = Chef::JSONCompat.to_json(data)
|
35
36
|
# Force encoding to binary to fix SSL related EOFErrors
|
@@ -52,6 +53,16 @@ class Chef
|
|
52
53
|
[http_response, rest_request, return_value]
|
53
54
|
end
|
54
55
|
|
56
|
+
private
|
57
|
+
|
58
|
+
def should_encode_as_json?(headers)
|
59
|
+
# ruby/Net::HTTP don't enforce capitalized headers (it normalizes them
|
60
|
+
# for you before sending the request), so we have to account for all
|
61
|
+
# the variations we might find
|
62
|
+
requested_content_type = headers.find {|k, v| k.downcase == "content-type" }
|
63
|
+
requested_content_type.nil? || requested_content_type.last.include?("json")
|
64
|
+
end
|
65
|
+
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
data/lib/chef/json_compat.rb
CHANGED
@@ -18,9 +18,7 @@
|
|
18
18
|
# Wrapper class for interacting with JSON.
|
19
19
|
|
20
20
|
require 'ffi_yajl'
|
21
|
-
require '
|
22
|
-
# We're requiring this to prevent breaking consumers using Hash.to_json
|
23
|
-
require 'json'
|
21
|
+
require 'ffi_yajl/json_gem' # XXX: parts of chef require JSON gem's Hash#to_json monkeypatch
|
24
22
|
|
25
23
|
class Chef
|
26
24
|
class JSONCompat
|
@@ -42,24 +40,15 @@ class Chef
|
|
42
40
|
|
43
41
|
class <<self
|
44
42
|
|
45
|
-
# API to use to avoid create_addtions
|
46
|
-
def parse(source, opts = {})
|
47
|
-
begin
|
48
|
-
FFI_Yajl::Parser.parse(source, opts)
|
49
|
-
rescue FFI_Yajl::ParseError => e
|
50
|
-
raise Chef::Exceptions::JSON::ParseError, e.message
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
43
|
# Just call the JSON gem's parse method with a modified :max_nesting field
|
55
44
|
def from_json(source, opts = {})
|
56
|
-
obj = parse(source
|
45
|
+
obj = ::FFI_Yajl::Parser.parse(source)
|
57
46
|
|
58
47
|
# JSON gem requires top level object to be a Hash or Array (otherwise
|
59
48
|
# you get the "must contain two octets" error). Yajl doesn't impose the
|
60
49
|
# same limitation. For compatibility, we re-impose this condition.
|
61
50
|
unless obj.kind_of?(Hash) or obj.kind_of?(Array)
|
62
|
-
raise
|
51
|
+
raise JSON::ParserError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})"
|
63
52
|
end
|
64
53
|
|
65
54
|
# The old default in the json gem (which we are mimicing because we
|
@@ -77,17 +66,17 @@ class Chef
|
|
77
66
|
# to an instance of Chef classes if desired.
|
78
67
|
def map_to_rb_obj(json_obj)
|
79
68
|
case json_obj
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
else
|
85
|
-
mapped_hash
|
86
|
-
end
|
87
|
-
when Array
|
88
|
-
json_obj.map {|e| map_to_rb_obj(e) }
|
69
|
+
when Hash
|
70
|
+
mapped_hash = map_hash_to_rb_obj(json_obj)
|
71
|
+
if json_obj.has_key?(JSON_CLASS) && (class_to_inflate = class_for_json_class(json_obj[JSON_CLASS]))
|
72
|
+
class_to_inflate.json_create(mapped_hash)
|
89
73
|
else
|
90
|
-
|
74
|
+
mapped_hash
|
75
|
+
end
|
76
|
+
when Array
|
77
|
+
json_obj.map {|e| map_to_rb_obj(e) }
|
78
|
+
else
|
79
|
+
json_obj
|
91
80
|
end
|
92
81
|
end
|
93
82
|
|
@@ -99,60 +88,52 @@ class Chef
|
|
99
88
|
end
|
100
89
|
|
101
90
|
def to_json(obj, opts = nil)
|
102
|
-
|
103
|
-
FFI_Yajl::Encoder.encode(obj, opts)
|
104
|
-
rescue FFI_Yajl::EncodeError => e
|
105
|
-
raise Chef::Exceptions::JSON::EncodeError, e.message
|
106
|
-
end
|
91
|
+
obj.to_json(opts)
|
107
92
|
end
|
108
93
|
|
109
94
|
def to_json_pretty(obj, opts = nil)
|
110
|
-
opts
|
111
|
-
options_map = {}
|
112
|
-
options_map[:pretty] = true
|
113
|
-
options_map[:indent] = opts[:indent] if opts.has_key?(:indent)
|
114
|
-
to_json(obj, options_map).chomp
|
95
|
+
::JSON.pretty_generate(obj, opts)
|
115
96
|
end
|
116
97
|
|
98
|
+
|
117
99
|
# Map +json_class+ to a Class object. We use a +case+ instead of a Hash
|
118
100
|
# assigned to a constant because otherwise this file could not be loaded
|
119
101
|
# until all the constants were defined, which means you'd have to load
|
120
102
|
# the world to get json, which would make knife very slow.
|
121
103
|
def class_for_json_class(json_class)
|
122
104
|
case json_class
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
105
|
+
when CHEF_APICLIENT
|
106
|
+
Chef::ApiClient
|
107
|
+
when CHEF_CHECKSUM
|
108
|
+
Chef::Checksum
|
109
|
+
when CHEF_COOKBOOKVERSION
|
110
|
+
Chef::CookbookVersion
|
111
|
+
when CHEF_DATABAG
|
112
|
+
Chef::DataBag
|
113
|
+
when CHEF_DATABAGITEM
|
114
|
+
Chef::DataBagItem
|
115
|
+
when CHEF_ENVIRONMENT
|
116
|
+
Chef::Environment
|
117
|
+
when CHEF_NODE
|
118
|
+
Chef::Node
|
119
|
+
when CHEF_ROLE
|
120
|
+
Chef::Role
|
121
|
+
when CHEF_SANDBOX
|
122
|
+
# a falsey return here will disable object inflation/"create
|
123
|
+
# additions" in the caller. In Chef 11 this is correct, we just have
|
124
|
+
# a dummy Chef::Sandbox class for compat with Chef 10 servers.
|
125
|
+
false
|
126
|
+
when CHEF_RESOURCE
|
127
|
+
Chef::Resource
|
128
|
+
when CHEF_RESOURCECOLLECTION
|
129
|
+
Chef::ResourceCollection
|
130
|
+
when /^Chef::Resource/
|
131
|
+
Chef::Resource.find_subclass_by_name(json_class)
|
132
|
+
else
|
133
|
+
raise JSON::ParserError, "Unsupported `json_class` type '#{json_class}'"
|
152
134
|
end
|
153
135
|
end
|
154
136
|
|
155
137
|
end
|
156
138
|
end
|
157
139
|
end
|
158
|
-
|
data/lib/chef/knife.rb
CHANGED
@@ -25,6 +25,7 @@ require 'chef/mixin/convert_to_class_name'
|
|
25
25
|
require 'chef/mixin/path_sanity'
|
26
26
|
require 'chef/knife/core/subcommand_loader'
|
27
27
|
require 'chef/knife/core/ui'
|
28
|
+
require 'chef/local_mode'
|
28
29
|
require 'chef/rest'
|
29
30
|
require 'pp'
|
30
31
|
|
@@ -488,11 +489,8 @@ class Chef
|
|
488
489
|
ui.error "You need to add a #run method to your knife command before you can use it"
|
489
490
|
end
|
490
491
|
enforce_path_sanity
|
491
|
-
Chef::
|
492
|
-
begin
|
492
|
+
Chef::LocalMode.with_server_connectivity do
|
493
493
|
run
|
494
|
-
ensure
|
495
|
-
Chef::Application.destroy_server_connectivity
|
496
494
|
end
|
497
495
|
rescue Exception => e
|
498
496
|
raise if raise_exception || Chef::Config[:verbosity] == 2
|
@@ -625,4 +623,3 @@ class Chef
|
|
625
623
|
|
626
624
|
end
|
627
625
|
end
|
628
|
-
|
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -126,7 +126,7 @@ class Chef
|
|
126
126
|
:short => "-j JSON_ATTRIBS",
|
127
127
|
:long => "--json-attributes",
|
128
128
|
:description => "A JSON string to be added to the first run of chef-client",
|
129
|
-
:proc => lambda { |o|
|
129
|
+
:proc => lambda { |o| JSON.parse(o) },
|
130
130
|
:default => {}
|
131
131
|
|
132
132
|
option :host_key_verify,
|
@@ -141,7 +141,7 @@ class Chef
|
|
141
141
|
:proc => Proc.new { |h|
|
142
142
|
Chef::Config[:knife][:hints] ||= Hash.new
|
143
143
|
name, path = h.split("=")
|
144
|
-
Chef::Config[:knife][:hints][name] = path ?
|
144
|
+
Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : Hash.new }
|
145
145
|
|
146
146
|
option :secret,
|
147
147
|
:short => "-s SECRET",
|
@@ -29,7 +29,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
29
29
|
|
30
30
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
31
31
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
32
|
-
<%=
|
32
|
+
<%= hash.to_json %>
|
33
33
|
EOP
|
34
34
|
<% end -%>
|
35
35
|
<% end -%>
|
@@ -56,7 +56,7 @@ https_proxy "<%= knife_config[:bootstrap_proxy] %>"
|
|
56
56
|
EOP
|
57
57
|
|
58
58
|
cat > /etc/chef/first-boot.json <<'EOP'
|
59
|
-
<%=
|
59
|
+
<%= first_boot.to_json %>
|
60
60
|
EOP
|
61
61
|
|
62
62
|
<%= start_chef %>'
|
@@ -46,7 +46,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
46
46
|
|
47
47
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
48
48
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
49
|
-
<%=
|
49
|
+
<%= hash.to_json %>
|
50
50
|
EOP
|
51
51
|
<% end -%>
|
52
52
|
<% end -%>
|
@@ -56,7 +56,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
56
56
|
EOP
|
57
57
|
|
58
58
|
cat > /etc/chef/first-boot.json <<'EOP'
|
59
|
-
<%=
|
59
|
+
<%= first_boot.to_json %>
|
60
60
|
EOP
|
61
61
|
|
62
62
|
<%= start_chef %>'
|
@@ -42,7 +42,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
42
42
|
|
43
43
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
44
44
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
45
|
-
<%=
|
45
|
+
<%= hash.to_json %>
|
46
46
|
EOP
|
47
47
|
<% end -%>
|
48
48
|
<% end -%>
|
@@ -52,7 +52,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
52
52
|
EOP
|
53
53
|
|
54
54
|
cat > /etc/chef/first-boot.json <<'EOP'
|
55
|
-
<%=
|
55
|
+
<%= first_boot.to_json %>
|
56
56
|
EOP
|
57
57
|
|
58
58
|
<%= start_chef %>'
|