chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32
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
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2017, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -52,6 +52,17 @@ class Chef
|
|
52
52
|
@candidate_version = nil
|
53
53
|
end
|
54
54
|
|
55
|
+
def options
|
56
|
+
if new_resource.options.is_a?(String)
|
57
|
+
# XXX: needs to handle double quotes, single quotes, nested quotes, etc and probably act
|
58
|
+
# more like a space-separated "C"SV file -- although users can fix this just by passing in
|
59
|
+
# a correctly pre-split Array.
|
60
|
+
new_resource.options.split(" ")
|
61
|
+
else
|
62
|
+
new_resource.options
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
55
66
|
def whyrun_supported?
|
56
67
|
true
|
57
68
|
end
|
@@ -64,16 +75,15 @@ class Chef
|
|
64
75
|
end
|
65
76
|
end
|
66
77
|
|
67
|
-
def load_current_resource
|
68
|
-
end
|
78
|
+
def load_current_resource; end
|
69
79
|
|
70
80
|
def define_resource_requirements
|
71
81
|
# XXX: upgrade with a specific version doesn't make a whole lot of sense, but why don't we throw this anyway if it happens?
|
72
82
|
# if not, shouldn't we raise to tell the user to use install instead of upgrade if they want to pin a version?
|
73
83
|
requirements.assert(:install) do |a|
|
74
84
|
a.assertion { candidates_exist_for_all_forced_changes? }
|
75
|
-
a.failure_message(Chef::Exceptions::Package, "No version specified, and no candidate version available for #{forced_packages_missing_candidates.join(
|
76
|
-
a.whyrun("Assuming a repository that offers #{forced_packages_missing_candidates.join(
|
85
|
+
a.failure_message(Chef::Exceptions::Package, "No version specified, and no candidate version available for #{forced_packages_missing_candidates.join(', ')}")
|
86
|
+
a.whyrun("Assuming a repository that offers #{forced_packages_missing_candidates.join(', ')} would have been configured")
|
77
87
|
end
|
78
88
|
|
79
89
|
# XXX: Does it make sense to pass in a source with :upgrade? Probably
|
@@ -81,19 +91,19 @@ class Chef
|
|
81
91
|
# so we'll just leave things as-is for now.
|
82
92
|
requirements.assert(:upgrade, :install) do |a|
|
83
93
|
a.assertion { candidates_exist_for_all_uninstalled? || new_resource.source }
|
84
|
-
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(
|
85
|
-
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(
|
94
|
+
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(', ')}")
|
95
|
+
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(', ')} would have been configured")
|
86
96
|
end
|
87
97
|
end
|
88
98
|
|
89
99
|
action :install do
|
90
100
|
unless target_version_array.any?
|
91
|
-
Chef::Log.debug("#{
|
101
|
+
Chef::Log.debug("#{new_resource} is already installed - nothing to do")
|
92
102
|
return
|
93
103
|
end
|
94
104
|
|
95
105
|
# @todo: move the preseed code out of the base class (and complete the fix for Array of preseeds? ugh...)
|
96
|
-
if
|
106
|
+
if new_resource.response_file
|
97
107
|
if preseed_file = get_preseed_file(package_names_for_targets, versions_for_targets)
|
98
108
|
converge_by("preseed package #{package_names_for_targets}") do
|
99
109
|
preseed_package(preseed_file)
|
@@ -105,7 +115,7 @@ class Chef
|
|
105
115
|
multipackage_api_adapter(package_names_for_targets, versions_for_targets) do |name, version|
|
106
116
|
install_package(name, version)
|
107
117
|
end
|
108
|
-
Chef::Log.info("#{
|
118
|
+
Chef::Log.info("#{new_resource} installed #{package_names_for_targets} at #{versions_for_targets}")
|
109
119
|
end
|
110
120
|
end
|
111
121
|
|
@@ -122,8 +132,8 @@ class Chef
|
|
122
132
|
private :install_description
|
123
133
|
|
124
134
|
action :upgrade do
|
125
|
-
|
126
|
-
Chef::Log.debug("#{
|
135
|
+
unless target_version_array.any?
|
136
|
+
Chef::Log.debug("#{new_resource} no versions to upgrade - nothing to do")
|
127
137
|
return
|
128
138
|
end
|
129
139
|
|
@@ -132,7 +142,7 @@ class Chef
|
|
132
142
|
upgrade_package(name, version)
|
133
143
|
end
|
134
144
|
log_allow_downgrade = allow_downgrade ? "(allow_downgrade)" : ""
|
135
|
-
Chef::Log.info("#{
|
145
|
+
Chef::Log.info("#{new_resource} upgraded#{log_allow_downgrade} #{package_names_for_targets} to #{versions_for_targets}")
|
136
146
|
end
|
137
147
|
end
|
138
148
|
|
@@ -153,15 +163,15 @@ class Chef
|
|
153
163
|
|
154
164
|
action :remove do
|
155
165
|
if removing_package?
|
156
|
-
description =
|
157
|
-
converge_by("remove #{description}package #{
|
158
|
-
multipackage_api_adapter(
|
166
|
+
description = new_resource.version ? "version #{new_resource.version} of " : ""
|
167
|
+
converge_by("remove #{description}package #{current_resource.package_name}") do
|
168
|
+
multipackage_api_adapter(current_resource.package_name, new_resource.version) do |name, version|
|
159
169
|
remove_package(name, version)
|
160
170
|
end
|
161
|
-
Chef::Log.info("#{
|
171
|
+
Chef::Log.info("#{new_resource} removed")
|
162
172
|
end
|
163
173
|
else
|
164
|
-
Chef::Log.debug("#{
|
174
|
+
Chef::Log.debug("#{new_resource} package does not exist - nothing to do")
|
165
175
|
end
|
166
176
|
end
|
167
177
|
|
@@ -188,48 +198,48 @@ class Chef
|
|
188
198
|
|
189
199
|
action :purge do
|
190
200
|
if removing_package?
|
191
|
-
description =
|
192
|
-
converge_by("purge #{description} package #{
|
193
|
-
multipackage_api_adapter(
|
201
|
+
description = new_resource.version ? "version #{new_resource.version} of" : ""
|
202
|
+
converge_by("purge #{description} package #{current_resource.package_name}") do
|
203
|
+
multipackage_api_adapter(current_resource.package_name, new_resource.version) do |name, version|
|
194
204
|
purge_package(name, version)
|
195
205
|
end
|
196
|
-
Chef::Log.info("#{
|
206
|
+
Chef::Log.info("#{new_resource} purged")
|
197
207
|
end
|
198
208
|
end
|
199
209
|
end
|
200
210
|
|
201
211
|
action :reconfig do
|
202
|
-
if
|
203
|
-
Chef::Log.debug("#{
|
212
|
+
if current_resource.version.nil?
|
213
|
+
Chef::Log.debug("#{new_resource} is NOT installed - nothing to do")
|
204
214
|
return
|
205
215
|
end
|
206
216
|
|
207
|
-
unless
|
208
|
-
Chef::Log.debug("#{
|
217
|
+
unless new_resource.response_file
|
218
|
+
Chef::Log.debug("#{new_resource} no response_file provided - nothing to do")
|
209
219
|
return
|
210
220
|
end
|
211
221
|
|
212
|
-
if preseed_file = get_preseed_file(
|
213
|
-
converge_by("reconfigure package #{
|
222
|
+
if preseed_file = get_preseed_file(new_resource.package_name, current_resource.version)
|
223
|
+
converge_by("reconfigure package #{new_resource.package_name}") do
|
214
224
|
preseed_package(preseed_file)
|
215
|
-
multipackage_api_adapter(
|
225
|
+
multipackage_api_adapter(new_resource.package_name, current_resource.version) do |name, version|
|
216
226
|
reconfig_package(name, version)
|
217
227
|
|
218
228
|
end
|
219
|
-
Chef::Log.info("#{
|
229
|
+
Chef::Log.info("#{new_resource} reconfigured")
|
220
230
|
end
|
221
231
|
else
|
222
|
-
Chef::Log.debug("#{
|
232
|
+
Chef::Log.debug("#{new_resource} preseeding has not changed - nothing to do")
|
223
233
|
end
|
224
234
|
end
|
225
235
|
|
226
236
|
def action_lock
|
227
|
-
if package_locked(
|
228
|
-
description =
|
229
|
-
converge_by("lock #{description}package #{
|
230
|
-
multipackage_api_adapter(
|
237
|
+
if package_locked(new_resource.name, new_resource.version) == false
|
238
|
+
description = new_resource.version ? "version #{new_resource.version} of " : ""
|
239
|
+
converge_by("lock #{description}package #{current_resource.package_name}") do
|
240
|
+
multipackage_api_adapter(current_resource.package_name, new_resource.version) do |name, version|
|
231
241
|
lock_package(name, version)
|
232
|
-
Chef::Log.info("#{
|
242
|
+
Chef::Log.info("#{new_resource} locked")
|
233
243
|
end
|
234
244
|
end
|
235
245
|
else
|
@@ -238,12 +248,12 @@ class Chef
|
|
238
248
|
end
|
239
249
|
|
240
250
|
def action_unlock
|
241
|
-
if package_locked(
|
242
|
-
description =
|
243
|
-
converge_by("unlock #{description}package #{
|
244
|
-
multipackage_api_adapter(
|
251
|
+
if package_locked(new_resource.name, new_resource.version) == true
|
252
|
+
description = new_resource.version ? "version #{new_resource.version} of " : ""
|
253
|
+
converge_by("unlock #{description}package #{current_resource.package_name}") do
|
254
|
+
multipackage_api_adapter(current_resource.package_name, new_resource.version) do |name, version|
|
245
255
|
unlock_package(name, version)
|
246
|
-
Chef::Log.info("#{
|
256
|
+
Chef::Log.info("#{new_resource} unlocked")
|
247
257
|
end
|
248
258
|
end
|
249
259
|
else
|
@@ -251,6 +261,10 @@ class Chef
|
|
251
261
|
end
|
252
262
|
end
|
253
263
|
|
264
|
+
def package_locked(name, version)
|
265
|
+
raise Chef::Exceptions::UnsupportedAction, "#{self} has no way to detect if package is locked"
|
266
|
+
end
|
267
|
+
|
254
268
|
# @todo use composition rather than inheritance
|
255
269
|
|
256
270
|
def multipackage_api_adapter(name, version)
|
@@ -295,6 +309,8 @@ class Chef
|
|
295
309
|
|
296
310
|
# used by subclasses. deprecated. use #a_to_s instead.
|
297
311
|
def expand_options(options)
|
312
|
+
# its deprecated but still work to do to deprecate it fully
|
313
|
+
#Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out_compact or shell_out_compact_timeout instead")
|
298
314
|
options ? " #{options}" : ""
|
299
315
|
end
|
300
316
|
|
@@ -339,7 +355,7 @@ class Chef
|
|
339
355
|
def get_preseed_file(name, version)
|
340
356
|
resource = preseed_resource(name, version)
|
341
357
|
resource.run_action(:create)
|
342
|
-
Chef::Log.debug("#{
|
358
|
+
Chef::Log.debug("#{new_resource} fetched preseed file to #{resource.path}")
|
343
359
|
|
344
360
|
if resource.updated_by_last_action?
|
345
361
|
resource.path
|
@@ -351,26 +367,26 @@ class Chef
|
|
351
367
|
# @todo: extract apt/dpkg specific preseeding to a helper class
|
352
368
|
def preseed_resource(name, version)
|
353
369
|
# A directory in our cache to store this cookbook's preseed files in
|
354
|
-
file_cache_dir = Chef::FileCache.create_cache_path("preseed/#{
|
370
|
+
file_cache_dir = Chef::FileCache.create_cache_path("preseed/#{new_resource.cookbook_name}")
|
355
371
|
# The full path where the preseed file will be stored
|
356
372
|
cache_seed_to = "#{file_cache_dir}/#{name}-#{version}.seed"
|
357
373
|
|
358
|
-
Chef::Log.debug("#{
|
374
|
+
Chef::Log.debug("#{new_resource} fetching preseed file to #{cache_seed_to}")
|
359
375
|
|
360
|
-
if template_available?(
|
361
|
-
Chef::Log.debug("#{
|
376
|
+
if template_available?(new_resource.response_file)
|
377
|
+
Chef::Log.debug("#{new_resource} fetching preseed file via Template")
|
362
378
|
remote_file = Chef::Resource::Template.new(cache_seed_to, run_context)
|
363
|
-
remote_file.variables(
|
364
|
-
elsif cookbook_file_available?(
|
365
|
-
Chef::Log.debug("#{
|
379
|
+
remote_file.variables(new_resource.response_file_variables)
|
380
|
+
elsif cookbook_file_available?(new_resource.response_file)
|
381
|
+
Chef::Log.debug("#{new_resource} fetching preseed file via cookbook_file")
|
366
382
|
remote_file = Chef::Resource::CookbookFile.new(cache_seed_to, run_context)
|
367
383
|
else
|
368
|
-
message = "No template or cookbook file found for response file #{
|
384
|
+
message = "No template or cookbook file found for response file #{new_resource.response_file}"
|
369
385
|
raise Chef::Exceptions::FileNotFound, message
|
370
386
|
end
|
371
387
|
|
372
|
-
remote_file.cookbook_name =
|
373
|
-
remote_file.source(
|
388
|
+
remote_file.cookbook_name = new_resource.cookbook_name
|
389
|
+
remote_file.source(new_resource.response_file)
|
374
390
|
remote_file.backup(false)
|
375
391
|
remote_file
|
376
392
|
end
|
@@ -608,8 +624,8 @@ class Chef
|
|
608
624
|
end
|
609
625
|
|
610
626
|
def allow_downgrade
|
611
|
-
if
|
612
|
-
|
627
|
+
if new_resource.respond_to?("allow_downgrade")
|
628
|
+
new_resource.allow_downgrade
|
613
629
|
else
|
614
630
|
false
|
615
631
|
end
|
@@ -624,14 +640,16 @@ class Chef
|
|
624
640
|
end
|
625
641
|
|
626
642
|
def add_timeout_option(command_args)
|
643
|
+
# this is deprecated but its not quite done yet
|
644
|
+
#Chef.deprecated(:package_misc, "shell_out_with_timeout and add_timeout_option are deprecated methods, use shell_out_compact_timeout instead")
|
627
645
|
args = command_args.dup
|
628
646
|
if args.last.is_a?(Hash)
|
629
647
|
options = args.pop.dup
|
630
648
|
options[:timeout] = new_resource.timeout if new_resource.timeout
|
631
|
-
options[:timeout] = 900 unless options.
|
649
|
+
options[:timeout] = 900 unless options.key?(:timeout)
|
632
650
|
args << options
|
633
651
|
else
|
634
|
-
args << { :
|
652
|
+
args << { timeout: new_resource.timeout ? new_resource.timeout : 900 }
|
635
653
|
end
|
636
654
|
args
|
637
655
|
end
|
@@ -34,48 +34,45 @@ class Chef
|
|
34
34
|
def define_resource_requirements
|
35
35
|
super
|
36
36
|
requirements.assert(:install) do |a|
|
37
|
-
a.assertion {
|
38
|
-
a.failure_message Chef::Exceptions::Package, "Source for package #{
|
37
|
+
a.assertion { new_resource.source }
|
38
|
+
a.failure_message Chef::Exceptions::Package, "Source for package #{new_resource.name} required for action install"
|
39
39
|
end
|
40
40
|
requirements.assert(:all_actions) do |a|
|
41
|
-
a.assertion {
|
42
|
-
a.failure_message Chef::Exceptions::Package, "Package #{
|
43
|
-
a.whyrun "would assume #{
|
41
|
+
a.assertion { !new_resource.source || package_source_found? }
|
42
|
+
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.name} not found: #{new_resource.source}"
|
43
|
+
a.whyrun "would assume #{new_resource.source} would be have previously been made available"
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def load_current_resource
|
48
|
-
@current_resource = Chef::Resource::Package.new(
|
49
|
-
|
48
|
+
@current_resource = Chef::Resource::Package.new(new_resource.name)
|
49
|
+
current_resource.package_name(new_resource.package_name)
|
50
50
|
|
51
|
-
if
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
fields = line.split(":")
|
64
|
-
@new_resource.version(fields[2])
|
65
|
-
end
|
51
|
+
if package_source_found?
|
52
|
+
Chef::Log.debug("#{new_resource} checking pkg status")
|
53
|
+
ret = shell_out_compact_timeout("installp", "-L", "-d", new_resource.source)
|
54
|
+
ret.stdout.each_line do |line|
|
55
|
+
case line
|
56
|
+
when /:#{new_resource.package_name}:/
|
57
|
+
fields = line.split(":")
|
58
|
+
new_resource.version(fields[2])
|
59
|
+
when /^#{new_resource.package_name}:/
|
60
|
+
Chef::Log.warn("You are installing a bff package by product name. For idempotent installs, please install individual filesets")
|
61
|
+
fields = line.split(":")
|
62
|
+
new_resource.version(fields[2])
|
66
63
|
end
|
67
|
-
raise Chef::Exceptions::Package, "package source #{@new_resource.source} does not provide package #{@new_resource.package_name}" unless @new_resource.version
|
68
64
|
end
|
65
|
+
raise Chef::Exceptions::Package, "package source #{new_resource.source} does not provide package #{new_resource.package_name}" unless new_resource.version
|
69
66
|
end
|
70
67
|
|
71
|
-
Chef::Log.debug("#{
|
72
|
-
ret =
|
68
|
+
Chef::Log.debug("#{new_resource} checking install state")
|
69
|
+
ret = shell_out_compact_timeout("lslpp", "-lcq", current_resource.package_name)
|
73
70
|
ret.stdout.each_line do |line|
|
74
71
|
case line
|
75
|
-
when /#{
|
72
|
+
when /#{current_resource.package_name}/
|
76
73
|
fields = line.split(":")
|
77
|
-
Chef::Log.debug("#{
|
78
|
-
|
74
|
+
Chef::Log.debug("#{new_resource} version #{fields[2]} is already installed")
|
75
|
+
current_resource.version(fields[2])
|
79
76
|
end
|
80
77
|
end
|
81
78
|
|
@@ -83,23 +80,25 @@ class Chef
|
|
83
80
|
raise Chef::Exceptions::Package, "lslpp failed - #{ret.format_for_exception}!"
|
84
81
|
end
|
85
82
|
|
86
|
-
|
83
|
+
current_resource
|
87
84
|
end
|
88
85
|
|
89
86
|
def candidate_version
|
90
87
|
return @candidate_version if @candidate_version
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
88
|
+
if package_source_found?
|
89
|
+
ret = shell_out_compact_timeout("installp", "-L", "-d", new_resource.source)
|
90
|
+
ret.stdout.each_line do |line|
|
91
|
+
case line
|
92
|
+
when /\w:#{Regexp.escape(new_resource.package_name)}:(.*)/
|
93
|
+
fields = line.split(":")
|
94
|
+
@candidate_version = fields[2]
|
95
|
+
new_resource.version(fields[2])
|
96
|
+
Chef::Log.debug("#{new_resource} setting install candidate version to #{@candidate_version}")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
unless ret.exitstatus == 0
|
100
|
+
raise Chef::Exceptions::Package, "installp -L -d #{new_resource.source} - #{ret.format_for_exception}!"
|
99
101
|
end
|
100
|
-
end
|
101
|
-
unless ret.exitstatus == 0
|
102
|
-
raise Chef::Exceptions::Package, "installp -L -d #{@new_resource.source} - #{ret.format_for_exception}!"
|
103
102
|
end
|
104
103
|
@candidate_version
|
105
104
|
end
|
@@ -112,28 +111,32 @@ class Chef
|
|
112
111
|
# So far, the code has been tested only with standalone packages.
|
113
112
|
#
|
114
113
|
def install_package(name, version)
|
115
|
-
Chef::Log.debug("#{
|
116
|
-
if
|
117
|
-
|
118
|
-
Chef::Log.debug("#{
|
114
|
+
Chef::Log.debug("#{new_resource} package install options: #{options}")
|
115
|
+
if options.nil?
|
116
|
+
shell_out_compact_timeout!("installp", "-aYF", "-d", new_resource.source, new_resource.package_name)
|
117
|
+
Chef::Log.debug("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
|
119
118
|
else
|
120
|
-
|
121
|
-
Chef::Log.debug("#{
|
119
|
+
shell_out_compact_timeout!("installp", "-aYF", options, "-d", new_resource.source, new_resource.package_name)
|
120
|
+
Chef::Log.debug("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
|
122
121
|
end
|
123
122
|
end
|
124
123
|
|
125
|
-
|
124
|
+
alias upgrade_package install_package
|
126
125
|
|
127
126
|
def remove_package(name, version)
|
128
|
-
if
|
129
|
-
|
130
|
-
Chef::Log.debug("#{
|
127
|
+
if options.nil?
|
128
|
+
shell_out_compact_timeout!("installp", "-u", name)
|
129
|
+
Chef::Log.debug("#{new_resource} removed version #{new_resource.version}")
|
131
130
|
else
|
132
|
-
|
133
|
-
Chef::Log.debug("#{
|
131
|
+
shell_out_compact_timeout!("installp", "-u", options, name)
|
132
|
+
Chef::Log.debug("#{new_resource} removed version #{new_resource.version}")
|
134
133
|
end
|
135
134
|
end
|
136
135
|
|
136
|
+
def package_source_found?
|
137
|
+
@package_source_found ||= new_resource.source && ::File.exist?(new_resource.source)
|
138
|
+
end
|
139
|
+
|
137
140
|
end
|
138
141
|
end
|
139
142
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2017, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -72,21 +72,21 @@ class Chef
|
|
72
72
|
|
73
73
|
def package_locked(name, version)
|
74
74
|
islocked = false
|
75
|
-
locked =
|
75
|
+
locked = shell_out_compact_timeout!("apt-mark", "showhold")
|
76
76
|
locked.stdout.each_line do |line|
|
77
77
|
line_package = line.strip
|
78
78
|
if line_package == name
|
79
79
|
islocked = true
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
82
|
+
islocked
|
83
83
|
end
|
84
84
|
|
85
85
|
def install_package(name, version)
|
86
86
|
package_name = name.zip(version).map do |n, v|
|
87
87
|
package_data[n][:virtual] ? n : "#{n}=#{v}"
|
88
88
|
end
|
89
|
-
run_noninteractive("apt-get -q -y", default_release_options,
|
89
|
+
run_noninteractive("apt-get", "-q", "-y", default_release_options, options, "install", package_name)
|
90
90
|
end
|
91
91
|
|
92
92
|
def upgrade_package(name, version)
|
@@ -97,14 +97,14 @@ class Chef
|
|
97
97
|
package_name = name.map do |n|
|
98
98
|
package_data[n][:virtual] ? resolve_virtual_package_name(n) : n
|
99
99
|
end
|
100
|
-
run_noninteractive("apt-get -q -y",
|
100
|
+
run_noninteractive("apt-get", "-q", "-y", options, "remove", package_name)
|
101
101
|
end
|
102
102
|
|
103
103
|
def purge_package(name, version)
|
104
104
|
package_name = name.map do |n|
|
105
105
|
package_data[n][:virtual] ? resolve_virtual_package_name(n) : n
|
106
106
|
end
|
107
|
-
run_noninteractive("apt-get -q -y",
|
107
|
+
run_noninteractive("apt-get", "-q", "-y", options, "purge", package_name)
|
108
108
|
end
|
109
109
|
|
110
110
|
def preseed_package(preseed_file)
|
@@ -118,11 +118,11 @@ class Chef
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def lock_package(name, version)
|
121
|
-
run_noninteractive("apt-mark",
|
121
|
+
run_noninteractive("apt-mark", options, "hold", name)
|
122
122
|
end
|
123
123
|
|
124
124
|
def unlock_package(name, version)
|
125
|
-
run_noninteractive("apt-mark",
|
125
|
+
run_noninteractive("apt-mark", options, "unhold", name)
|
126
126
|
end
|
127
127
|
|
128
128
|
private
|
@@ -131,12 +131,14 @@ class Chef
|
|
131
131
|
# interactive prompts. Command is run with default localization rather
|
132
132
|
# than forcing locale to "C", so command output may not be stable.
|
133
133
|
def run_noninteractive(*args)
|
134
|
-
|
134
|
+
shell_out_compact_timeout!(*args, env: { "DEBIAN_FRONTEND" => "noninteractive" })
|
135
135
|
end
|
136
136
|
|
137
137
|
def default_release_options
|
138
138
|
# Use apt::Default-Release option only if provider supports it
|
139
|
-
|
139
|
+
if new_resource.respond_to?(:default_release) && new_resource.default_release
|
140
|
+
[ "-o", "APT::Default-Release=#{new_resource.default_release}" ]
|
141
|
+
end
|
140
142
|
end
|
141
143
|
|
142
144
|
def resolve_package_versions(pkg)
|
@@ -156,7 +158,7 @@ class Chef
|
|
156
158
|
end
|
157
159
|
|
158
160
|
def resolve_virtual_package_name(pkg)
|
159
|
-
showpkg = run_noninteractive("apt-cache showpkg", pkg).stdout
|
161
|
+
showpkg = run_noninteractive("apt-cache", "showpkg", pkg).stdout
|
160
162
|
partitions = showpkg.rpartition(/Reverse Provides: ?#{$/}/)
|
161
163
|
return nil if partitions[0] == "" && partitions[1] == "" # not found in output
|
162
164
|
set = partitions[2].lines.each_with_object(Set.new) do |line, acc|
|
@@ -166,7 +168,7 @@ class Chef
|
|
166
168
|
if set.size > 1
|
167
169
|
raise Chef::Exceptions::Package, "#{new_resource.package_name} is a virtual package provided by multiple packages, you must explicitly select one"
|
168
170
|
end
|
169
|
-
|
171
|
+
set.to_a.first
|
170
172
|
end
|
171
173
|
|
172
174
|
def package_data_for(pkg)
|
@@ -186,7 +188,7 @@ class Chef
|
|
186
188
|
end
|
187
189
|
end
|
188
190
|
|
189
|
-
|
191
|
+
{
|
190
192
|
current_version: current_version,
|
191
193
|
candidate_version: candidate_version,
|
192
194
|
virtual: virtual,
|