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/node_map.rb
CHANGED
@@ -32,8 +32,8 @@ class Chef
|
|
32
32
|
# @return [NodeMap] Returns self for possible chaining
|
33
33
|
#
|
34
34
|
def set(key, value, platform: nil, platform_version: nil, platform_family: nil, os: nil, on_platform: nil, on_platforms: nil, canonical: nil, override: nil, &block)
|
35
|
-
Chef
|
36
|
-
Chef
|
35
|
+
Chef.log_deprecation("The on_platform option to node_map has been deprecated") if on_platform
|
36
|
+
Chef.log_deprecation("The on_platforms option to node_map has been deprecated") if on_platforms
|
37
37
|
platform ||= on_platform || on_platforms
|
38
38
|
filters = {}
|
39
39
|
filters[:platform] = platform if platform
|
@@ -31,11 +31,6 @@ class Chef
|
|
31
31
|
# are exactly equal
|
32
32
|
if new_matcher[:value].is_a?(Class) && !new_matcher[:override]
|
33
33
|
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name }
|
34
|
-
if cmp < 0
|
35
|
-
Chef::Log.warn "You are overriding #{key} on #{new_matcher[:filters].inspect} with #{new_matcher[:value].inspect}: used to be #{matcher[:value].inspect}. Use override: true if this is what you intended."
|
36
|
-
elsif cmp > 0
|
37
|
-
Chef::Log.warn "You declared a new resource #{new_matcher[:value].inspect} for resource #{key}, but it comes alphabetically after #{matcher[:value].inspect} and has the same filters (#{new_matcher[:filters].inspect}), so it will not be used. Use override: true if you want to use it for #{key}."
|
38
|
-
end
|
39
34
|
end
|
40
35
|
end
|
41
36
|
cmp
|
@@ -200,14 +200,13 @@ class Chef
|
|
200
200
|
class_name = resource_type.class.name ? resource_type.class.name.split('::').last :
|
201
201
|
convert_to_class_name(resource_type.resource_name.to_s)
|
202
202
|
|
203
|
-
|
204
|
-
|
205
|
-
Chef::Log.warn("
|
206
|
-
Chef::
|
207
|
-
rescue NameError
|
203
|
+
if Chef::Provider.const_defined?(class_name)
|
204
|
+
Chef::Log.warn("Class Chef::Provider::#{class_name} does not declare 'provides #{convert_to_snake_case(class_name).to_sym.inspect}'.")
|
205
|
+
Chef::Log.warn("This will no longer work in Chef 13: you must use 'provides' to use the resource's DSL.")
|
206
|
+
return Chef::Provider.const_get(class_name)
|
208
207
|
end
|
209
208
|
end
|
210
|
-
|
209
|
+
nil
|
211
210
|
end
|
212
211
|
|
213
212
|
end
|
@@ -25,13 +25,10 @@ class Chef
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def windows_server_2003?
|
28
|
+
# WMI startup shouldn't be performed unless we're on Windows.
|
28
29
|
return false unless windows?
|
29
30
|
require 'wmi-lite/wmi'
|
30
31
|
|
31
|
-
# CHEF-4888: Work around ruby #2618, expected to be fixed in Ruby 2.1.0
|
32
|
-
# https://github.com/ruby/ruby/commit/588504b20f5cc880ad51827b93e571e32446e5db
|
33
|
-
# https://github.com/ruby/ruby/commit/27ed294c7134c0de582007af3c915a635a6506cd
|
34
|
-
|
35
32
|
wmi = WmiLite::Wmi.new
|
36
33
|
host = wmi.first_of('Win32_OperatingSystem')
|
37
34
|
is_server_2003 = (host['version'] && host['version'].start_with?("5.2"))
|
@@ -39,6 +36,44 @@ class Chef
|
|
39
36
|
is_server_2003
|
40
37
|
end
|
41
38
|
|
39
|
+
def windows_nano_server?
|
40
|
+
return false unless windows?
|
41
|
+
require 'win32/registry'
|
42
|
+
|
43
|
+
# This method may be called before ohai runs (e.g., it may be used to
|
44
|
+
# determine settings in config.rb). Chef::Win32::Registry.new uses
|
45
|
+
# node attributes to verify the machine architecture which aren't
|
46
|
+
# accessible before ohai runs.
|
47
|
+
nano = nil
|
48
|
+
key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Server\\ServerLevels"
|
49
|
+
access = ::Win32::Registry::KEY_QUERY_VALUE | 0x0100 # nano is 64-bit only
|
50
|
+
begin
|
51
|
+
::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, access) do |reg|
|
52
|
+
nano = reg["NanoServer"]
|
53
|
+
end
|
54
|
+
rescue ::Win32::Registry::Error
|
55
|
+
# If accessing the registry key failed, then we're probably not on
|
56
|
+
# nano. Fail through.
|
57
|
+
end
|
58
|
+
return nano == 1
|
59
|
+
end
|
60
|
+
|
61
|
+
def supports_msi?
|
62
|
+
return false unless windows?
|
63
|
+
require 'win32/registry'
|
64
|
+
|
65
|
+
key = "System\\CurrentControlSet\\Services\\msiserver"
|
66
|
+
access = ::Win32::Registry::KEY_QUERY_VALUE
|
67
|
+
|
68
|
+
begin
|
69
|
+
::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, access) do |reg|
|
70
|
+
true
|
71
|
+
end
|
72
|
+
rescue ::Win32::Registry::Error
|
73
|
+
false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
42
77
|
def supports_powershell_execution_bypass?(node)
|
43
78
|
node[:languages] && node[:languages][:powershell] &&
|
44
79
|
node[:languages][:powershell][:version].to_i >= 3
|
@@ -55,6 +90,13 @@ class Chef
|
|
55
90
|
Gem::Version.new(node[:languages][:powershell][:version]) >=
|
56
91
|
Gem::Version.new("5.0.10018.0")
|
57
92
|
end
|
93
|
+
|
94
|
+
def dsc_refresh_mode_disabled?(node)
|
95
|
+
require 'chef/util/powershell/cmdlet'
|
96
|
+
cmdlet = Chef::Util::Powershell::Cmdlet.new(node, "Get-DscLocalConfigurationManager", :object)
|
97
|
+
metadata = cmdlet.run!.return_value
|
98
|
+
metadata['RefreshMode'] == 'Disabled'
|
99
|
+
end
|
58
100
|
end
|
59
101
|
end
|
60
102
|
end
|
@@ -32,7 +32,7 @@ class Chef
|
|
32
32
|
|
33
33
|
cmd = if Chef::Platform.windows?
|
34
34
|
# should this do /f as well? do we then need a minimum delay to let apps quit?
|
35
|
-
"shutdown /r /t #{reboot_info[:delay_mins]} /c \"#{reboot_info[:reason]}\""
|
35
|
+
"shutdown /r /t #{reboot_info[:delay_mins]*60} /c \"#{reboot_info[:reason]}\""
|
36
36
|
else
|
37
37
|
# probably Linux-only.
|
38
38
|
"shutdown -r +#{reboot_info[:delay_mins]} \"#{reboot_info[:reason]}\""
|
@@ -19,6 +19,7 @@
|
|
19
19
|
# XXX: mixing shellout into a mixin into classes has to be code smell
|
20
20
|
require 'chef/mixin/shell_out'
|
21
21
|
require 'chef/mixin/which'
|
22
|
+
require 'chef/chef_class'
|
22
23
|
|
23
24
|
class Chef
|
24
25
|
class Platform
|
@@ -42,56 +43,56 @@ class Chef
|
|
42
43
|
# different services is NOT a design concern of this module.
|
43
44
|
#
|
44
45
|
def service_resource_providers
|
45
|
-
|
46
|
+
providers = []
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
if ::File.exist?("/usr/sbin/invoke-rc.d")
|
52
|
-
service_resource_providers << :invokercd
|
53
|
-
end
|
48
|
+
if ::File.exist?(Chef.path_to("/usr/sbin/update-rc.d"))
|
49
|
+
providers << :debian
|
50
|
+
end
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
if ::File.exist?(Chef.path_to("/usr/sbin/invoke-rc.d"))
|
53
|
+
providers << :invokercd
|
54
|
+
end
|
58
55
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
56
|
+
if ::File.exist?(Chef.path_to("/sbin/insserv"))
|
57
|
+
providers << :insserv
|
58
|
+
end
|
63
59
|
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
# debian >= 6.0 has /etc/init but does not have upstart
|
61
|
+
if ::File.exist?(Chef.path_to("/etc/init")) && ::File.exist?(Chef.path_to("/sbin/start"))
|
62
|
+
providers << :upstart
|
63
|
+
end
|
67
64
|
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
if ::File.exist?(Chef.path_to("/sbin/chkconfig"))
|
66
|
+
providers << :redhat
|
67
|
+
end
|
71
68
|
|
69
|
+
if systemd_sanity_check?
|
70
|
+
providers << :systemd
|
72
71
|
end
|
72
|
+
|
73
|
+
providers
|
73
74
|
end
|
74
75
|
|
75
76
|
def config_for_service(service_name)
|
76
77
|
configs = []
|
77
78
|
|
78
|
-
if ::File.exist?("/etc/init.d/#{service_name}")
|
79
|
+
if ::File.exist?(Chef.path_to("/etc/init.d/#{service_name}"))
|
79
80
|
configs << :initd
|
80
81
|
end
|
81
82
|
|
82
|
-
if ::File.exist?("/etc/init/#{service_name}.conf")
|
83
|
+
if ::File.exist?(Chef.path_to("/etc/init/#{service_name}.conf"))
|
83
84
|
configs << :upstart
|
84
85
|
end
|
85
86
|
|
86
|
-
if ::File.exist?("/etc/xinetd.d/#{service_name}")
|
87
|
+
if ::File.exist?(Chef.path_to("/etc/xinetd.d/#{service_name}"))
|
87
88
|
configs << :xinetd
|
88
89
|
end
|
89
90
|
|
90
|
-
if ::File.exist?("/etc/rc.d/#{service_name}")
|
91
|
+
if ::File.exist?(Chef.path_to("/etc/rc.d/#{service_name}"))
|
91
92
|
configs << :etc_rcd
|
92
93
|
end
|
93
94
|
|
94
|
-
if ::File.exist?("/usr/local/etc/rc.d/#{service_name}")
|
95
|
+
if ::File.exist?(Chef.path_to("/usr/local/etc/rc.d/#{service_name}"))
|
95
96
|
configs << :usr_local_etc_rcd
|
96
97
|
end
|
97
98
|
|
@@ -105,14 +106,11 @@ class Chef
|
|
105
106
|
private
|
106
107
|
|
107
108
|
def systemctl_path
|
108
|
-
|
109
|
-
@systemctl_path = which("systemctl")
|
110
|
-
end
|
111
|
-
@systemctl_path
|
109
|
+
which("systemctl")
|
112
110
|
end
|
113
111
|
|
114
112
|
def systemd_sanity_check?
|
115
|
-
systemctl_path && File.exist?("/proc/1/comm") && File.open("/proc/1/comm").gets.chomp == "systemd"
|
113
|
+
systemctl_path && File.exist?(Chef.path_to("/proc/1/comm")) && File.open(Chef.path_to("/proc/1/comm")).gets.chomp == "systemd"
|
116
114
|
end
|
117
115
|
|
118
116
|
def extract_systemd_services(command)
|
@@ -126,7 +124,7 @@ class Chef
|
|
126
124
|
# this splits off the suffix after the last dot to return "sshd"
|
127
125
|
services += services.select {|s| s.match(/\.service$/) }.map { |s| s.sub(/(.*)\.service$/, '\1') }
|
128
126
|
rescue Mixlib::ShellOut::ShellCommandFailed
|
129
|
-
|
127
|
+
[]
|
130
128
|
end
|
131
129
|
|
132
130
|
def platform_has_systemd_unit?(service_name)
|
data/lib/chef/policy_builder.rb
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
require 'chef/policy_builder/expand_node_object'
|
20
20
|
require 'chef/policy_builder/policyfile'
|
21
|
+
require 'chef/policy_builder/dynamic'
|
21
22
|
|
22
23
|
class Chef
|
23
24
|
|
@@ -37,13 +38,5 @@ class Chef
|
|
37
38
|
# * cookbook_hash is stored in run_context
|
38
39
|
module PolicyBuilder
|
39
40
|
|
40
|
-
def self.strategy
|
41
|
-
if Chef::Config[:use_policyfile]
|
42
|
-
Policyfile
|
43
|
-
else
|
44
|
-
ExpandNodeObject
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
41
|
end
|
49
42
|
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
|
+
# Copyright:: Copyright 2015 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'forwardable'
|
20
|
+
|
21
|
+
require 'chef/log'
|
22
|
+
require 'chef/rest'
|
23
|
+
require 'chef/run_context'
|
24
|
+
require 'chef/config'
|
25
|
+
require 'chef/node'
|
26
|
+
require 'chef/exceptions'
|
27
|
+
|
28
|
+
class Chef
|
29
|
+
module PolicyBuilder
|
30
|
+
|
31
|
+
# PolicyBuilder that selects either a Policyfile or non-Policyfile
|
32
|
+
# implementation based on the content of the node object.
|
33
|
+
class Dynamic
|
34
|
+
|
35
|
+
extend Forwardable
|
36
|
+
|
37
|
+
attr_reader :node
|
38
|
+
attr_reader :node_name
|
39
|
+
attr_reader :ohai_data
|
40
|
+
attr_reader :json_attribs
|
41
|
+
attr_reader :override_runlist
|
42
|
+
attr_reader :events
|
43
|
+
|
44
|
+
def initialize(node_name, ohai_data, json_attribs, override_runlist, events)
|
45
|
+
@implementation = nil
|
46
|
+
|
47
|
+
@node_name = node_name
|
48
|
+
@ohai_data = ohai_data
|
49
|
+
@json_attribs = json_attribs
|
50
|
+
@override_runlist = override_runlist
|
51
|
+
@events = events
|
52
|
+
|
53
|
+
@node = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
## PolicyBuilder API ##
|
57
|
+
|
58
|
+
# Loads the node state from the server, then picks the correct
|
59
|
+
# implementation class based on the node and json_attribs.
|
60
|
+
#
|
61
|
+
# Calls #finish_load_node on the implementation object to complete the
|
62
|
+
# loading process. All subsequent lifecycle calls are delegated.
|
63
|
+
#
|
64
|
+
# @return [Chef::Node] the loaded node.
|
65
|
+
def load_node
|
66
|
+
events.node_load_start(node_name, config)
|
67
|
+
Chef::Log.debug("Building node object for #{node_name}")
|
68
|
+
|
69
|
+
@node =
|
70
|
+
if Chef::Config[:solo]
|
71
|
+
Chef::Node.build(node_name)
|
72
|
+
else
|
73
|
+
Chef::Node.find_or_create(node_name)
|
74
|
+
end
|
75
|
+
select_implementation(node)
|
76
|
+
implementation.finish_load_node(node)
|
77
|
+
node
|
78
|
+
rescue Exception => e
|
79
|
+
events.node_load_failed(node_name, e, config)
|
80
|
+
raise
|
81
|
+
end
|
82
|
+
|
83
|
+
## Delegated Public API Methods ##
|
84
|
+
|
85
|
+
### Accessors ###
|
86
|
+
|
87
|
+
def_delegator :implementation, :original_runlist
|
88
|
+
def_delegator :implementation, :run_context
|
89
|
+
def_delegator :implementation, :run_list_expansion
|
90
|
+
|
91
|
+
### Lifecycle Methods ###
|
92
|
+
|
93
|
+
# @!method build_node
|
94
|
+
#
|
95
|
+
# Applies external attributes (e.g., from JSON file, environment,
|
96
|
+
# policyfile, etc.) and determines the correct expanded run list for the
|
97
|
+
# run.
|
98
|
+
#
|
99
|
+
# @return [Chef::Node]
|
100
|
+
def_delegator :implementation, :build_node
|
101
|
+
|
102
|
+
# @!method setup_run_context
|
103
|
+
#
|
104
|
+
# Synchronizes cookbooks and initializes the run context object for the
|
105
|
+
# run.
|
106
|
+
#
|
107
|
+
# @return [Chef::RunContext]
|
108
|
+
def_delegator :implementation, :setup_run_context
|
109
|
+
|
110
|
+
# @!method expanded_run_list
|
111
|
+
#
|
112
|
+
# Resolves the run list to a form containing only recipes and sets the
|
113
|
+
# `roles` and `recipes` automatic attributes on the node.
|
114
|
+
#
|
115
|
+
# @return [#recipes, #roles] A RunListExpansion or duck-type.
|
116
|
+
def_delegator :implementation, :expand_run_list
|
117
|
+
|
118
|
+
# @!method sync_cookbooks
|
119
|
+
#
|
120
|
+
# Synchronizes cookbooks. In a normal chef-client run, this is handled by
|
121
|
+
# #setup_run_context, but may be called directly in some circumstances.
|
122
|
+
#
|
123
|
+
# @return [Hash{String => Chef::CookbookManifest}] A map of
|
124
|
+
# CookbookManifest objects by cookbook name.
|
125
|
+
def_delegator :implementation, :sync_cookbooks
|
126
|
+
|
127
|
+
# @!method temporary_policy?
|
128
|
+
#
|
129
|
+
# Indicates whether the policy is temporary, which means an
|
130
|
+
# override_runlist was provided. Chef::Client uses this to decide whether
|
131
|
+
# to do the final node save at the end of the run or not.
|
132
|
+
#
|
133
|
+
# @return [true,false]
|
134
|
+
def_delegator :implementation, :temporary_policy?
|
135
|
+
|
136
|
+
## Internal Public API ##
|
137
|
+
|
138
|
+
# Returns the selected implementation, or raises if not set. The
|
139
|
+
# implementation is set when #load_node is called.
|
140
|
+
#
|
141
|
+
# @return [PolicyBuilder::Policyfile, PolicyBuilder::ExpandNodeObject]
|
142
|
+
def implementation
|
143
|
+
@implementation or raise Exceptions::InvalidPolicybuilderCall, "#load_node must be called before other policy builder methods"
|
144
|
+
end
|
145
|
+
|
146
|
+
# @api private
|
147
|
+
#
|
148
|
+
# Sets the implementation based on the content of the node, node JSON
|
149
|
+
# (i.e., the `-j JSON_FILE` data), and config. This is only public for
|
150
|
+
# testing purposes; production code should call #load_node instead.
|
151
|
+
def select_implementation(node)
|
152
|
+
if policyfile_set_in_config? ||
|
153
|
+
policyfile_attribs_in_node_json? ||
|
154
|
+
node_has_policyfile_attrs?(node) ||
|
155
|
+
policyfile_compat_mode_config?
|
156
|
+
@implementation = Policyfile.new(node_name, ohai_data, json_attribs, override_runlist, events)
|
157
|
+
else
|
158
|
+
@implementation = ExpandNodeObject.new(node_name, ohai_data, json_attribs, override_runlist, events)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def config
|
163
|
+
Chef::Config
|
164
|
+
end
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
def node_has_policyfile_attrs?(node)
|
169
|
+
node.policy_name || node.policy_group
|
170
|
+
end
|
171
|
+
|
172
|
+
def policyfile_attribs_in_node_json?
|
173
|
+
json_attribs.key?("policy_name") || json_attribs.key?("policy_group")
|
174
|
+
end
|
175
|
+
|
176
|
+
def policyfile_set_in_config?
|
177
|
+
config[:use_policyfile] || config[:policy_name] || config[:policy_group]
|
178
|
+
end
|
179
|
+
|
180
|
+
def policyfile_compat_mode_config?
|
181
|
+
config[:deployment_group] && !config[:policy_document_native_api]
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|