chef 12.4.3-universal-mingw32 → 12.5.1-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +21 -25
- data/Gemfile +46 -0
- data/README.md +4 -4
- data/Rakefile +4 -110
- data/bin/chef-service-manager +3 -1
- data/distro/common/html/knife_cookbook_site.html +18 -18
- data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
- data/lib/chef.rb +1 -1
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +19 -1
- data/lib/chef/application/client.rb +11 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/application/windows_service_manager.rb +19 -12
- data/lib/chef/chef_class.rb +46 -0
- data/lib/chef/chef_fs/config.rb +22 -24
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
- data/lib/chef/chef_fs/file_pattern.rb +4 -15
- data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +4 -4
- data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
- data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
- data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
- data/lib/chef/chef_fs/knife.rb +35 -7
- data/lib/chef/chef_fs/path_utils.rb +65 -34
- data/lib/chef/client.rb +2 -3
- data/lib/chef/config.rb +34 -2
- data/lib/chef/{mixin/wstring.rb → constants.rb} +9 -13
- data/lib/chef/cookbook/metadata.rb +25 -3
- data/lib/chef/cookbook/synchronizer.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/delayed_evaluator.rb +21 -0
- data/lib/chef/deprecation/mixin/template.rb +1 -2
- data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
- data/lib/chef/deprecation/provider/file.rb +1 -1
- data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
- data/lib/chef/deprecation/provider/remote_file.rb +1 -2
- data/lib/chef/deprecation/provider/template.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +3 -4
- data/lib/chef/dsl/reboot_pending.rb +3 -2
- data/lib/chef/dsl/recipe.rb +26 -7
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +51 -22
- data/lib/chef/event_dispatch/dispatcher.rb +21 -6
- data/lib/chef/event_dispatch/dsl.rb +64 -0
- data/lib/chef/exceptions.rb +28 -1
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +3 -0
- data/lib/chef/formatters/doc.rb +56 -6
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
- data/lib/chef/formatters/minimal.rb +2 -2
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +3 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/knife.rb +35 -55
- data/lib/chef/knife/bootstrap.rb +41 -0
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
- data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
- data/lib/chef/knife/bootstrap/templates/README.md +3 -4
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +1 -1
- data/lib/chef/knife/cookbook_create.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +6 -6
- data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
- data/lib/chef/knife/core/bootstrap_context.rb +12 -4
- data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
- data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
- data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
- data/lib/chef/knife/core/node_presenter.rb +24 -1
- data/lib/chef/knife/core/object_loader.rb +1 -0
- data/lib/chef/knife/core/subcommand_loader.rb +131 -146
- data/lib/chef/knife/node_run_list_remove.rb +12 -1
- data/lib/chef/knife/null.rb +10 -0
- data/lib/chef/knife/rehash.rb +62 -0
- data/lib/chef/knife/search.rb +3 -3
- data/lib/chef/knife/ssh.rb +52 -30
- data/lib/chef/knife/ssl_check.rb +3 -2
- data/lib/chef/knife/user_edit.rb +1 -2
- data/lib/chef/local_mode.rb +5 -0
- data/lib/chef/log.rb +5 -1
- data/lib/chef/mixin/deprecation.rb +8 -8
- data/lib/chef/mixin/params_validate.rb +362 -135
- data/lib/chef/mixin/template.rb +48 -0
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/mixin/wide_string.rb +72 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
- data/lib/chef/mixin/windows_env_helper.rb +4 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
- data/lib/chef/monkey_patches/win32/registry.rb +72 -0
- data/lib/chef/node.rb +116 -3
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/handler_map.rb +0 -5
- data/lib/chef/platform/provider_mapping.rb +5 -6
- data/lib/chef/platform/query_helpers.rb +46 -4
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +30 -32
- data/lib/chef/policy_builder.rb +1 -8
- data/lib/chef/policy_builder/dynamic.rb +186 -0
- data/lib/chef/policy_builder/expand_node_object.rb +30 -15
- data/lib/chef/policy_builder/policyfile.rb +155 -18
- data/lib/chef/property.rb +568 -0
- data/lib/chef/provider.rb +222 -13
- data/lib/chef/provider/batch.rb +8 -0
- data/lib/chef/provider/deploy.rb +5 -7
- data/lib/chef/provider/directory.rb +14 -2
- data/lib/chef/provider/dsc_resource.rb +5 -9
- data/lib/chef/provider/group/pw.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/lwrp_base.rb +1 -75
- data/lib/chef/provider/mount.rb +7 -3
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +5 -11
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +17 -5
- data/lib/chef/provider/powershell_script.rb +59 -23
- data/lib/chef/provider/registry_key.rb +5 -5
- data/lib/chef/provider/remote_directory.rb +190 -102
- data/lib/chef/provider/service.rb +12 -2
- data/lib/chef/provider/service/aix.rb +1 -1
- data/lib/chef/provider/service/debian.rb +3 -5
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +3 -3
- data/lib/chef/provider/service/init.rb +3 -3
- data/lib/chef/provider/service/insserv.rb +2 -4
- data/lib/chef/provider/service/invokercd.rb +2 -4
- data/lib/chef/provider/service/macosx.rb +5 -1
- data/lib/chef/provider/service/openbsd.rb +2 -1
- data/lib/chef/provider/service/redhat.rb +52 -16
- data/lib/chef/provider/service/simple.rb +2 -2
- data/lib/chef/provider/service/systemd.rb +3 -5
- data/lib/chef/provider/service/upstart.rb +4 -6
- data/lib/chef/provider/subversion.rb +13 -7
- data/lib/chef/provider/template/content.rb +16 -6
- data/lib/chef/provider/user/solaris.rb +32 -4
- data/lib/chef/provider/windows_script.rb +3 -5
- data/lib/chef/provider_resolver.rb +2 -2
- data/lib/chef/recipe.rb +1 -8
- data/lib/chef/resource.rb +563 -90
- data/lib/chef/resource/action_class.rb +83 -0
- data/lib/chef/resource/chef_gem.rb +3 -3
- data/lib/chef/resource/deploy.rb +8 -2
- data/lib/chef/resource/dsc_script.rb +2 -0
- data/lib/chef/resource/file/verification.rb +7 -1
- data/lib/chef/resource/lwrp_base.rb +1 -7
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/service.rb +10 -2
- data/lib/chef/resource/subversion.rb +5 -0
- data/lib/chef/resource/windows_script.rb +6 -2
- data/lib/chef/resource/yum_package.rb +10 -1
- data/lib/chef/resource_resolver.rb +3 -3
- data/lib/chef/run_context.rb +402 -83
- data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
- data/lib/chef/run_lock.rb +30 -21
- data/lib/chef/util/powershell/ps_credential.rb +4 -0
- data/lib/chef/util/windows.rb +0 -32
- data/lib/chef/util/windows/net_group.rb +85 -106
- data/lib/chef/util/windows/net_use.rb +35 -71
- data/lib/chef/util/windows/net_user.rb +0 -1
- data/lib/chef/util/windows/volume.rb +19 -19
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api.rb +1 -0
- data/lib/chef/win32/api/file.rb +20 -0
- data/lib/chef/win32/api/net.rb +163 -43
- data/lib/chef/win32/api/registry.rb +51 -0
- data/lib/chef/win32/api/system.rb +23 -0
- data/lib/chef/win32/api/unicode.rb +0 -43
- data/lib/chef/win32/crypto.rb +2 -1
- data/lib/chef/win32/file.rb +28 -3
- data/lib/chef/win32/mutex.rb +1 -2
- data/lib/chef/win32/net.rb +162 -8
- data/lib/chef/win32/process.rb +13 -0
- data/lib/chef/win32/registry.rb +35 -30
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/token.rb +1 -1
- data/lib/chef/win32/system.rb +62 -0
- data/lib/chef/win32/unicode.rb +7 -2
- data/lib/chef/win32/version.rb +0 -4
- data/lib/chef/workstation_config_loader.rb +3 -158
- data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
- data/spec/data/dsc_lcm.pfx +0 -0
- data/spec/data/run_context/cookbooks/include/recipes/default.rb +24 -0
- data/spec/data/run_context/cookbooks/include/recipes/includee.rb +3 -0
- data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
- data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
- data/spec/functional/knife/ssh_spec.rb +16 -0
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +2 -0
- data/spec/functional/resource/dsc_script_spec.rb +91 -2
- data/spec/functional/resource/group_spec.rb +67 -44
- data/spec/functional/resource/{powershell_spec.rb → powershell_script_spec.rb} +107 -18
- data/spec/functional/resource/windows_service_spec.rb +1 -1
- data/spec/functional/run_lock_spec.rb +368 -189
- data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +16 -23
- data/spec/functional/win32/service_manager_spec.rb +2 -2
- data/spec/integration/client/client_spec.rb +51 -0
- data/spec/integration/knife/chef_repo_path_spec.rb +13 -11
- data/spec/integration/knife/download_spec.rb +4 -0
- data/spec/integration/knife/list_spec.rb +8 -0
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -16
- data/spec/integration/recipes/remote_directory.rb +74 -0
- data/spec/integration/recipes/resource_action_spec.rb +363 -0
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
- data/spec/integration/recipes/resource_load_spec.rb +206 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/platform_helpers.rb +13 -0
- data/spec/support/shared/context/win32.rb +34 -0
- data/spec/support/shared/functional/win32_service.rb +2 -1
- data/spec/support/shared/functional/windows_script.rb +63 -26
- data/spec/support/shared/unit/mock_shellout.rb +46 -0
- data/spec/support/shared/unit/provider/file.rb +10 -4
- data/spec/unit/application/client_spec.rb +16 -3
- data/spec/unit/application/knife_spec.rb +2 -2
- data/spec/unit/application/solo_spec.rb +4 -3
- data/spec/unit/chef_class_spec.rb +23 -4
- data/spec/unit/chef_fs/path_util_spec.rb +108 -0
- data/spec/unit/client_spec.rb +6 -1
- data/spec/unit/config_spec.rb +31 -0
- data/spec/unit/cookbook/metadata_spec.rb +23 -3
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/deprecation_spec.rb +3 -6
- data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
- data/spec/unit/event_dispatch/dsl_spec.rb +83 -0
- data/spec/unit/formatters/doc_spec.rb +32 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
- data/spec/unit/json_compat_spec.rb +4 -3
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -3
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
- data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
- data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
- data/spec/unit/knife/ssl_check_spec.rb +4 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
- data/spec/unit/mixin/params_validate_spec.rb +4 -2
- data/spec/unit/mixin/template_spec.rb +5 -1
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
- data/spec/unit/node_spec.rb +220 -0
- data/spec/unit/platform/query_helpers_spec.rb +146 -3
- data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
- data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
- data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
- data/spec/unit/property/state_spec.rb +506 -0
- data/spec/unit/property/validation_spec.rb +663 -0
- data/spec/unit/property_spec.rb +1094 -0
- data/spec/unit/provider/deploy_spec.rb +5 -5
- data/spec/unit/provider/directory_spec.rb +35 -0
- data/spec/unit/provider/dsc_resource_spec.rb +3 -10
- data/spec/unit/provider/ifconfig_spec.rb +22 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -1
- data/spec/unit/provider/mount/mount_spec.rb +6 -0
- data/spec/unit/provider/mount/windows_spec.rb +14 -0
- data/spec/unit/provider/mount_spec.rb +12 -1
- data/spec/unit/provider/package/dpkg_spec.rb +8 -1
- data/spec/unit/provider/package/rpm_spec.rb +18 -1
- data/spec/unit/provider/package/rubygems_spec.rb +18 -0
- data/spec/unit/provider/package/yum_spec.rb +97 -24
- data/spec/unit/provider/powershell_script_spec.rb +106 -0
- data/spec/unit/provider/registry_key_spec.rb +12 -0
- data/spec/unit/provider/remote_directory_spec.rb +1 -2
- data/spec/unit/provider/service/aix_service_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
- data/spec/unit/provider/service/macosx_spec.rb +4 -4
- data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
- data/spec/unit/provider/service/redhat_spec.rb +88 -8
- data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
- data/spec/unit/provider/service/windows_spec.rb +211 -200
- data/spec/unit/provider/subversion_spec.rb +50 -31
- data/spec/unit/provider/template/content_spec.rb +93 -2
- data/spec/unit/provider/user/solaris_spec.rb +66 -9
- data/spec/unit/provider_resolver_spec.rb +707 -650
- data/spec/unit/provider_spec.rb +1 -3
- data/spec/unit/recipe_spec.rb +0 -4
- data/spec/unit/resource/deploy_spec.rb +7 -1
- data/spec/unit/resource/dsc_script_spec.rb +4 -0
- data/spec/unit/resource/file/verification_spec.rb +33 -5
- data/spec/unit/resource/{powershell_spec.rb → powershell_script_spec.rb} +17 -13
- data/spec/unit/resource/service_spec.rb +4 -4
- data/spec/unit/resource/subversion_spec.rb +4 -0
- data/spec/unit/resource/yum_package_spec.rb +10 -1
- data/spec/unit/resource_spec.rb +2 -2
- data/spec/unit/run_context/child_run_context_spec.rb +133 -0
- data/spec/unit/run_context_spec.rb +7 -0
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
- data/spec/unit/win32/registry_spec.rb +394 -0
- data/tasks/external_tests.rb +47 -23
- data/tasks/maintainers.rb +155 -14
- metadata +64 -53
- data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
- data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
- data/spec/unit/provider/powershell_spec.rb +0 -80
- data/spec/unit/registry_helper_spec.rb +0 -376
- data/spec/unit/workstation_config_loader_spec.rb +0 -283
data/lib/chef/provider.rb
CHANGED
@@ -26,6 +26,7 @@ require 'chef/mixin/powershell_out'
|
|
26
26
|
require 'chef/mixin/provides'
|
27
27
|
require 'chef/platform/service_helpers'
|
28
28
|
require 'chef/node_map'
|
29
|
+
require 'forwardable'
|
29
30
|
|
30
31
|
class Chef
|
31
32
|
class Provider
|
@@ -65,6 +66,7 @@ class Chef
|
|
65
66
|
|
66
67
|
@recipe_name = nil
|
67
68
|
@cookbook_name = nil
|
69
|
+
self.class.include_resource_dsl_module(new_resource)
|
68
70
|
end
|
69
71
|
|
70
72
|
def whyrun_mode?
|
@@ -119,11 +121,11 @@ class Chef
|
|
119
121
|
check_resource_semantics!
|
120
122
|
|
121
123
|
# user-defined LWRPs may include unsafe load_current_resource methods that cannot be run in whyrun mode
|
122
|
-
if
|
124
|
+
if whyrun_mode? && !whyrun_supported?
|
125
|
+
events.resource_current_state_load_bypassed(@new_resource, @action, @current_resource)
|
126
|
+
else
|
123
127
|
load_current_resource
|
124
128
|
events.resource_current_state_loaded(@new_resource, @action, @current_resource)
|
125
|
-
elsif whyrun_mode? && !whyrun_supported?
|
126
|
-
events.resource_current_state_load_bypassed(@new_resource, @action, @current_resource)
|
127
129
|
end
|
128
130
|
|
129
131
|
define_resource_requirements
|
@@ -136,9 +138,7 @@ class Chef
|
|
136
138
|
# we can't execute the action.
|
137
139
|
# in non-whyrun mode, this will still cause the action to be
|
138
140
|
# executed normally.
|
139
|
-
if
|
140
|
-
send("action_#{@action}")
|
141
|
-
elsif whyrun_mode?
|
141
|
+
if whyrun_mode? && (!whyrun_supported? || requirements.action_blocked?(@action))
|
142
142
|
events.resource_bypassed(@new_resource, @action, self)
|
143
143
|
else
|
144
144
|
send("action_#{@action}")
|
@@ -175,6 +175,62 @@ class Chef
|
|
175
175
|
converge_actions.add_action(descriptions, &block)
|
176
176
|
end
|
177
177
|
|
178
|
+
#
|
179
|
+
# Handle patchy convergence safely.
|
180
|
+
#
|
181
|
+
# - Does *not* call the block if the current_resource's properties match
|
182
|
+
# the properties the user specified on the resource.
|
183
|
+
# - Calls the block if current_resource does not exist
|
184
|
+
# - Calls the block if the user has specified any properties in the resource
|
185
|
+
# whose values are *different* from current_resource.
|
186
|
+
# - Does *not* call the block if why-run is enabled (just prints out text).
|
187
|
+
# - Prints out automatic green text saying what properties have changed.
|
188
|
+
#
|
189
|
+
# @param properties An optional list of property names (symbols). If not
|
190
|
+
# specified, `new_resource.class.state_properties` will be used.
|
191
|
+
# @param converge_block The block to do the converging in.
|
192
|
+
#
|
193
|
+
# @return [Boolean] whether the block was executed.
|
194
|
+
#
|
195
|
+
def converge_if_changed(*properties, &converge_block)
|
196
|
+
if !converge_block
|
197
|
+
raise ArgumentError, "converge_if_changed must be passed a block!"
|
198
|
+
end
|
199
|
+
|
200
|
+
properties = new_resource.class.state_properties.map { |p| p.name } if properties.empty?
|
201
|
+
properties = properties.map { |p| p.to_sym }
|
202
|
+
if current_resource
|
203
|
+
# Collect the list of modified properties
|
204
|
+
specified_properties = properties.select { |property| new_resource.property_is_set?(property) }
|
205
|
+
modified = specified_properties.select { |p| new_resource.send(p) != current_resource.send(p) }
|
206
|
+
if modified.empty?
|
207
|
+
Chef::Log.debug("Skipping update of #{new_resource.to_s}: has not changed any of the specified properties #{specified_properties.map { |p| "#{p}=#{new_resource.send(p).inspect}" }.join(", ")}.")
|
208
|
+
return false
|
209
|
+
end
|
210
|
+
|
211
|
+
# Print the pretty green text and run the block
|
212
|
+
property_size = modified.map { |p| p.size }.max
|
213
|
+
modified = modified.map { |p| " set #{p.to_s.ljust(property_size)} to #{new_resource.send(p).inspect} (was #{current_resource.send(p).inspect})" }
|
214
|
+
converge_by([ "update #{current_resource.identity}" ] + modified, &converge_block)
|
215
|
+
|
216
|
+
else
|
217
|
+
# The resource doesn't exist. Mark that we are *creating* this, and
|
218
|
+
# write down any properties we are setting.
|
219
|
+
property_size = properties.map { |p| p.size }.max
|
220
|
+
created = []
|
221
|
+
properties.each do |property|
|
222
|
+
if new_resource.property_is_set?(property)
|
223
|
+
created << " set #{property.to_s.ljust(property_size)} to #{new_resource.send(property).inspect}"
|
224
|
+
else
|
225
|
+
created << " set #{property.to_s.ljust(property_size)} to #{new_resource.send(property).inspect} (default value)"
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
converge_by([ "create #{new_resource.identity}" ] + created, &converge_block)
|
230
|
+
end
|
231
|
+
true
|
232
|
+
end
|
233
|
+
|
178
234
|
def self.provides(short_name, opts={}, &block)
|
179
235
|
Chef.provider_handler_map.set(short_name, self, opts, &block)
|
180
236
|
end
|
@@ -183,6 +239,157 @@ class Chef
|
|
183
239
|
Chef::ProviderResolver.new(node, resource, :nothing).provided_by?(self)
|
184
240
|
end
|
185
241
|
|
242
|
+
#
|
243
|
+
# Include attributes, public and protected methods from this Resource in
|
244
|
+
# the provider.
|
245
|
+
#
|
246
|
+
# If this is set to true, delegate methods are included in the provider so
|
247
|
+
# that you can call (for example) `attrname` and it will call
|
248
|
+
# `new_resource.attrname`.
|
249
|
+
#
|
250
|
+
# The actual include does not happen until the first time the Provider
|
251
|
+
# is instantiated (so that we don't have to worry about load order issues).
|
252
|
+
#
|
253
|
+
# @param include_resource_dsl [Boolean] Whether to include resource DSL or
|
254
|
+
# not (defaults to `false`).
|
255
|
+
#
|
256
|
+
def self.include_resource_dsl(include_resource_dsl)
|
257
|
+
@include_resource_dsl = include_resource_dsl
|
258
|
+
end
|
259
|
+
|
260
|
+
# Create the resource DSL module that forwards resource methods to new_resource
|
261
|
+
#
|
262
|
+
# @api private
|
263
|
+
def self.include_resource_dsl_module(resource)
|
264
|
+
if @include_resource_dsl && !defined?(@included_resource_dsl_module)
|
265
|
+
provider_class = self
|
266
|
+
@included_resource_dsl_module = Module.new do
|
267
|
+
extend Forwardable
|
268
|
+
define_singleton_method(:to_s) { "forwarder module for #{provider_class}" }
|
269
|
+
define_singleton_method(:inspect) { to_s }
|
270
|
+
# Add a delegator for each explicit property that will get the *current* value
|
271
|
+
# of the property by default instead of the *actual* value.
|
272
|
+
resource.class.properties.each do |name, property|
|
273
|
+
class_eval(<<-EOM, __FILE__, __LINE__)
|
274
|
+
def #{name}(*args, &block)
|
275
|
+
# If no arguments were passed, we process "get" by defaulting
|
276
|
+
# the value to current_resource, not new_resource. This helps
|
277
|
+
# avoid issues where resources accidentally overwrite perfectly
|
278
|
+
# valid stuff with default values.
|
279
|
+
if args.empty? && !block
|
280
|
+
if !new_resource.property_is_set?(__method__) && current_resource
|
281
|
+
return current_resource.public_send(__method__)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
new_resource.public_send(__method__, *args, &block)
|
285
|
+
end
|
286
|
+
EOM
|
287
|
+
end
|
288
|
+
dsl_methods =
|
289
|
+
resource.class.public_instance_methods +
|
290
|
+
resource.class.protected_instance_methods -
|
291
|
+
provider_class.instance_methods -
|
292
|
+
resource.class.properties.keys
|
293
|
+
def_delegators(:new_resource, *dsl_methods)
|
294
|
+
end
|
295
|
+
include @included_resource_dsl_module
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
# Enables inline evaluation of resources in provider actions.
|
300
|
+
#
|
301
|
+
# Without this option, any resources declared inside the Provider are added
|
302
|
+
# to the resource collection after the current position at the time the
|
303
|
+
# action is executed. Because they are added to the primary resource
|
304
|
+
# collection for the chef run, they can notify other resources outside
|
305
|
+
# the Provider, and potentially be notified by resources outside the Provider
|
306
|
+
# (but this is complicated by the fact that they don't exist until the
|
307
|
+
# provider executes). In this mode, it is impossible to correctly set the
|
308
|
+
# updated_by_last_action flag on the parent Provider resource, since it
|
309
|
+
# executes and returns before its component resources are run.
|
310
|
+
#
|
311
|
+
# With this option enabled, each action creates a temporary run_context
|
312
|
+
# with its own resource collection, evaluates the action's code in that
|
313
|
+
# context, and then converges the resources created. If any resources
|
314
|
+
# were updated, then this provider's new_resource will be marked updated.
|
315
|
+
#
|
316
|
+
# In this mode, resources created within the Provider cannot interact with
|
317
|
+
# external resources via notifies, though notifications to other
|
318
|
+
# resources within the Provider will work. Delayed notifications are executed
|
319
|
+
# at the conclusion of the provider's action, *not* at the end of the
|
320
|
+
# main chef run.
|
321
|
+
#
|
322
|
+
# This mode of evaluation is experimental, but is believed to be a better
|
323
|
+
# set of tradeoffs than the append-after mode, so it will likely become
|
324
|
+
# the default in a future major release of Chef.
|
325
|
+
#
|
326
|
+
def self.use_inline_resources
|
327
|
+
extend InlineResources::ClassMethods
|
328
|
+
include InlineResources
|
329
|
+
end
|
330
|
+
|
331
|
+
# Chef::Provider::InlineResources
|
332
|
+
# Implementation of inline resource convergence for providers. See
|
333
|
+
# Provider.use_inline_resources for a longer explanation.
|
334
|
+
#
|
335
|
+
# This code is restricted to a module so that it can be selectively
|
336
|
+
# applied to providers on an opt-in basis.
|
337
|
+
#
|
338
|
+
# @api private
|
339
|
+
module InlineResources
|
340
|
+
|
341
|
+
# Our run context is a child of the main run context; that gives us a
|
342
|
+
# whole new resource collection and notification set.
|
343
|
+
def initialize(resource, run_context)
|
344
|
+
super(resource, run_context.create_child)
|
345
|
+
end
|
346
|
+
|
347
|
+
# Class methods for InlineResources. Overrides the `action` DSL method
|
348
|
+
# with one that enables inline resource convergence.
|
349
|
+
#
|
350
|
+
# @api private
|
351
|
+
module ClassMethods
|
352
|
+
# Defines an action method on the provider, running the block to
|
353
|
+
# compile the resources, converging them, and then checking if any
|
354
|
+
# were updated (and updating new-resource if so)
|
355
|
+
def action(name, &block)
|
356
|
+
# We first try to create the method using "def method_name", which is
|
357
|
+
# preferred because it actually shows up in stack traces. If that
|
358
|
+
# fails, we try define_method.
|
359
|
+
begin
|
360
|
+
class_eval <<-EOM, __FILE__, __LINE__+1
|
361
|
+
def action_#{name}
|
362
|
+
return_value = compile_action_#{name}
|
363
|
+
Chef::Runner.new(run_context).converge
|
364
|
+
return_value
|
365
|
+
ensure
|
366
|
+
if run_context.resource_collection.any? {|r| r.updated? }
|
367
|
+
new_resource.updated_by_last_action(true)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
EOM
|
371
|
+
rescue SyntaxError
|
372
|
+
define_method("action_#{name}") do
|
373
|
+
begin
|
374
|
+
return_value = send("compile_action_#{name}")
|
375
|
+
Chef::Runner.new(run_context).converge
|
376
|
+
return_value
|
377
|
+
ensure
|
378
|
+
if run_context.resource_collection.any? {|r| r.updated? }
|
379
|
+
new_resource.updated_by_last_action(true)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
# We put the action in its own method so that super() works.
|
385
|
+
define_method("compile_action_#{name}", &block)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
require 'chef/dsl/recipe'
|
390
|
+
include Chef::DSL::Recipe::FullDSL
|
391
|
+
end
|
392
|
+
|
186
393
|
protected
|
187
394
|
|
188
395
|
def converge_actions
|
@@ -200,19 +407,21 @@ class Chef
|
|
200
407
|
# manipulating notifies.
|
201
408
|
|
202
409
|
converge_by ("evaluate block and run any associated actions") do
|
203
|
-
saved_run_context =
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
410
|
+
saved_run_context = run_context
|
411
|
+
begin
|
412
|
+
@run_context = run_context.create_child
|
413
|
+
instance_eval(&block)
|
414
|
+
Chef::Runner.new(run_context).converge
|
415
|
+
ensure
|
416
|
+
@run_context = saved_run_context
|
417
|
+
end
|
209
418
|
end
|
210
419
|
end
|
211
420
|
|
212
421
|
module DeprecatedLWRPClass
|
213
422
|
def const_missing(class_name)
|
214
423
|
if deprecated_constants[class_name.to_sym]
|
215
|
-
Chef
|
424
|
+
Chef.log_deprecation("Using an LWRP provider by its name (#{class_name}) directly is no longer supported in Chef 12 and will be removed. Use Chef::ProviderResolver.new(node, resource, action) instead.")
|
216
425
|
deprecated_constants[class_name.to_sym]
|
217
426
|
else
|
218
427
|
raise NameError, "uninitialized constant Chef::Provider::#{class_name}"
|
data/lib/chef/provider/batch.rb
CHANGED
@@ -28,6 +28,14 @@ class Chef
|
|
28
28
|
super(new_resource, run_context, '.bat')
|
29
29
|
end
|
30
30
|
|
31
|
+
def command
|
32
|
+
basepath = is_forced_32bit ? wow64_directory : run_context.node.kernel.os_info.system_directory
|
33
|
+
|
34
|
+
interpreter_path = Chef::Util::PathHelper.join(basepath, interpreter)
|
35
|
+
|
36
|
+
"\"#{interpreter_path}\" #{flags} \"#{script_file.path}\""
|
37
|
+
end
|
38
|
+
|
31
39
|
def flags
|
32
40
|
@new_resource.flags.nil? ? '/c' : new_resource.flags + ' /c'
|
33
41
|
end
|
data/lib/chef/provider/deploy.rb
CHANGED
@@ -201,7 +201,7 @@ class Chef
|
|
201
201
|
|
202
202
|
converge_by("execute migration command #{@new_resource.migration_command}") do
|
203
203
|
Chef::Log.info "#{@new_resource} migrating #{@new_resource.user} with environment #{env_info}"
|
204
|
-
|
204
|
+
shell_out!(@new_resource.migration_command,run_options(:cwd=>release_path, :log_level => :info))
|
205
205
|
end
|
206
206
|
end
|
207
207
|
end
|
@@ -221,7 +221,7 @@ class Chef
|
|
221
221
|
else
|
222
222
|
converge_by("restart app using command #{@new_resource.restart_command}") do
|
223
223
|
Chef::Log.info("#{@new_resource} restarting app")
|
224
|
-
|
224
|
+
shell_out!(@new_resource.restart_command,run_options(:cwd=>@new_resource.current_path))
|
225
225
|
end
|
226
226
|
end
|
227
227
|
end
|
@@ -373,11 +373,9 @@ class Chef
|
|
373
373
|
end
|
374
374
|
|
375
375
|
def gem_resource_collection_runner
|
376
|
-
|
377
|
-
gem_packages.each { |rbgem|
|
378
|
-
|
379
|
-
gems_run_context.resource_collection = gems_collection
|
380
|
-
Chef::Runner.new(gems_run_context)
|
376
|
+
child_context = run_context.create_child
|
377
|
+
gem_packages.each { |rbgem| child_context.resource_collection.insert(rbgem) }
|
378
|
+
Chef::Runner.new(child_context)
|
381
379
|
end
|
382
380
|
|
383
381
|
def gem_packages
|
@@ -64,7 +64,13 @@ class Chef
|
|
64
64
|
is_parent_writable = lambda do |base_dir|
|
65
65
|
base_dir = ::File.dirname(base_dir)
|
66
66
|
if ::File.exists?(base_dir)
|
67
|
-
Chef::FileAccessControl.writable?(base_dir)
|
67
|
+
if Chef::FileAccessControl.writable?(base_dir)
|
68
|
+
true
|
69
|
+
elsif Chef::Util::PathHelper.is_sip_path?(base_dir, node)
|
70
|
+
Chef::Util::PathHelper.writable_sip_path?(base_dir)
|
71
|
+
else
|
72
|
+
false
|
73
|
+
end
|
68
74
|
else
|
69
75
|
is_parent_writable.call(base_dir)
|
70
76
|
end
|
@@ -74,7 +80,13 @@ class Chef
|
|
74
80
|
# in why run mode & parent directory does not exist no permissions check is required
|
75
81
|
# If not in why run, permissions must be valid and we rely on prior assertion that dir exists
|
76
82
|
if !whyrun_mode? || ::File.exists?(parent_directory)
|
77
|
-
Chef::FileAccessControl.writable?(parent_directory)
|
83
|
+
if Chef::FileAccessControl.writable?(parent_directory)
|
84
|
+
true
|
85
|
+
elsif Chef::Util::PathHelper.is_sip_path?(parent_directory, node)
|
86
|
+
Chef::Util::PathHelper.writable_sip_path?(@new_resource.path)
|
87
|
+
else
|
88
|
+
false
|
89
|
+
end
|
78
90
|
else
|
79
91
|
true
|
80
92
|
end
|
@@ -59,9 +59,7 @@ class Chef
|
|
59
59
|
a.block_action!
|
60
60
|
end
|
61
61
|
requirements.assert(:run) do |a|
|
62
|
-
a.assertion {
|
63
|
-
meta_configuration['RefreshMode'] == 'Disabled'
|
64
|
-
}
|
62
|
+
a.assertion { dsc_refresh_mode_disabled? }
|
65
63
|
err = ["The LCM must have its RefreshMode set to Disabled. "]
|
66
64
|
a.failure_message Chef::Exceptions::ProviderNotFound, err.join(' ')
|
67
65
|
a.whyrun err + ["Assuming a previous resource sets the RefreshMode."]
|
@@ -85,6 +83,10 @@ class Chef
|
|
85
83
|
def supports_dsc_invoke_resource?
|
86
84
|
run_context && Chef::Platform.supports_dsc_invoke_resource?(node)
|
87
85
|
end
|
86
|
+
|
87
|
+
def dsc_refresh_mode_disabled?
|
88
|
+
Chef::Platform.dsc_refresh_mode_disabled?(node)
|
89
|
+
end
|
88
90
|
|
89
91
|
def generate_description
|
90
92
|
@converge_description
|
@@ -153,12 +155,6 @@ class Chef
|
|
153
155
|
cmdlet.run!
|
154
156
|
end
|
155
157
|
|
156
|
-
def meta_configuration
|
157
|
-
cmdlet = Chef::Util::Powershell::Cmdlet.new(node, "Get-DscLocalConfigurationManager", :object)
|
158
|
-
result = cmdlet.run!
|
159
|
-
result.return_value
|
160
|
-
end
|
161
|
-
|
162
158
|
end
|
163
159
|
end
|
164
160
|
end
|
@@ -109,7 +109,7 @@ class Chef
|
|
109
109
|
else
|
110
110
|
# Append is not set so we're resetting the membership of
|
111
111
|
# the group to the given members.
|
112
|
-
members_to_be_added = @new_resource.members
|
112
|
+
members_to_be_added = @new_resource.members.dup
|
113
113
|
@current_resource.members.each do |member|
|
114
114
|
# No need to re-add a member if it's present in the new
|
115
115
|
# list of members
|
@@ -194,7 +194,7 @@ class Chef
|
|
194
194
|
|
195
195
|
private
|
196
196
|
def add_command
|
197
|
-
command = "ifconfig #{@new_resource.device} #{@new_resource.
|
197
|
+
command = "ifconfig #{@new_resource.device} #{@new_resource.target}"
|
198
198
|
command << " netmask #{@new_resource.mask}" if @new_resource.mask
|
199
199
|
command << " metric #{@new_resource.metric}" if @new_resource.metric
|
200
200
|
command << " mtu #{@new_resource.mtu}" if @new_resource.mtu
|
@@ -202,7 +202,7 @@ class Chef
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def enable_command
|
205
|
-
command = "ifconfig #{@new_resource.device} #{@new_resource.
|
205
|
+
command = "ifconfig #{@new_resource.device} #{@new_resource.target}"
|
206
206
|
command << " netmask #{@new_resource.mask}" if @new_resource.mask
|
207
207
|
command << " metric #{@new_resource.metric}" if @new_resource.metric
|
208
208
|
command << " mtu #{@new_resource.mtu}" if @new_resource.mtu
|
@@ -28,52 +28,10 @@ class Chef
|
|
28
28
|
# Base class from which LWRP providers inherit.
|
29
29
|
class LWRPBase < Provider
|
30
30
|
|
31
|
-
# Chef::Provider::LWRPBase::InlineResources
|
32
|
-
# Implementation of inline resource convergence for LWRP providers. See
|
33
|
-
# Provider::LWRPBase.use_inline_resources for a longer explanation.
|
34
|
-
#
|
35
|
-
# This code is restricted to a module so that it can be selectively
|
36
|
-
# applied to providers on an opt-in basis.
|
37
|
-
module InlineResources
|
38
|
-
|
39
|
-
# Class methods for InlineResources. Overrides the `action` DSL method
|
40
|
-
# with one that enables inline resource convergence.
|
41
|
-
module ClassMethods
|
42
|
-
# Defines an action method on the provider, using
|
43
|
-
# recipe_eval_with_update_check to execute the given block.
|
44
|
-
def action(name, &block)
|
45
|
-
define_method("action_#{name}") do
|
46
|
-
recipe_eval_with_update_check(&block)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Executes the given block in a temporary run_context with its own
|
52
|
-
# resource collection. After the block is executed, any resources
|
53
|
-
# declared inside are converged, and if any are updated, the
|
54
|
-
# new_resource will be marked updated.
|
55
|
-
def recipe_eval_with_update_check(&block)
|
56
|
-
saved_run_context = @run_context
|
57
|
-
temp_run_context = @run_context.dup
|
58
|
-
@run_context = temp_run_context
|
59
|
-
@run_context.resource_collection = Chef::ResourceCollection.new
|
60
|
-
|
61
|
-
return_value = instance_eval(&block)
|
62
|
-
Chef::Runner.new(@run_context).converge
|
63
|
-
return_value
|
64
|
-
ensure
|
65
|
-
@run_context = saved_run_context
|
66
|
-
if temp_run_context.resource_collection.any? {|r| r.updated? }
|
67
|
-
new_resource.updated_by_last_action(true)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
31
|
include Chef::DSL::Recipe
|
74
32
|
|
75
33
|
# These were previously provided by Chef::Mixin::RecipeDefinitionDSLCore.
|
76
|
-
# They are not included by its
|
34
|
+
# They are not included by its replacement, Chef::DSL::Recipe, but
|
77
35
|
# they may be used in existing LWRPs.
|
78
36
|
include Chef::DSL::PlatformIntrospection
|
79
37
|
include Chef::DSL::DataQuery
|
@@ -122,38 +80,6 @@ class Chef
|
|
122
80
|
provider_class
|
123
81
|
end
|
124
82
|
|
125
|
-
# Enables inline evaluation of resources in provider actions.
|
126
|
-
#
|
127
|
-
# Without this option, any resources declared inside the LWRP are added
|
128
|
-
# to the resource collection after the current position at the time the
|
129
|
-
# action is executed. Because they are added to the primary resource
|
130
|
-
# collection for the chef run, they can notify other resources outside
|
131
|
-
# the LWRP, and potentially be notified by resources outside the LWRP
|
132
|
-
# (but this is complicated by the fact that they don't exist until the
|
133
|
-
# provider executes). In this mode, it is impossible to correctly set the
|
134
|
-
# updated_by_last_action flag on the parent LWRP resource, since it
|
135
|
-
# executes and returns before its component resources are run.
|
136
|
-
#
|
137
|
-
# With this option enabled, each action creates a temporary run_context
|
138
|
-
# with its own resource collection, evaluates the action's code in that
|
139
|
-
# context, and then converges the resources created. If any resources
|
140
|
-
# were updated, then this provider's new_resource will be marked updated.
|
141
|
-
#
|
142
|
-
# In this mode, resources created within the LWRP cannot interact with
|
143
|
-
# external resources via notifies, though notifications to other
|
144
|
-
# resources within the LWRP will work. Delayed notifications are executed
|
145
|
-
# at the conclusion of the provider's action, *not* at the end of the
|
146
|
-
# main chef run.
|
147
|
-
#
|
148
|
-
# This mode of evaluation is experimental, but is believed to be a better
|
149
|
-
# set of tradeoffs than the append-after mode, so it will likely become
|
150
|
-
# the default in a future major release of Chef.
|
151
|
-
#
|
152
|
-
def use_inline_resources
|
153
|
-
extend InlineResources::ClassMethods
|
154
|
-
include InlineResources
|
155
|
-
end
|
156
|
-
|
157
83
|
# DSL for defining a provider's actions.
|
158
84
|
def action(name, &block)
|
159
85
|
define_method("action_#{name}") do
|