chef 16.0.257-universal-mingw32 → 16.0.275-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +30 -16
- data/chef.gemspec +1 -1
- data/lib/chef/knife/environment_compare.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/supermarket_install.rb +1 -1
- data/lib/chef/knife/yaml_convert.rb +2 -2
- data/lib/chef/provider/execute.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +2 -1
- data/lib/chef/provider/package/homebrew.rb +1 -1
- data/lib/chef/provider/package/macports.rb +0 -2
- data/lib/chef/provider/package/windows.rb +26 -51
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/resource/alternatives.rb +65 -4
- data/lib/chef/resource/apt_package.rb +31 -2
- data/lib/chef/resource/apt_preference.rb +34 -5
- data/lib/chef/resource/apt_repository.rb +22 -15
- data/lib/chef/resource/apt_update.rb +6 -4
- data/lib/chef/resource/archive_file.rb +5 -4
- data/lib/chef/resource/bash.rb +1 -1
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +1 -1
- data/lib/chef/resource/breakpoint.rb +1 -1
- data/lib/chef/resource/build_essential.rb +8 -4
- data/lib/chef/resource/cab_package.rb +1 -1
- data/lib/chef/resource/chef_client_cron.rb +12 -9
- data/lib/chef/resource/chef_client_scheduled_task.rb +9 -6
- data/lib/chef/resource/chef_client_systemd_timer.rb +10 -7
- data/lib/chef/resource/chef_gem.rb +6 -2
- data/lib/chef/resource/chef_handler.rb +1 -1
- data/lib/chef/resource/chef_sleep.rb +7 -4
- data/lib/chef/resource/chef_vault_secret.rb +3 -3
- data/lib/chef/resource/chocolatey_config.rb +5 -3
- data/lib/chef/resource/chocolatey_feature.rb +5 -3
- data/lib/chef/resource/chocolatey_package.rb +5 -3
- data/lib/chef/resource/chocolatey_source.rb +5 -3
- data/lib/chef/resource/cookbook_file.rb +3 -2
- data/lib/chef/resource/cron.rb +15 -15
- data/lib/chef/resource/cron_access.rb +7 -4
- data/lib/chef/resource/cron_d.rb +37 -23
- data/lib/chef/resource/csh.rb +1 -1
- data/lib/chef/resource/directory.rb +1 -1
- data/lib/chef/resource/dmg_package.rb +18 -15
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/dpkg_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -2
- data/lib/chef/resource/file.rb +5 -4
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +6 -6
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_cask.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +1 -1
- data/lib/chef/resource/hostname.rb +4 -4
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/ifconfig.rb +7 -7
- data/lib/chef/resource/ips_package.rb +1 -1
- data/lib/chef/resource/kernel_module.rb +1 -1
- data/lib/chef/resource/ksh.rb +1 -1
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/link.rb +4 -4
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +1 -1
- data/lib/chef/resource/macos_userdefaults.rb +1 -1
- data/lib/chef/resource/macosx_service.rb +1 -1
- data/lib/chef/resource/macports_package.rb +1 -1
- data/lib/chef/resource/mdadm.rb +1 -1
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/msu_package.rb +1 -1
- data/lib/chef/resource/ohai.rb +1 -1
- data/lib/chef/resource/ohai_hint.rb +1 -1
- data/lib/chef/resource/openbsd_package.rb +1 -1
- data/lib/chef/resource/openssl_dhparam.rb +1 -1
- data/lib/chef/resource/openssl_ec_private_key.rb +1 -1
- data/lib/chef/resource/openssl_ec_public_key.rb +1 -1
- data/lib/chef/resource/openssl_rsa_private_key.rb +1 -1
- data/lib/chef/resource/openssl_rsa_public_key.rb +1 -1
- data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
- data/lib/chef/resource/openssl_x509_crl.rb +1 -1
- data/lib/chef/resource/openssl_x509_request.rb +1 -1
- data/lib/chef/resource/osx_profile.rb +1 -1
- data/lib/chef/resource/package.rb +1 -1
- data/lib/chef/resource/pacman_package.rb +1 -1
- data/lib/chef/resource/paludis_package.rb +1 -1
- data/lib/chef/resource/perl.rb +1 -1
- data/lib/chef/resource/plist.rb +1 -1
- data/lib/chef/resource/portage_package.rb +1 -1
- data/lib/chef/resource/powershell_package.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +1 -1
- data/lib/chef/resource/powershell_script.rb +1 -1
- data/lib/chef/resource/python.rb +1 -1
- data/lib/chef/resource/reboot.rb +1 -1
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/remote_directory.rb +1 -1
- data/lib/chef/resource/remote_file.rb +1 -2
- data/lib/chef/resource/rhsm_errata.rb +1 -3
- data/lib/chef/resource/rhsm_errata_level.rb +1 -1
- data/lib/chef/resource/rhsm_register.rb +1 -2
- data/lib/chef/resource/rhsm_repo.rb +1 -2
- data/lib/chef/resource/rhsm_subscription.rb +1 -3
- data/lib/chef/resource/route.rb +1 -1
- data/lib/chef/resource/rpm_package.rb +5 -2
- data/lib/chef/resource/ruby.rb +1 -1
- data/lib/chef/resource/ruby_block.rb +1 -4
- data/lib/chef/resource/scm/_scm.rb +4 -3
- data/lib/chef/resource/scm/git.rb +1 -1
- data/lib/chef/resource/scm/subversion.rb +2 -2
- data/lib/chef/resource/script.rb +1 -1
- data/lib/chef/resource/service.rb +1 -1
- data/lib/chef/resource/smartos_package.rb +1 -1
- data/lib/chef/resource/snap_package.rb +1 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
- data/lib/chef/resource/sudo.rb +4 -4
- data/lib/chef/resource/swap_file.rb +2 -2
- data/lib/chef/resource/sysctl.rb +61 -2
- data/lib/chef/resource/systemd_unit.rb +2 -2
- data/lib/chef/resource/timezone.rb +1 -1
- data/lib/chef/resource/user.rb +2 -2
- data/lib/chef/resource/user_ulimit.rb +24 -22
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_auto_run.rb +2 -2
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_dfs_folder.rb +1 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +1 -1
- data/lib/chef/resource/windows_dfs_server.rb +1 -1
- data/lib/chef/resource/windows_env.rb +10 -1
- data/lib/chef/resource/windows_feature.rb +57 -2
- data/lib/chef/resource/windows_feature_dism.rb +15 -2
- data/lib/chef/resource/windows_feature_powershell.rb +29 -2
- data/lib/chef/resource/windows_firewall_rule.rb +9 -5
- data/lib/chef/resource/windows_font.rb +10 -1
- data/lib/chef/resource/windows_package.rb +63 -3
- data/lib/chef/resource/windows_pagefile.rb +30 -2
- data/lib/chef/resource/windows_path.rb +18 -1
- data/lib/chef/resource/windows_printer.rb +25 -5
- data/lib/chef/resource/windows_printer_port.rb +29 -1
- data/lib/chef/resource/windows_security_policy.rb +1 -1
- data/lib/chef/resource/windows_service.rb +1 -1
- data/lib/chef/resource/windows_share.rb +21 -1
- data/lib/chef/resource/windows_shortcut.rb +13 -2
- data/lib/chef/resource/windows_task.rb +122 -8
- data/lib/chef/resource/windows_uac.rb +20 -1
- data/lib/chef/resource/windows_workgroup.rb +19 -3
- data/lib/chef/resource/yum_package.rb +88 -6
- data/lib/chef/resource/yum_repository.rb +28 -11
- data/lib/chef/resource/zypper_package.rb +29 -3
- data/lib/chef/resource/zypper_repository.rb +17 -5
- data/lib/chef/resource_inspector.rb +1 -1
- data/lib/chef/scan_access_control.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/link_spec.rb +3 -3
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +4 -4
- data/spec/integration/knife/redirection_spec.rb +2 -2
- data/spec/support/platform_helpers.rb +0 -13
- data/spec/support/shared/functional/http.rb +2 -2
- data/spec/support/shared/unit/mock_shellout.rb +1 -1
- data/spec/unit/file_access_control_spec.rb +1 -1
- data/spec/unit/mixin/shell_out_spec.rb +25 -31
- data/spec/unit/provider/apt_repository_spec.rb +27 -27
- data/spec/unit/provider/zypper_repository_spec.rb +17 -17
- data/spec/unit/provider_resolver_spec.rb +2 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abadb83dc708a6808d7914030f131699fcc00343ddb453c836b0c0ae12748689
|
4
|
+
data.tar.gz: b0fe5ae006d654435d0a5c71df6e1aa44007849ff473fa94d9bfa864a378b716
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24d18a8d55ec79197b0f332c9118c16df582a43c2fa7274cc8575ec2831830e0303ad33809aee5a08554775a32aa7ae5932781ce6548df8e54fc3cc0baebe6f4
|
7
|
+
data.tar.gz: 5ffedd46cdbcf844b732f70cff4313f4b6464fe5f42989db36612652faf3a2ecabcc191a7b2537fc78338d8999ae1cb3bb14ac66459372c4a45dcc89a893dc3a
|
data/Rakefile
CHANGED
@@ -17,6 +17,9 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
+
# we need this to resolve files required by lib/chef/dist
|
21
|
+
$LOAD_PATH.unshift(File.expand_path("../chef-config/lib", __FILE__))
|
22
|
+
|
20
23
|
begin
|
21
24
|
require_relative "tasks/rspec"
|
22
25
|
require_relative "tasks/dependencies"
|
@@ -27,26 +30,36 @@ rescue LoadError => e
|
|
27
30
|
puts "Skipping missing rake dep: #{e}"
|
28
31
|
end
|
29
32
|
|
33
|
+
require "bundler/gem_helper"
|
34
|
+
|
30
35
|
ENV["CHEF_LICENSE"] = "accept-no-persist"
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
namespace :pre_install do
|
38
|
+
desc "Runs 'rake install' for the gems that live in subdirectories in this repo"
|
39
|
+
task :install_gems_from_dirs do
|
40
|
+
%w{chef-utils chef-config}.each do |gem|
|
41
|
+
path = ::File.join(::File.dirname(__FILE__), gem)
|
42
|
+
Dir.chdir(path) do
|
43
|
+
sh("rake install")
|
44
|
+
end
|
45
|
+
end
|
38
46
|
end
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
desc "Renders the powershell extensions with distro flavoring"
|
49
|
+
task :render_powershell_extension do
|
50
|
+
template_file = ::File.join(::File.dirname(__FILE__), "distro", "templates", "powershell", "chef", "chef.psm1.erb")
|
51
|
+
psm1_path = ::File.join(::File.dirname(__FILE__), "distro", "powershell", "chef")
|
52
|
+
FileUtils.mkdir_p psm1_path
|
53
|
+
template = ERB.new(IO.read(template_file))
|
54
|
+
chef_psm1 = template.result
|
55
|
+
File.open(::File.join(psm1_path, "chef.psm1"), "w") { |f| f.write(chef_psm1) }
|
56
|
+
end
|
57
|
+
|
58
|
+
task all: ["pre_install:install_gems_from_dirs", "pre_install:render_powershell_extension"]
|
47
59
|
end
|
48
60
|
|
49
|
-
|
61
|
+
# hack in all the preinstall tasks to occur before the tradtional install task
|
62
|
+
task install: "pre_install:all"
|
50
63
|
|
51
64
|
# make sure we build the correct gemspec on windows
|
52
65
|
gemspec = Gem.win_platform? ? "chef-universal-mingw32" : "chef"
|
@@ -55,8 +68,9 @@ Bundler::GemHelper.install_tasks name: gemspec
|
|
55
68
|
# this gets appended to the normal bundler install helper
|
56
69
|
task :install do
|
57
70
|
chef_bin_path = ::File.join(::File.dirname(__FILE__), "chef-bin")
|
58
|
-
Dir.chdir(chef_bin_path)
|
59
|
-
|
71
|
+
Dir.chdir(chef_bin_path) do
|
72
|
+
sh("rake install:force")
|
73
|
+
end
|
60
74
|
end
|
61
75
|
|
62
76
|
task :pedant, :chef_zero_spec
|
data/chef.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
|
35
35
|
s.add_dependency "net-sftp", "~> 2.1", ">= 2.1.2"
|
36
36
|
s.add_dependency "ed25519", "~> 1.2" # ed25519 ssh key support
|
37
|
-
s.add_dependency "bcrypt_pbkdf", "
|
37
|
+
s.add_dependency "bcrypt_pbkdf", "= 1.1.0.rc1" # ed25519 ssh key support
|
38
38
|
s.add_dependency "highline", ">= 1.6.9", "< 3"
|
39
39
|
s.add_dependency "tty-screen", "~> 0.6" # knife list
|
40
40
|
s.add_dependency "pastel" # knife ui.color
|
@@ -81,7 +81,7 @@ class Chef
|
|
81
81
|
|
82
82
|
def constraint_list(environments)
|
83
83
|
constraints = {}
|
84
|
-
environments.each do |env, url| # rubocop:disable
|
84
|
+
environments.each do |env, url| # rubocop:disable Style/HashEachMethods
|
85
85
|
# Because you cannot modify the default environment I filter it out here.
|
86
86
|
unless env == "_default"
|
87
87
|
envdata = Chef::Environment.load(env)
|
data/lib/chef/knife/list.rb
CHANGED
@@ -90,7 +90,7 @@ class Chef
|
|
90
90
|
|
91
91
|
# Flatten out directory results if necessary
|
92
92
|
if config[:flat]
|
93
|
-
dir_results.each do |result, children| # rubocop:disable
|
93
|
+
dir_results.each do |result, children| # rubocop:disable Style/HashEachMethods
|
94
94
|
results += children
|
95
95
|
end
|
96
96
|
dir_results = []
|
@@ -96,7 +96,7 @@ class Chef
|
|
96
96
|
extract_cookbook(upstream_file, downloader.version)
|
97
97
|
|
98
98
|
# TODO: it'd be better to store these outside the cookbook repo and
|
99
|
-
# keep them around, e.g., in ~/Library/Caches on
|
99
|
+
# keep them around, e.g., in ~/Library/Caches on macOS.
|
100
100
|
ui.info("Removing downloaded tarball")
|
101
101
|
File.unlink(upstream_file)
|
102
102
|
|
@@ -56,7 +56,7 @@ class Chef::Knife::YamlConvert < Chef::Knife
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# Unfortunately, per the YAML spec, comments are stripped when we load, so we lose them on conversion
|
59
|
-
yaml_hash = ::YAML.safe_load(yaml_contents)
|
59
|
+
yaml_hash = ::YAML.safe_load(yaml_contents, permitted_classes: [Symbol])
|
60
60
|
unless yaml_hash.is_a?(Hash) && yaml_hash.key?("resources")
|
61
61
|
ui.fatal!("YAML recipe '#{source_file}' must contain a top-level 'resources' hash (YAML sequence), i.e. 'resources:'")
|
62
62
|
end
|
@@ -81,7 +81,7 @@ class Chef::Knife::YamlConvert < Chef::Knife
|
|
81
81
|
|
82
82
|
ruby_contents << "#{type} \"#{name}\" do"
|
83
83
|
r.each do |k, v|
|
84
|
-
ruby_contents << " #{k}
|
84
|
+
ruby_contents << " #{k} #{v.inspect}"
|
85
85
|
end
|
86
86
|
ruby_contents << "end\n"
|
87
87
|
end
|
@@ -49,7 +49,7 @@ class Chef
|
|
49
49
|
|
50
50
|
converge_by("execute #{description}") do
|
51
51
|
begin
|
52
|
-
shell_out!(command, opts)
|
52
|
+
shell_out!(command, **opts)
|
53
53
|
rescue Mixlib::ShellOut::ShellCommandFailed
|
54
54
|
if sensitive?
|
55
55
|
ex = Mixlib::ShellOut::ShellCommandFailed.new("Command execution failed. STDOUT/STDERR suppressed for sensitive resource")
|
@@ -58,7 +58,8 @@ class Chef
|
|
58
58
|
|
59
59
|
def makefile_variable_value(variable, dir = nil)
|
60
60
|
options = dir ? { cwd: dir } : {}
|
61
|
-
|
61
|
+
options.merge!(env: nil, returns: [0, 1])
|
62
|
+
make_v = shell_out!("make", "-V", variable, **options)
|
62
63
|
make_v.exitstatus == 0 ? make_v.stdout.strip.split($OUTPUT_RECORD_SEPARATOR).first : nil # $\ is the line separator, i.e. newline.
|
63
64
|
end
|
64
65
|
end
|
@@ -36,6 +36,13 @@ class Chef
|
|
36
36
|
require "chef/provider/package/windows/registry_uninstall_entry.rb"
|
37
37
|
|
38
38
|
def define_resource_requirements
|
39
|
+
if new_resource.checksum
|
40
|
+
requirements.assert(:install) do |a|
|
41
|
+
a.assertion { new_resource.checksum.downcase == checksum(source_location) }
|
42
|
+
a.failure_message Chef::Exceptions::Package, "Checksum on resource (#{short_cksum(new_resource.checksum)}) does not match checksum on content (#{short_cksum(source_location)})"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
39
46
|
requirements.assert(:install) do |a|
|
40
47
|
a.assertion { new_resource.source || msi? }
|
41
48
|
a.failure_message Chef::Exceptions::NoWindowsPackageSource, "Source for package #{new_resource.package_name} must be specified in the resource's source property for package to be installed because the package_name property is used to test for the package installation state for this package type."
|
@@ -50,27 +57,15 @@ class Chef
|
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
53
|
-
# load_current_resource is run in Chef::Provider#run_action when not in whyrun_mode?
|
54
60
|
def load_current_resource
|
55
|
-
|
56
|
-
|
57
|
-
logger.trace("We do not know the version of #{new_resource.source} because the file is not downloaded")
|
58
|
-
# FIXME: this label should not be used. It could be set to nil. Probably what should happen is that
|
59
|
-
# if the file hasn't been downloaded then load_current_resource must download the file here, and then
|
60
|
-
# the else clause to set current_resource.version can always be run. Relying on a side-effect here
|
61
|
-
# produces at least less readable code, if not outright buggy... (and I'm assuming that this isn't
|
62
|
-
# wholly just a bug -- since if we only need the package_name to determine if its installed then we
|
63
|
-
# need this, so I'm assuming we need to download the file to pull out the name in order to check
|
64
|
-
# the registry -- which it still feels like we get wrong in the sense we're forcing always downloading
|
65
|
-
# and then always installing(?) which violates idempotency -- and I'm having to think way too hard
|
66
|
-
# about this and would need to go surfing around the code to determine what actually happens, probably
|
67
|
-
# in every different package_provider...)
|
68
|
-
current_resource.version(:unknown.to_s)
|
69
|
-
else
|
70
|
-
current_resource.version(package_provider.installed_version)
|
71
|
-
new_resource.version(package_provider.package_version) if package_provider.package_version
|
61
|
+
if uri_scheme?(new_resource.source) && action == :install
|
62
|
+
download_source_file
|
72
63
|
end
|
73
64
|
|
65
|
+
@current_resource = Chef::Resource::WindowsPackage.new(new_resource.name)
|
66
|
+
current_resource.version(package_provider.installed_version)
|
67
|
+
new_resource.version(package_provider.package_version) if package_provider.package_version
|
68
|
+
|
74
69
|
current_resource
|
75
70
|
end
|
76
71
|
|
@@ -139,17 +134,6 @@ class Chef
|
|
139
134
|
end
|
140
135
|
end
|
141
136
|
|
142
|
-
action :install do
|
143
|
-
if uri_scheme?(new_resource.source)
|
144
|
-
download_source_file
|
145
|
-
load_current_resource
|
146
|
-
else
|
147
|
-
validate_content!
|
148
|
-
end
|
149
|
-
|
150
|
-
super
|
151
|
-
end
|
152
|
-
|
153
137
|
# Chef::Provider::Package action_install + action_remove call install_package + remove_package
|
154
138
|
# Pass those calls to the correct sub-provider
|
155
139
|
def install_package(name, version)
|
@@ -245,6 +229,7 @@ class Chef
|
|
245
229
|
end
|
246
230
|
|
247
231
|
def resource_for_provider
|
232
|
+
# XXX: this is crazy
|
248
233
|
@resource_for_provider = Chef::Resource::WindowsPackage.new(new_resource.name).tap do |r|
|
249
234
|
r.source(Chef::Util::PathHelper.validate_path(source_location)) unless source_location.nil?
|
250
235
|
r.cookbook_name = new_resource.cookbook_name
|
@@ -257,23 +242,22 @@ class Chef
|
|
257
242
|
end
|
258
243
|
|
259
244
|
def download_source_file
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
r.checksum(new_resource.checksum)
|
269
|
-
r.backup(false)
|
245
|
+
# It seems correct that this is a build_resource rather than declare_resource/DSL use since updating should not trigger a notification
|
246
|
+
# unless the downloaded file is actually installed. The case where the remote_file downloads the package but the package is already
|
247
|
+
# installed on the target should not trigger a notification since the running state did not change.
|
248
|
+
build_resource(:remote_file, default_download_cache_path) do
|
249
|
+
source(new_resource.source)
|
250
|
+
cookbook_name = new_resource.cookbook_name
|
251
|
+
checksum(new_resource.checksum)
|
252
|
+
backup(false)
|
270
253
|
|
271
254
|
if new_resource.remote_file_attributes
|
272
255
|
new_resource.remote_file_attributes.each do |(k, v)|
|
273
|
-
|
256
|
+
send(k.to_sym, v)
|
274
257
|
end
|
275
258
|
end
|
276
|
-
end
|
259
|
+
end.run_action(:create)
|
260
|
+
logger.trace("#{new_resource} fetched source file to #{default_download_cache_path}")
|
277
261
|
end
|
278
262
|
|
279
263
|
def default_download_cache_path
|
@@ -287,22 +271,13 @@ class Chef
|
|
287
271
|
if new_resource.source.nil?
|
288
272
|
nil
|
289
273
|
elsif uri_scheme?(new_resource.source)
|
290
|
-
|
274
|
+
default_download_cache_path
|
291
275
|
else
|
292
276
|
new_source = Chef::Util::PathHelper.cleanpath(new_resource.source)
|
293
277
|
::File.exist?(new_source) ? new_source : nil
|
294
278
|
end
|
295
279
|
end
|
296
280
|
|
297
|
-
def validate_content!
|
298
|
-
if new_resource.checksum
|
299
|
-
source_checksum = checksum(source_location)
|
300
|
-
if new_resource.checksum.downcase != source_checksum
|
301
|
-
raise Chef::Exceptions::ChecksumMismatch.new(short_cksum(new_resource.checksum), short_cksum(source_checksum))
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
281
|
def msi?
|
307
282
|
return true if new_resource.installer_type == :msi
|
308
283
|
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
class User
|
29
29
|
#
|
30
30
|
# The most tricky bit of this provider is the way it deals with user passwords.
|
31
|
-
#
|
31
|
+
# macOS has different password shadow calculations based on the version.
|
32
32
|
# < 10.7 => password shadow calculation format SALTED-SHA1
|
33
33
|
# => stored in: /var/db/shadow/hash/#{guid}
|
34
34
|
# => shadow binary length 68 bytes
|
@@ -28,11 +28,72 @@ class Chef
|
|
28
28
|
|
29
29
|
description "The alternatives resource allows for configuration of command alternatives in Linux using the alternatives or update-alternatives packages."
|
30
30
|
introduced "16.0"
|
31
|
+
examples <<~DOC
|
32
|
+
**Install an alternative**:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
alternatives 'python install 2' do
|
36
|
+
link_name 'python'
|
37
|
+
path '/usr/bin/python2.7'
|
38
|
+
priority 100
|
39
|
+
action :install
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
**Set an alternative**:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
alternatives 'python set version 3' do
|
47
|
+
link_name 'python'
|
48
|
+
path '/usr/bin/python3'
|
49
|
+
action :set
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
**Set the automatic alternative state**:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
alternatives 'python auto' do
|
57
|
+
link_name 'python'
|
58
|
+
action :auto
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
**Refresh an alternative**:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
alternatives 'python refresh' do
|
66
|
+
link_name 'python'
|
67
|
+
action :refresh
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
**Remove an alternative**:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
alternatives 'python remove' do
|
75
|
+
link_name 'python'
|
76
|
+
path '/usr/bin/python3'
|
77
|
+
action :remove
|
78
|
+
end
|
79
|
+
```
|
80
|
+
DOC
|
81
|
+
|
82
|
+
property :link_name, String,
|
83
|
+
name_property: true,
|
84
|
+
description: "The name of the link to create. This will be the command you type on the command line such as `ruby` or `gcc`."
|
85
|
+
|
86
|
+
property :link, String,
|
87
|
+
default: lazy { |n| "/usr/bin/#{n.link_name}" },
|
88
|
+
default_description: "/usr/bin/LINK_NAME",
|
89
|
+
description: "The path to the alternatives link."
|
90
|
+
|
91
|
+
property :path, String,
|
92
|
+
description: "The full path to the original application binary such as `/usr/bin/ruby27`."
|
31
93
|
|
32
|
-
property :
|
33
|
-
|
34
|
-
|
35
|
-
property :priority, [String, Integer], coerce: proc { |n| n.to_i }
|
94
|
+
property :priority, [String, Integer],
|
95
|
+
coerce: proc { |n| n.to_i },
|
96
|
+
description: "The priority of the alternative."
|
36
97
|
|
37
98
|
def define_resource_requirements
|
38
99
|
requirements.assert(:install) do |a|
|
@@ -25,11 +25,40 @@ class Chef
|
|
25
25
|
|
26
26
|
provides :apt_package, target_mode: true
|
27
27
|
provides :package, platform_family: "debian", target_mode: true
|
28
|
+
examples <<~DOC
|
29
|
+
**Install a package using package manager**:
|
28
30
|
|
29
|
-
|
31
|
+
```ruby
|
32
|
+
apt_package 'name of package' do
|
33
|
+
action :install
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
**Install a package without specifying the default action**:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
apt_package 'name of package'
|
41
|
+
```
|
42
|
+
|
43
|
+
**Install multiple packages at once**:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
apt_package %(package1 package2 package3)
|
47
|
+
```
|
48
|
+
|
49
|
+
**Install without using recommend packages as a dependency**
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
package 'apache2' do
|
53
|
+
options '--no-install-recommends'
|
54
|
+
end
|
55
|
+
```
|
56
|
+
DOC
|
57
|
+
|
58
|
+
description "Use the **apt_package** resource to manage packages on Debian and Ubuntu platforms."
|
30
59
|
|
31
60
|
property :default_release, String,
|
32
|
-
description: "The default release. For example: stable
|
61
|
+
description: "The default release. For example: `stable`.",
|
33
62
|
desired_state: false
|
34
63
|
|
35
64
|
property :overwrite_config_files, [TrueClass, FalseClass],
|
@@ -20,14 +20,43 @@ require_relative "../resource"
|
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
|
-
# @since 13.3
|
24
23
|
class AptPreference < Chef::Resource
|
25
24
|
unified_mode true
|
26
25
|
|
27
26
|
provides(:apt_preference) { true }
|
28
27
|
|
29
|
-
description "
|
28
|
+
description "Use the **apt_preference** resource to create APT [preference files](https://wiki.debian.org/AptPreferences). Preference files are used to control which package versions and sources are prioritized during installation."
|
30
29
|
introduced "13.3"
|
30
|
+
examples <<~DOC
|
31
|
+
**Pin libmysqlclient16 to a version 5.1.49-3**:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
apt_preference 'libmysqlclient16' do
|
35
|
+
pin 'version 5.1.49-3'
|
36
|
+
pin_priority '700'
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
Note: The `pin_priority` of `700` ensures that this version will be preferred over any other available versions.
|
41
|
+
|
42
|
+
**Unpin a libmysqlclient16**:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
apt_preference 'libmysqlclient16' do
|
46
|
+
action :remove
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
**Pin all packages to prefer the packages.dotdeb.org repository**:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
apt_preference 'dotdeb' do
|
54
|
+
glob '*'
|
55
|
+
pin 'origin packages.dotdeb.org'
|
56
|
+
pin_priority '700'
|
57
|
+
end
|
58
|
+
```
|
59
|
+
DOC
|
31
60
|
|
32
61
|
property :package_name, String,
|
33
62
|
name_property: true,
|
@@ -36,15 +65,15 @@ class Chef
|
|
36
65
|
validation_message: "The provided package name is not valid. Package names can only contain alphanumeric characters as well as _, -, +, or *!"
|
37
66
|
|
38
67
|
property :glob, String,
|
39
|
-
description: "Pin by glob() expression or with regular
|
68
|
+
description: "Pin by a `glob()` expression or with a regular expression surrounded by `/`."
|
40
69
|
|
41
70
|
property :pin, String,
|
42
71
|
description: "The package version or repository to pin.",
|
43
|
-
required:
|
72
|
+
required: [:add]
|
44
73
|
|
45
74
|
property :pin_priority, [String, Integer],
|
46
75
|
description: "Sets the Pin-Priority for a package. See <https://wiki.debian.org/AptPreferences> for more details.",
|
47
|
-
required:
|
76
|
+
required: [:add]
|
48
77
|
|
49
78
|
default_action :add
|
50
79
|
allowed_actions :add, :remove
|