chef 12.18.31 → 12.19.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -4
- data/README.md +12 -13
- data/VERSION +1 -1
- data/acceptance/Gemfile +4 -4
- data/acceptance/Gemfile.lock +70 -69
- data/chef-universal-mingw32.gemspec +2 -3
- data/chef.gemspec +6 -6
- data/lib/chef/api_client.rb +8 -10
- data/lib/chef/api_client_v1.rb +9 -11
- data/lib/chef/application/apply.rb +8 -10
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/exit_code.rb +3 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service.rb +29 -30
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/audit/audit_event_proxy.rb +2 -2
- data/lib/chef/audit/control_group_data.rb +1 -1
- data/lib/chef/chef_class.rb +1 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
- data/lib/chef/chef_fs/command_line.rb +15 -16
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
- data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
- data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
- data/lib/chef/chef_fs/parallelizer.rb +9 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
- data/lib/chef/cookbook/metadata.rb +26 -26
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +3 -3
- data/lib/chef/data_collector.rb +3 -4
- data/lib/chef/decorator.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/audit.rb +2 -2
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +29 -31
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/dsl/resources.rb +6 -8
- data/lib/chef/encrypted_data_bag_item.rb +2 -2
- data/lib/chef/environment.rb +9 -11
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_access_control/unix.rb +14 -14
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
- data/lib/chef/formatters/error_mapper.rb +6 -6
- data/lib/chef/http/api_versions.rb +50 -0
- data/lib/chef/http/validate_content_length.rb +2 -2
- data/lib/chef/json_compat.rb +6 -10
- data/lib/chef/key.rb +5 -5
- data/lib/chef/knife.rb +4 -4
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/ui.rb +19 -25
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/deps.rb +32 -34
- data/lib/chef/knife/help.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +37 -27
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/user_delete.rb +1 -1
- data/lib/chef/mash.rb +1 -1
- data/lib/chef/mixin/command.rb +2 -2
- data/lib/chef/mixin/create_path.rb +3 -5
- data/lib/chef/mixin/from_file.rb +2 -2
- data/lib/chef/mixin/get_source_from_package.rb +2 -2
- data/lib/chef/mixin/notifying_block.rb +7 -9
- data/lib/chef/mixin/params_validate.rb +3 -3
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +23 -3
- data/lib/chef/mixin/unformatter.rb +2 -2
- data/lib/chef/mixin/uris.rb +4 -6
- data/lib/chef/mixin/versioned_api.rb +69 -0
- data/lib/chef/mixin/which.rb +25 -8
- data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
- data/lib/chef/mixin/xml_escape.rb +3 -5
- data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
- data/lib/chef/node.rb +8 -8
- data/lib/chef/node/attribute.rb +4 -4
- data/lib/chef/node/common_api.rb +5 -7
- data/lib/chef/org.rb +10 -12
- data/lib/chef/platform/provider_mapping.rb +7 -7
- data/lib/chef/platform/query_helpers.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +31 -0
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/breakpoint.rb +1 -1
- data/lib/chef/provider/cookbook_file.rb +3 -3
- data/lib/chef/provider/cron.rb +38 -38
- data/lib/chef/provider/deploy.rb +81 -81
- data/lib/chef/provider/deploy/revision.rb +3 -5
- data/lib/chef/provider/directory.rb +32 -32
- data/lib/chef/provider/dsc_resource.rb +22 -6
- data/lib/chef/provider/env.rb +28 -28
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/erl_call.rb +13 -13
- data/lib/chef/provider/execute.rb +5 -2
- data/lib/chef/provider/file.rb +49 -51
- data/lib/chef/provider/git.rb +55 -55
- data/lib/chef/provider/http_request.rb +36 -36
- data/lib/chef/provider/launchd.rb +2 -2
- data/lib/chef/provider/link.rb +50 -50
- data/lib/chef/provider/log.rb +2 -2
- data/lib/chef/provider/mdadm.rb +25 -25
- data/lib/chef/provider/mount/aix.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/ohai.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +23 -23
- data/lib/chef/provider/package.rb +74 -56
- data/lib/chef/provider/package/aix.rb +55 -52
- data/lib/chef/provider/package/apt.rb +15 -13
- data/lib/chef/provider/package/cab.rb +49 -20
- data/lib/chef/provider/package/chocolatey.rb +9 -10
- data/lib/chef/provider/package/dnf.rb +20 -18
- data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
- data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
- data/lib/chef/provider/package/dnf/version.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +8 -9
- data/lib/chef/provider/package/easy_install.rb +22 -22
- data/lib/chef/provider/package/freebsd/base.rb +10 -10
- data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
- data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
- data/lib/chef/provider/package/freebsd/port.rb +7 -7
- data/lib/chef/provider/package/homebrew.rb +11 -10
- data/lib/chef/provider/package/ips.rb +18 -23
- data/lib/chef/provider/package/macports.rb +23 -23
- data/lib/chef/provider/package/msu.rb +11 -11
- data/lib/chef/provider/package/openbsd.rb +25 -22
- data/lib/chef/provider/package/pacman.rb +16 -16
- data/lib/chef/provider/package/paludis.rb +26 -27
- data/lib/chef/provider/package/portage.rb +22 -22
- data/lib/chef/provider/package/powershell.rb +17 -17
- data/lib/chef/provider/package/rpm.rb +25 -25
- data/lib/chef/provider/package/rubygems.rb +60 -60
- data/lib/chef/provider/package/smartos.rb +16 -16
- data/lib/chef/provider/package/solaris.rb +44 -44
- data/lib/chef/provider/package/windows.rb +3 -3
- data/lib/chef/provider/package/windows/exe.rb +6 -6
- data/lib/chef/provider/package/windows/msi.rb +6 -6
- data/lib/chef/provider/package/yum.rb +318 -268
- data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
- data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
- data/lib/chef/provider/package/zypper.rb +11 -11
- data/lib/chef/provider/powershell_script.rb +15 -7
- data/lib/chef/provider/reboot.rb +10 -10
- data/lib/chef/provider/registry_key.rb +39 -39
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file.rb +3 -3
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/ruby_block.rb +3 -3
- data/lib/chef/provider/script.rb +42 -6
- data/lib/chef/provider/service.rb +49 -49
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +39 -39
- data/lib/chef/provider/systemd_unit.rb +2 -0
- data/lib/chef/provider/template.rb +3 -3
- data/lib/chef/provider/user.rb +42 -42
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
- data/lib/chef/resource.rb +27 -16
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +6 -3
- data/lib/chef/resource/dsc_resource.rb +9 -1
- data/lib/chef/resource/execute.rb +70 -6
- data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/launchd.rb +13 -1
- data/lib/chef/resource/package.rb +2 -2
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/yum_package.rb +12 -3
- data/lib/chef/resource/yum_repository.rb +0 -1
- data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
- data/lib/chef/resource_collection/resource_set.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/run_list/run_list_item.rb +1 -1
- data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/server_api_versions.rb +40 -0
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/user.rb +9 -11
- data/lib/chef/user_v1.rb +9 -11
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/net_group.rb +18 -30
- data/lib/chef/util/windows/net_use.rb +7 -11
- data/lib/chef/util/windows/net_user.rb +11 -17
- data/lib/chef/util/windows/volume.rb +9 -15
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/win32/api.rb +4 -6
- data/lib/chef/win32/api/file.rb +25 -31
- data/lib/chef/win32/api/installer.rb +2 -2
- data/lib/chef/win32/file.rb +4 -6
- data/lib/chef/win32/registry.rb +9 -9
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/acl.rb +2 -2
- data/lib/chef/win32/unicode.rb +2 -2
- data/lib/chef/win32/version.rb +1 -1
- data/spec/data/prefer_metadata_json/metadata.json +51 -0
- data/spec/data/prefer_metadata_json/metadata.rb +6 -0
- data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/resource/batch_spec.rb +5 -1
- data/spec/functional/resource/dsc_script_spec.rb +2 -4
- data/spec/functional/resource/execute_spec.rb +17 -0
- data/spec/functional/resource/user/dscl_spec.rb +2 -4
- data/spec/integration/client/client_spec.rb +33 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
- data/spec/spec_helper.rb +4 -0
- data/spec/support/chef_helpers.rb +5 -7
- data/spec/support/platform_helpers.rb +6 -0
- data/spec/support/platforms/prof/gc.rb +4 -6
- data/spec/support/shared/context/client.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +150 -0
- data/spec/support/shared/functional/windows_script.rb +74 -4
- data/spec/support/shared/unit/execute_resource.rb +37 -0
- data/spec/support/shared/unit/provider/file.rb +10 -0
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
- data/spec/unit/http/api_versions_spec.rb +69 -0
- data/spec/unit/knife/ssh_spec.rb +34 -36
- data/spec/unit/mixin/versioned_api_spec.rb +107 -0
- data/spec/unit/mixin/which.rb +160 -0
- data/spec/unit/platform_spec.rb +28 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +10 -0
- data/spec/unit/provider/dsc_resource_spec.rb +175 -0
- data/spec/unit/provider/execute_spec.rb +0 -1
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/package/aix_spec.rb +22 -22
- data/spec/unit/provider/package/apt_spec.rb +27 -27
- data/spec/unit/provider/package/cab_spec.rb +59 -5
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
- data/spec/unit/provider/package/dpkg_spec.rb +16 -16
- data/spec/unit/provider/package/easy_install_spec.rb +18 -18
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
- data/spec/unit/provider/package/homebrew_spec.rb +9 -9
- data/spec/unit/provider/package/ips_spec.rb +37 -31
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +10 -10
- data/spec/unit/provider/package/pacman_spec.rb +6 -6
- data/spec/unit/provider/package/paludis_spec.rb +7 -7
- data/spec/unit/provider/package/portage_spec.rb +6 -7
- data/spec/unit/provider/package/rpm_spec.rb +23 -23
- data/spec/unit/provider/package/rubygems_spec.rb +38 -38
- data/spec/unit/provider/package/solaris_spec.rb +15 -15
- data/spec/unit/provider/package/windows_spec.rb +2 -1
- data/spec/unit/provider/package/yum_spec.rb +51 -43
- data/spec/unit/provider/package/zypper_spec.rb +34 -34
- data/spec/unit/provider/package_spec.rb +8 -0
- data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
- data/spec/unit/provider/route_spec.rb +7 -1
- data/spec/unit/provider/script_spec.rb +49 -6
- data/spec/unit/resource/dsc_resource_spec.rb +6 -0
- data/spec/unit/resource/execute_spec.rb +214 -0
- data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
- data/spec/unit/resource/freebsd_package_spec.rb +2 -2
- data/spec/unit/resource/package_spec.rb +5 -0
- data/spec/unit/resource/yum_package_spec.rb +42 -1
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +18 -0
- data/spec/unit/server_api_versions_spec.rb +44 -0
- data/spec/unit/util/selinux_spec.rb +3 -14
- data/spec/unit/win32/error_spec.rb +67 -0
- data/spec/unit/win32/security_spec.rb +66 -0
- data/tasks/changelog.rb +1 -1
- data/tasks/dependencies.rb +20 -4
- metadata +39 -18
- data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -32,78 +32,78 @@ class Chef
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def load_current_resource
|
35
|
-
@http = Chef::HTTP::Simple.new(
|
35
|
+
@http = Chef::HTTP::Simple.new(new_resource.url)
|
36
36
|
end
|
37
37
|
|
38
|
-
# Send a HEAD request to
|
38
|
+
# Send a HEAD request to new_resource.url
|
39
39
|
def action_head
|
40
|
-
message = check_message(
|
40
|
+
message = check_message(new_resource.message)
|
41
41
|
# CHEF-4762: we expect a nil return value from Chef::HTTP for a "200 Success" response
|
42
42
|
# and false for a "304 Not Modified" response
|
43
43
|
modified = @http.head(
|
44
|
-
"#{
|
45
|
-
|
44
|
+
"#{new_resource.url}",
|
45
|
+
new_resource.headers
|
46
46
|
)
|
47
|
-
Chef::Log.info("#{
|
48
|
-
Chef::Log.debug("#{
|
47
|
+
Chef::Log.info("#{new_resource} HEAD to #{new_resource.url} successful")
|
48
|
+
Chef::Log.debug("#{new_resource} HEAD request response: #{modified}")
|
49
49
|
# :head is usually used to trigger notifications, which converge_by now does
|
50
50
|
if modified != false
|
51
|
-
converge_by("#{
|
51
|
+
converge_by("#{new_resource} HEAD to #{new_resource.url} returned modified, trigger notifications") {}
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
# Send a GET request to
|
55
|
+
# Send a GET request to new_resource.url
|
56
56
|
def action_get
|
57
|
-
converge_by("#{
|
57
|
+
converge_by("#{new_resource} GET to #{new_resource.url}") do
|
58
58
|
|
59
|
-
message = check_message(
|
59
|
+
message = check_message(new_resource.message)
|
60
60
|
body = @http.get(
|
61
|
-
"#{
|
62
|
-
|
61
|
+
"#{new_resource.url}",
|
62
|
+
new_resource.headers
|
63
63
|
)
|
64
|
-
Chef::Log.info("#{
|
65
|
-
Chef::Log.debug("#{
|
64
|
+
Chef::Log.info("#{new_resource} GET to #{new_resource.url} successful")
|
65
|
+
Chef::Log.debug("#{new_resource} GET request response: #{body}")
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
# Send a PUT request to
|
69
|
+
# Send a PUT request to new_resource.url, with the message as the payload
|
70
70
|
def action_put
|
71
|
-
converge_by("#{
|
72
|
-
message = check_message(
|
71
|
+
converge_by("#{new_resource} PUT to #{new_resource.url}") do
|
72
|
+
message = check_message(new_resource.message)
|
73
73
|
body = @http.put(
|
74
|
-
"#{
|
74
|
+
"#{new_resource.url}",
|
75
75
|
message,
|
76
|
-
|
76
|
+
new_resource.headers
|
77
77
|
)
|
78
|
-
Chef::Log.info("#{
|
79
|
-
Chef::Log.debug("#{
|
78
|
+
Chef::Log.info("#{new_resource} PUT to #{new_resource.url} successful")
|
79
|
+
Chef::Log.debug("#{new_resource} PUT request response: #{body}")
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
# Send a POST request to
|
83
|
+
# Send a POST request to new_resource.url, with the message as the payload
|
84
84
|
def action_post
|
85
|
-
converge_by("#{
|
86
|
-
message = check_message(
|
85
|
+
converge_by("#{new_resource} POST to #{new_resource.url}") do
|
86
|
+
message = check_message(new_resource.message)
|
87
87
|
body = @http.post(
|
88
|
-
"#{
|
88
|
+
"#{new_resource.url}",
|
89
89
|
message,
|
90
|
-
|
90
|
+
new_resource.headers
|
91
91
|
)
|
92
|
-
Chef::Log.info("#{
|
93
|
-
Chef::Log.debug("#{
|
92
|
+
Chef::Log.info("#{new_resource} POST to #{new_resource.url} message: #{message.inspect} successful")
|
93
|
+
Chef::Log.debug("#{new_resource} POST request response: #{body}")
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
# Send a DELETE request to
|
97
|
+
# Send a DELETE request to new_resource.url
|
98
98
|
def action_delete
|
99
|
-
converge_by("#{
|
99
|
+
converge_by("#{new_resource} DELETE to #{new_resource.url}") do
|
100
100
|
body = @http.delete(
|
101
|
-
"#{
|
102
|
-
|
101
|
+
"#{new_resource.url}",
|
102
|
+
new_resource.headers
|
103
103
|
)
|
104
|
-
|
105
|
-
Chef::Log.info("#{
|
106
|
-
Chef::Log.debug("#{
|
104
|
+
new_resource.updated_by_last_action(true)
|
105
|
+
Chef::Log.info("#{new_resource} DELETE to #{new_resource.url} successful")
|
106
|
+
Chef::Log.debug("#{new_resource} DELETE request response: #{body}")
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
extend Forwardable
|
31
31
|
provides :launchd, os: "darwin"
|
32
32
|
|
33
|
-
def_delegators
|
33
|
+
def_delegators :new_resource, *[
|
34
34
|
:backup,
|
35
35
|
:cookbook,
|
36
36
|
:group,
|
@@ -150,7 +150,7 @@ class Chef
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def content
|
153
|
-
plist_hash = new_resource.
|
153
|
+
plist_hash = new_resource.plist_hash || gen_hash
|
154
154
|
Plist::Emit.dump(plist_hash) unless plist_hash.nil?
|
155
155
|
end
|
156
156
|
|
data/lib/chef/provider/link.rb
CHANGED
@@ -47,41 +47,41 @@ class Chef
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def load_current_resource
|
50
|
-
@current_resource = Chef::Resource::Link.new(
|
51
|
-
|
52
|
-
if file_class.symlink?(
|
53
|
-
|
54
|
-
|
55
|
-
canonicalize(file_class.readlink(
|
50
|
+
@current_resource = Chef::Resource::Link.new(new_resource.name)
|
51
|
+
current_resource.target_file(new_resource.target_file)
|
52
|
+
if file_class.symlink?(current_resource.target_file)
|
53
|
+
current_resource.link_type(:symbolic)
|
54
|
+
current_resource.to(
|
55
|
+
canonicalize(file_class.readlink(current_resource.target_file))
|
56
56
|
)
|
57
57
|
else
|
58
|
-
|
59
|
-
if ::File.exists?(
|
60
|
-
if ::File.exists?(
|
61
|
-
file_class.stat(
|
62
|
-
file_class.stat(
|
63
|
-
|
58
|
+
current_resource.link_type(:hard)
|
59
|
+
if ::File.exists?(current_resource.target_file)
|
60
|
+
if ::File.exists?(new_resource.to) &&
|
61
|
+
file_class.stat(current_resource.target_file).ino ==
|
62
|
+
file_class.stat(new_resource.to).ino
|
63
|
+
current_resource.to(canonicalize(new_resource.to))
|
64
64
|
else
|
65
|
-
|
65
|
+
current_resource.to("")
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
-
ScanAccessControl.new(
|
70
|
-
|
69
|
+
ScanAccessControl.new(new_resource, current_resource).set_all!
|
70
|
+
current_resource
|
71
71
|
end
|
72
72
|
|
73
73
|
def define_resource_requirements
|
74
74
|
requirements.assert(:delete) do |a|
|
75
75
|
a.assertion do
|
76
|
-
if
|
77
|
-
|
78
|
-
(
|
76
|
+
if current_resource.to
|
77
|
+
current_resource.link_type == new_resource.link_type &&
|
78
|
+
(current_resource.link_type == :symbolic || current_resource.to != "")
|
79
79
|
else
|
80
80
|
true
|
81
81
|
end
|
82
82
|
end
|
83
|
-
a.failure_message Chef::Exceptions::Link, "Cannot delete #{
|
84
|
-
a.whyrun("Would assume the link at #{
|
83
|
+
a.failure_message Chef::Exceptions::Link, "Cannot delete #{new_resource} at #{new_resource.target_file}! Not a #{new_resource.link_type} link."
|
84
|
+
a.whyrun("Would assume the link at #{new_resource.target_file} was previously created")
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -95,48 +95,48 @@ class Chef
|
|
95
95
|
# to - the location to link to
|
96
96
|
# target_file - the name of the link
|
97
97
|
|
98
|
-
if
|
99
|
-
|
98
|
+
if current_resource.to != canonicalize(new_resource.to) ||
|
99
|
+
current_resource.link_type != new_resource.link_type
|
100
100
|
# Handle the case where the symlink already exists and is pointing at a valid to_file
|
101
|
-
if
|
101
|
+
if current_resource.to
|
102
102
|
# On Windows, to fix a symlink already pointing at a directory we must first
|
103
103
|
# ::Dir.unlink the symlink (not the directory), while if we have a symlink
|
104
104
|
# pointing at file we must use ::File.unlink on the symlink.
|
105
105
|
# However if the new symlink will point to a file and the current symlink is pointing at a
|
106
106
|
# directory we want to throw an exception and calling ::File.unlink on the directory symlink
|
107
107
|
# will throw the correct ones.
|
108
|
-
if Chef::Platform.windows? && ::File.directory?(
|
109
|
-
::File.directory?(
|
110
|
-
converge_by("unlink existing windows symlink to dir at #{
|
111
|
-
::Dir.unlink(
|
108
|
+
if Chef::Platform.windows? && ::File.directory?(new_resource.to) &&
|
109
|
+
::File.directory?(current_resource.target_file)
|
110
|
+
converge_by("unlink existing windows symlink to dir at #{new_resource.target_file}") do
|
111
|
+
::Dir.unlink(new_resource.target_file)
|
112
112
|
end
|
113
113
|
else
|
114
|
-
converge_by("unlink existing symlink to file at #{
|
115
|
-
::File.unlink(
|
114
|
+
converge_by("unlink existing symlink to file at #{new_resource.target_file}") do
|
115
|
+
::File.unlink(new_resource.target_file)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
119
|
-
if
|
120
|
-
converge_by("create symlink at #{
|
121
|
-
file_class.symlink(canonicalize(
|
122
|
-
Chef::Log.debug("#{
|
123
|
-
Chef::Log.info("#{
|
119
|
+
if new_resource.link_type == :symbolic
|
120
|
+
converge_by("create symlink at #{new_resource.target_file} to #{new_resource.to}") do
|
121
|
+
file_class.symlink(canonicalize(new_resource.to), new_resource.target_file)
|
122
|
+
Chef::Log.debug("#{new_resource} created #{new_resource.link_type} link from #{new_resource.target_file} -> #{new_resource.to}")
|
123
|
+
Chef::Log.info("#{new_resource} created")
|
124
124
|
# file_class.symlink will create the link with default access controls.
|
125
125
|
# This means that the access controls of the file could be different
|
126
126
|
# than those captured during the initial evaluation of current_resource.
|
127
127
|
# We need to re-evaluate the current_resource to ensure that the desired
|
128
128
|
# access controls are applied.
|
129
|
-
ScanAccessControl.new(
|
129
|
+
ScanAccessControl.new(new_resource, current_resource).set_all!
|
130
130
|
end
|
131
|
-
elsif
|
132
|
-
converge_by("create hard link at #{
|
133
|
-
file_class.link(
|
134
|
-
Chef::Log.debug("#{
|
135
|
-
Chef::Log.info("#{
|
131
|
+
elsif new_resource.link_type == :hard
|
132
|
+
converge_by("create hard link at #{new_resource.target_file} to #{new_resource.to}") do
|
133
|
+
file_class.link(new_resource.to, new_resource.target_file)
|
134
|
+
Chef::Log.debug("#{new_resource} created #{new_resource.link_type} link from #{new_resource.target_file} -> #{new_resource.to}")
|
135
|
+
Chef::Log.info("#{new_resource} created")
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
139
|
-
if
|
139
|
+
if new_resource.link_type == :symbolic
|
140
140
|
if access_controls.requires_changes?
|
141
141
|
converge_by(access_controls.describe_changes) do
|
142
142
|
access_controls.set_all
|
@@ -146,16 +146,16 @@ class Chef
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def action_delete
|
149
|
-
if
|
150
|
-
if Chef::Platform.windows? && ::File.directory?(
|
151
|
-
converge_by("delete link to dir at #{
|
152
|
-
::Dir.delete(
|
153
|
-
Chef::Log.info("#{
|
149
|
+
if current_resource.to # Exists
|
150
|
+
if Chef::Platform.windows? && ::File.directory?(current_resource.target_file)
|
151
|
+
converge_by("delete link to dir at #{new_resource.target_file}") do
|
152
|
+
::Dir.delete(new_resource.target_file)
|
153
|
+
Chef::Log.info("#{new_resource} deleted")
|
154
154
|
end
|
155
155
|
else
|
156
|
-
converge_by("delete link to file at #{
|
157
|
-
::File.delete(
|
158
|
-
Chef::Log.info("#{
|
156
|
+
converge_by("delete link to file at #{new_resource.target_file}") do
|
157
|
+
::File.delete(new_resource.target_file)
|
158
|
+
Chef::Log.info("#{new_resource} deleted")
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
@@ -165,7 +165,7 @@ class Chef
|
|
165
165
|
# access control (e.g., use lchmod instead of chmod) if the resource is a
|
166
166
|
# symlink.
|
167
167
|
def manage_symlink_access?
|
168
|
-
|
168
|
+
new_resource.link_type == :symbolic
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
data/lib/chef/provider/log.rb
CHANGED
@@ -44,8 +44,8 @@ class Chef
|
|
44
44
|
# === Return
|
45
45
|
# true:: Always return true
|
46
46
|
def action_write
|
47
|
-
Chef::Log.send(
|
48
|
-
|
47
|
+
Chef::Log.send(new_resource.level, new_resource.message)
|
48
|
+
new_resource.updated_by_last_action(true) if Chef::Config[:count_log_resource_updates]
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
data/lib/chef/provider/mdadm.rb
CHANGED
@@ -34,57 +34,57 @@ class Chef
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_current_resource
|
37
|
-
@current_resource = Chef::Resource::Mdadm.new(
|
38
|
-
|
39
|
-
Chef::Log.debug("#{
|
37
|
+
@current_resource = Chef::Resource::Mdadm.new(new_resource.name)
|
38
|
+
current_resource.raid_device(new_resource.raid_device)
|
39
|
+
Chef::Log.debug("#{new_resource} checking for software raid device #{current_resource.raid_device}")
|
40
40
|
|
41
41
|
device_not_found = 4
|
42
|
-
mdadm = shell_out!("mdadm --detail --test #{
|
42
|
+
mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", :returns => [0, device_not_found])
|
43
43
|
exists = (mdadm.status == 0)
|
44
|
-
|
44
|
+
current_resource.exists(exists)
|
45
45
|
end
|
46
46
|
|
47
47
|
def action_create
|
48
|
-
unless
|
48
|
+
unless current_resource.exists
|
49
49
|
converge_by("create RAID device #{new_resource.raid_device}") do
|
50
|
-
command = "yes | mdadm --create #{
|
51
|
-
command << " --chunk=#{
|
52
|
-
command << " --metadata=#{
|
53
|
-
command << " --bitmap=#{
|
54
|
-
command << " --layout=#{
|
55
|
-
command << " --raid-devices #{
|
56
|
-
Chef::Log.debug("#{
|
50
|
+
command = "yes | mdadm --create #{new_resource.raid_device} --level #{new_resource.level}"
|
51
|
+
command << " --chunk=#{new_resource.chunk}" unless new_resource.level == 1
|
52
|
+
command << " --metadata=#{new_resource.metadata}"
|
53
|
+
command << " --bitmap=#{new_resource.bitmap}" if new_resource.bitmap
|
54
|
+
command << " --layout=#{new_resource.layout}" if new_resource.layout
|
55
|
+
command << " --raid-devices #{new_resource.devices.length} #{new_resource.devices.join(" ")}"
|
56
|
+
Chef::Log.debug("#{new_resource} mdadm command: #{command}")
|
57
57
|
shell_out!(command)
|
58
|
-
Chef::Log.info("#{
|
58
|
+
Chef::Log.info("#{new_resource} created raid device (#{new_resource.raid_device})")
|
59
59
|
end
|
60
60
|
else
|
61
|
-
Chef::Log.debug("#{
|
61
|
+
Chef::Log.debug("#{new_resource} raid device already exists, skipping create (#{new_resource.raid_device})")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def action_assemble
|
66
|
-
unless
|
66
|
+
unless current_resource.exists
|
67
67
|
converge_by("assemble RAID device #{new_resource.raid_device}") do
|
68
|
-
command = "yes | mdadm --assemble #{
|
69
|
-
Chef::Log.debug("#{
|
68
|
+
command = "yes | mdadm --assemble #{new_resource.raid_device} #{new_resource.devices.join(" ")}"
|
69
|
+
Chef::Log.debug("#{new_resource} mdadm command: #{command}")
|
70
70
|
shell_out!(command)
|
71
|
-
Chef::Log.info("#{
|
71
|
+
Chef::Log.info("#{new_resource} assembled raid device (#{new_resource.raid_device})")
|
72
72
|
end
|
73
73
|
else
|
74
|
-
Chef::Log.debug("#{
|
74
|
+
Chef::Log.debug("#{new_resource} raid device already exists, skipping assemble (#{new_resource.raid_device})")
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
def action_stop
|
79
|
-
if
|
79
|
+
if current_resource.exists
|
80
80
|
converge_by("stop RAID device #{new_resource.raid_device}") do
|
81
|
-
command = "yes | mdadm --stop #{
|
82
|
-
Chef::Log.debug("#{
|
81
|
+
command = "yes | mdadm --stop #{new_resource.raid_device}"
|
82
|
+
Chef::Log.debug("#{new_resource} mdadm command: #{command}")
|
83
83
|
shell_out!(command)
|
84
|
-
Chef::Log.info("#{
|
84
|
+
Chef::Log.info("#{new_resource} stopped raid device (#{new_resource.raid_device})")
|
85
85
|
end
|
86
86
|
else
|
87
|
-
Chef::Log.debug("#{
|
87
|
+
Chef::Log.debug("#{new_resource} raid device doesn't exist (#{new_resource.raid_device}) - not stopping")
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -116,9 +116,9 @@ class Chef
|
|
116
116
|
|
117
117
|
def remount_command
|
118
118
|
if !(@new_resource.options.nil? || @new_resource.options.empty?)
|
119
|
-
|
119
|
+
"mount -o remount,#{@new_resource.options.join(',')} #{@new_resource.device} #{@new_resource.mount_point}"
|
120
120
|
else
|
121
|
-
|
121
|
+
"mount -o remount #{@new_resource.device} #{@new_resource.mount_point}"
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -47,7 +47,7 @@ class Chef
|
|
47
47
|
elsif @new_resource.mount_point != "none" && !::File.exists?(@new_resource.mount_point)
|
48
48
|
raise Chef::Exceptions::Mount, "Mount point #{@new_resource.mount_point} does not exist"
|
49
49
|
end
|
50
|
-
|
50
|
+
true
|
51
51
|
end
|
52
52
|
|
53
53
|
def enabled?
|
@@ -129,7 +129,7 @@ class Chef
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def remount_command
|
132
|
-
|
132
|
+
"mount -o remount,#{@new_resource.options.join(',')} #{@new_resource.mount_point}"
|
133
133
|
end
|
134
134
|
|
135
135
|
def remount_fs
|
data/lib/chef/provider/ohai.rb
CHANGED
@@ -37,7 +37,7 @@ class Chef
|
|
37
37
|
converge_by("re-run ohai and merge results into node attributes") do
|
38
38
|
ohai = ::Ohai::System.new
|
39
39
|
|
40
|
-
# If
|
40
|
+
# If new_resource.plugin is nil, ohai will reload all the plugins
|
41
41
|
# Otherwise it will only reload the specified plugin
|
42
42
|
# Note that any changes to plugins, or new plugins placed on
|
43
43
|
# the path are picked up by ohai.
|
@@ -34,16 +34,16 @@ class Chef
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_current_resource
|
37
|
-
@current_resource = Chef::Resource::OsxProfile.new(
|
38
|
-
|
37
|
+
@current_resource = Chef::Resource::OsxProfile.new(new_resource.name)
|
38
|
+
current_resource.profile_name(new_resource.profile_name)
|
39
39
|
|
40
40
|
all_profiles = get_installed_profiles
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
new_resource.profile(
|
42
|
+
new_resource.profile ||
|
43
|
+
new_resource.profile_name
|
44
44
|
)
|
45
45
|
|
46
|
-
@new_profile_hash = get_profile_hash(
|
46
|
+
@new_profile_hash = get_profile_hash(new_resource.profile)
|
47
47
|
if @new_profile_hash
|
48
48
|
@new_profile_hash["PayloadUUID"] =
|
49
49
|
config_uuid(@new_profile_hash)
|
@@ -52,8 +52,8 @@ class Chef
|
|
52
52
|
if @new_profile_hash
|
53
53
|
@new_profile_identifier = @new_profile_hash["PayloadIdentifier"]
|
54
54
|
else
|
55
|
-
@new_profile_identifier =
|
56
|
-
|
55
|
+
@new_profile_identifier = new_resource.identifier ||
|
56
|
+
new_resource.profile_name
|
57
57
|
end
|
58
58
|
|
59
59
|
current_profile = nil
|
@@ -62,7 +62,7 @@ class Chef
|
|
62
62
|
item["ProfileIdentifier"] == @new_profile_identifier
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
65
|
+
current_resource.profile(current_profile)
|
66
66
|
end
|
67
67
|
|
68
68
|
def define_resource_requirements
|
@@ -75,7 +75,7 @@ class Chef
|
|
75
75
|
end
|
76
76
|
a.failure_message RuntimeError, "when removing using the identifier attribute, it must match the profile identifier"
|
77
77
|
else
|
78
|
-
new_profile_name =
|
78
|
+
new_profile_name = new_resource.profile_name
|
79
79
|
a.assertion do
|
80
80
|
!new_profile_name.end_with?(".mobileconfig") &&
|
81
81
|
/^\w+(?:(\.| )\w+)+$/.match(new_profile_name)
|
@@ -128,21 +128,21 @@ class Chef
|
|
128
128
|
raise Chef::Exceptions::FileNotFound, error_string
|
129
129
|
end
|
130
130
|
cookbook_profile = cache_cookbook_profile(new_profile)
|
131
|
-
|
131
|
+
read_plist(cookbook_profile)
|
132
132
|
else
|
133
|
-
|
133
|
+
nil
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
def cookbook_file_available?(cookbook_file)
|
138
138
|
run_context.has_cookbook_file_in_cookbook?(
|
139
|
-
|
139
|
+
new_resource.cookbook_name, cookbook_file
|
140
140
|
)
|
141
141
|
end
|
142
142
|
|
143
143
|
def get_cache_dir
|
144
144
|
cache_dir = Chef::FileCache.create_cache_path(
|
145
|
-
"profiles/#{
|
145
|
+
"profiles/#{new_resource.cookbook_name}"
|
146
146
|
)
|
147
147
|
end
|
148
148
|
|
@@ -150,7 +150,7 @@ class Chef
|
|
150
150
|
Chef::FileCache.create_cache_path(
|
151
151
|
::File.join(
|
152
152
|
"profiles",
|
153
|
-
|
153
|
+
new_resource.cookbook_name,
|
154
154
|
::File.dirname(cookbook_file)
|
155
155
|
)
|
156
156
|
)
|
@@ -161,7 +161,7 @@ class Chef
|
|
161
161
|
),
|
162
162
|
run_context
|
163
163
|
)
|
164
|
-
remote_file.cookbook_name =
|
164
|
+
remote_file.cookbook_name = new_resource.cookbook_name
|
165
165
|
remote_file.source(cookbook_file)
|
166
166
|
remote_file.backup(false)
|
167
167
|
remote_file.run_action(:create)
|
@@ -170,9 +170,9 @@ class Chef
|
|
170
170
|
|
171
171
|
def get_profile_hash(new_profile)
|
172
172
|
if new_profile.is_a?(Hash)
|
173
|
-
|
173
|
+
new_profile
|
174
174
|
elsif new_profile.is_a?(String)
|
175
|
-
|
175
|
+
load_profile_hash(new_profile)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -185,8 +185,8 @@ class Chef
|
|
185
185
|
end
|
186
186
|
|
187
187
|
def write_profile_to_disk
|
188
|
-
|
189
|
-
tempfile = Chef::FileContentManagement::Tempfile.new(
|
188
|
+
new_resource.path(Chef::FileCache.create_cache_path("profiles"))
|
189
|
+
tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
|
190
190
|
tempfile.write(@new_profile_hash.to_plist)
|
191
191
|
tempfile.close
|
192
192
|
tempfile.path
|
@@ -240,13 +240,13 @@ class Chef
|
|
240
240
|
|
241
241
|
def profile_installed?
|
242
242
|
# Profile Identifier and UUID must match a currently installed profile
|
243
|
-
if
|
243
|
+
if current_resource.profile.nil? || current_resource.profile.empty?
|
244
244
|
false
|
245
245
|
else
|
246
|
-
if
|
246
|
+
if new_resource.action.include?(:remove)
|
247
247
|
true
|
248
248
|
else
|
249
|
-
|
249
|
+
current_resource.profile["ProfileUUID"] ==
|
250
250
|
@new_profile_hash["PayloadUUID"]
|
251
251
|
end
|
252
252
|
end
|