chef 18.5.0 → 18.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -3
- data/chef-universal-mingw-ucrt.gemspec +1 -1
- data/chef.gemspec +2 -2
- data/lib/chef/application/client.rb +0 -12
- data/lib/chef/client.rb +1 -10
- data/lib/chef/compliance/runner.rb +0 -10
- data/lib/chef/cookbook/remote_file_vendor.rb +3 -2
- data/lib/chef/cookbook/synchronizer.rb +0 -5
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_access_control/unix.rb +9 -9
- data/lib/chef/file_content_management/deploy.rb +1 -4
- data/lib/chef/mixin/file_class.rb +1 -3
- data/lib/chef/mixin/get_source_from_package.rb +1 -1
- data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
- data/lib/chef/mixin/openssl_helper.rb +1 -12
- data/lib/chef/provider/cookbook_file.rb +1 -1
- data/lib/chef/provider/cron.rb +1 -1
- data/lib/chef/provider/directory.rb +15 -15
- data/lib/chef/provider/file.rb +29 -42
- data/lib/chef/provider/git.rb +8 -8
- data/lib/chef/provider/group/aix.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/group/gpasswd.rb +2 -2
- data/lib/chef/provider/group/groupadd.rb +1 -1
- data/lib/chef/provider/group/groupmod.rb +2 -2
- data/lib/chef/provider/group/pw.rb +2 -2
- data/lib/chef/provider/group/solaris.rb +2 -2
- data/lib/chef/provider/group/usermod.rb +2 -2
- data/lib/chef/provider/group.rb +1 -1
- data/lib/chef/provider/http_request.rb +3 -2
- data/lib/chef/provider/ifconfig/aix.rb +1 -1
- data/lib/chef/provider/ifconfig/debian.rb +3 -3
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +1 -1
- data/lib/chef/provider/link.rb +10 -10
- data/lib/chef/provider/mount/aix.rb +4 -4
- data/lib/chef/provider/mount/linux.rb +4 -4
- data/lib/chef/provider/mount/mount.rb +11 -11
- data/lib/chef/provider/package/apt.rb +11 -2
- data/lib/chef/provider/package/bff.rb +3 -3
- data/lib/chef/provider/package/chocolatey.rb +2 -2
- data/lib/chef/provider/package/dpkg.rb +3 -3
- data/lib/chef/provider/package/freebsd/base.rb +1 -1
- data/lib/chef/provider/package/habitat.rb +3 -5
- data/lib/chef/provider/package/homebrew.rb +6 -9
- data/lib/chef/provider/package/ips.rb +2 -2
- data/lib/chef/provider/package/openbsd.rb +2 -3
- data/lib/chef/provider/package/pacman.rb +4 -4
- data/lib/chef/provider/package/paludis.rb +2 -2
- data/lib/chef/provider/package/portage.rb +1 -1
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +4 -0
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/package/snap.rb +1 -1
- data/lib/chef/provider/package/solaris.rb +4 -4
- data/lib/chef/provider/package/zypper.rb +4 -4
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +5 -5
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/remote_file.rb +1 -1
- data/lib/chef/provider/route.rb +9 -9
- data/lib/chef/provider/service/aix.rb +1 -1
- data/lib/chef/provider/service/aixinit.rb +4 -4
- data/lib/chef/provider/service/arch.rb +6 -6
- data/lib/chef/provider/service/debian.rb +5 -5
- data/lib/chef/provider/service/freebsd.rb +7 -7
- data/lib/chef/provider/service/gentoo.rb +5 -5
- data/lib/chef/provider/service/init.rb +2 -2
- data/lib/chef/provider/service/insserv.rb +2 -2
- data/lib/chef/provider/service/invokercd.rb +1 -1
- data/lib/chef/provider/service/openbsd.rb +7 -7
- data/lib/chef/provider/service/redhat.rb +3 -3
- data/lib/chef/provider/service/solaris.rb +2 -2
- data/lib/chef/provider/service/systemd.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +2 -2
- data/lib/chef/provider/subversion.rb +8 -8
- data/lib/chef/provider/systemd_unit.rb +3 -3
- data/lib/chef/provider/template.rb +1 -1
- data/lib/chef/provider/user/aix.rb +3 -3
- data/lib/chef/provider/user/linux.rb +2 -7
- data/lib/chef/provider/user/pw.rb +3 -3
- data/lib/chef/provider/user/solaris.rb +7 -7
- data/lib/chef/provider/user/windows.rb +5 -0
- data/lib/chef/provider/user.rb +8 -7
- data/lib/chef/provider/yum_repository.rb +3 -1
- data/lib/chef/provider/zypper_repository.rb +1 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource/alternatives.rb +2 -2
- data/lib/chef/resource/apt_preference.rb +1 -1
- data/lib/chef/resource/apt_repository.rb +9 -7
- data/lib/chef/resource/apt_update.rb +3 -3
- data/lib/chef/resource/bff_package.rb +1 -1
- data/lib/chef/resource/chef_client_config.rb +3 -2
- data/lib/chef/resource/chef_sleep.rb +1 -1
- data/lib/chef/resource/cookbook_file.rb +1 -1
- data/lib/chef/resource/cron/cron.rb +1 -1
- data/lib/chef/resource/cron/cron_d.rb +1 -1
- data/lib/chef/resource/cron_access.rb +1 -1
- data/lib/chef/resource/directory.rb +1 -1
- data/lib/chef/resource/dpkg_package.rb +1 -1
- data/lib/chef/resource/file/verification/json.rb +1 -1
- data/lib/chef/resource/file/verification/systemd_unit.rb +1 -1
- data/lib/chef/resource/file/verification/yaml.rb +1 -1
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/freebsd_package.rb +2 -2
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/habitat/habitat_package.rb +1 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +9 -9
- data/lib/chef/resource/habitat/habitat_sup_systemd.rb +2 -2
- data/lib/chef/resource/habitat_install.rb +3 -3
- data/lib/chef/resource/homebrew_cask.rb +19 -30
- data/lib/chef/resource/homebrew_tap.rb +32 -17
- data/lib/chef/resource/homebrew_update.rb +4 -4
- data/lib/chef/resource/hostname.rb +10 -11
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/ifconfig.rb +1 -1
- data/lib/chef/resource/inspec_input.rb +1 -3
- data/lib/chef/resource/inspec_waiver.rb +1 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
- data/lib/chef/resource/ips_package.rb +2 -2
- data/lib/chef/resource/kernel_module.rb +2 -2
- data/lib/chef/resource/link.rb +1 -1
- data/lib/chef/resource/locale.rb +2 -2
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/notify_group.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 +2 -2
- 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/portage_package.rb +1 -1
- data/lib/chef/resource/reboot.rb +1 -1
- data/lib/chef/resource/remote_directory.rb +1 -1
- data/lib/chef/resource/remote_file.rb +1 -1
- data/lib/chef/resource/rhsm_errata.rb +1 -1
- data/lib/chef/resource/rhsm_errata_level.rb +1 -1
- data/lib/chef/resource/rhsm_register.rb +1 -1
- data/lib/chef/resource/rhsm_repo.rb +4 -3
- data/lib/chef/resource/rhsm_subscription.rb +9 -8
- data/lib/chef/resource/route.rb +1 -1
- data/lib/chef/resource/rpm_package.rb +1 -1
- data/lib/chef/resource/scm/git.rb +1 -1
- data/lib/chef/resource/scm/subversion.rb +1 -1
- data/lib/chef/resource/selinux/common_helpers.rb +1 -1
- data/lib/chef/resource/selinux_boolean.rb +1 -1
- data/lib/chef/resource/selinux_fcontext.rb +3 -3
- data/lib/chef/resource/selinux_install.rb +1 -1
- data/lib/chef/resource/selinux_login.rb +1 -1
- data/lib/chef/resource/selinux_module.rb +5 -5
- data/lib/chef/resource/selinux_permissive.rb +2 -2
- data/lib/chef/resource/selinux_port.rb +2 -2
- data/lib/chef/resource/selinux_state.rb +2 -2
- data/lib/chef/resource/selinux_user.rb +1 -1
- data/lib/chef/resource/smartos_package.rb +2 -2
- 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 +5 -5
- data/lib/chef/resource/support/client.erb +3 -2
- data/lib/chef/resource/swap_file.rb +6 -6
- data/lib/chef/resource/sysctl.rb +5 -5
- data/lib/chef/resource/systemd_unit.rb +1 -1
- data/lib/chef/resource/template.rb +1 -1
- data/lib/chef/resource/timezone.rb +5 -5
- data/lib/chef/resource/user/aix_user.rb +2 -2
- data/lib/chef/resource/user/linux_user.rb +2 -2
- data/lib/chef/resource/user/pw_user.rb +2 -2
- data/lib/chef/resource/user/solaris_user.rb +2 -2
- data/lib/chef/resource/user_ulimit.rb +1 -1
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource/zypper_package.rb +2 -2
- data/lib/chef/resource/zypper_repository.rb +2 -2
- data/lib/chef/resource_inspector.rb +25 -7
- data/lib/chef/run_lock.rb +0 -3
- data/lib/chef/scan_access_control.rb +6 -6
- data/lib/chef/util/backup.rb +1 -1
- data/lib/chef/util/diff.rb +1 -14
- data/lib/chef/util/file_edit.rb +4 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/registry.rb +5 -0
- data/lib/chef/win32/security.rb +9 -0
- data/lib/chef.rb +0 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/integration/client/open_ssl_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/platform_helpers.rb +8 -0
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/unit/mixin/homebrew_spec.rb +118 -0
- data/spec/unit/provider/apt_repository_spec.rb +1 -1
- data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
- data/spec/unit/provider/package/homebrew_spec.rb +4 -1
- data/spec/unit/provider/route_spec.rb +4 -6
- data/spec/unit/provider/user/windows_spec.rb +1 -0
- data/spec/unit/resource/rhsm_repo_spec.rb +0 -1
- data/spec/unit/resource/rhsm_subscription_spec.rb +0 -2
- data/spec/unit/resource_inspector_spec.rb +36 -0
- metadata +20 -28
- data/lib/chef/file_content_management/deploy/target_io.rb +0 -29
- data/lib/chef/provider/.gitkeep +0 -0
- data/lib/chef/provider/package/snap_tm.rb +0 -79
- data/lib/chef/resource/.gitkeep +0 -0
- data/lib/chef/target_io/dir.rb +0 -12
- data/lib/chef/target_io/etc.rb +0 -16
- data/lib/chef/target_io/file.rb +0 -12
- data/lib/chef/target_io/fileutils.rb +0 -12
- data/lib/chef/target_io/http.rb +0 -22
- data/lib/chef/target_io/io.rb +0 -12
- data/lib/chef/target_io/shadow.rb +0 -44
- data/lib/chef/target_io/train/dir.rb +0 -69
- data/lib/chef/target_io/train/etc.rb +0 -112
- data/lib/chef/target_io/train/file.rb +0 -219
- data/lib/chef/target_io/train/fileutils.rb +0 -220
- data/lib/chef/target_io/train/http.rb +0 -117
- data/lib/chef/target_io/train/io.rb +0 -13
- data/lib/chef/target_io/train/shadow.rb +0 -52
- data/lib/chef/target_io/train_compat.rb +0 -7
- data/lib/chef/target_io.rb +0 -9
- data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
|
@@ -22,8 +22,8 @@ class Chef
|
|
|
22
22
|
class Resource
|
|
23
23
|
class SmartosPackage < Chef::Resource::Package
|
|
24
24
|
|
|
25
|
-
provides :smartos_package
|
|
26
|
-
provides :package, platform_family: "smartos"
|
|
25
|
+
provides :smartos_package
|
|
26
|
+
provides :package, platform_family: "smartos"
|
|
27
27
|
|
|
28
28
|
description "Use the **smartos_package** resource to manage packages for the SmartOS platform."
|
|
29
29
|
|
|
@@ -22,7 +22,7 @@ class Chef
|
|
|
22
22
|
class Resource
|
|
23
23
|
class SnapPackage < Chef::Resource::Package
|
|
24
24
|
|
|
25
|
-
provides :snap_package
|
|
25
|
+
provides :snap_package
|
|
26
26
|
|
|
27
27
|
description "Use the **snap_package** resource to manage snap packages on Debian and Ubuntu platforms."
|
|
28
28
|
introduced "15.0"
|
|
@@ -23,7 +23,7 @@ class Chef
|
|
|
23
23
|
class Resource
|
|
24
24
|
class SolarisPackage < Chef::Resource::Package
|
|
25
25
|
|
|
26
|
-
provides :solaris_package
|
|
26
|
+
provides :solaris_package
|
|
27
27
|
|
|
28
28
|
description "Use the **solaris_package** resource to manage packages on the Solaris platform."
|
|
29
29
|
|
|
@@ -24,7 +24,7 @@ class Chef
|
|
|
24
24
|
class Resource
|
|
25
25
|
class SshKnownHostsEntry < Chef::Resource
|
|
26
26
|
|
|
27
|
-
provides :ssh_known_hosts_entry
|
|
27
|
+
provides :ssh_known_hosts_entry
|
|
28
28
|
|
|
29
29
|
description "Use the **ssh_known_hosts_entry** resource to add an entry for the specified host in /etc/ssh/ssh_known_hosts or a user's known hosts file if specified."
|
|
30
30
|
introduced "14.3"
|
data/lib/chef/resource/sudo.rb
CHANGED
|
@@ -25,7 +25,7 @@ class Chef
|
|
|
25
25
|
class Resource
|
|
26
26
|
class Sudo < Chef::Resource
|
|
27
27
|
|
|
28
|
-
provides(:sudo
|
|
28
|
+
provides(:sudo) { true }
|
|
29
29
|
|
|
30
30
|
description "Use the **sudo** resource to add or remove individual sudo entries using sudoers.d files."\
|
|
31
31
|
" Sudo version 1.7.2 or newer is required to use the sudo resource, as it relies on the"\
|
|
@@ -216,11 +216,11 @@ class Chef
|
|
|
216
216
|
target = "#{new_resource.config_prefix}/sudoers.d/"
|
|
217
217
|
directory(target)
|
|
218
218
|
|
|
219
|
-
Chef::Log.warn("#{new_resource.filename} will be rendered, but will not take effect because the #{new_resource.config_prefix}/sudoers config lacks the includedir directive that loads configs from #{new_resource.config_prefix}/sudoers.d/!") if ::
|
|
219
|
+
Chef::Log.warn("#{new_resource.filename} will be rendered, but will not take effect because the #{new_resource.config_prefix}/sudoers config lacks the includedir directive that loads configs from #{new_resource.config_prefix}/sudoers.d/!") if ::File.readlines("#{new_resource.config_prefix}/sudoers").grep(/includedir/).empty?
|
|
220
220
|
file_path = "#{target}#{new_resource.filename}"
|
|
221
221
|
|
|
222
222
|
if new_resource.template
|
|
223
|
-
|
|
223
|
+
logger.trace("Template property provided, all other properties ignored.")
|
|
224
224
|
|
|
225
225
|
template file_path do
|
|
226
226
|
source new_resource.template
|
|
@@ -279,13 +279,13 @@ class Chef
|
|
|
279
279
|
end
|
|
280
280
|
|
|
281
281
|
def visudo_present?
|
|
282
|
-
return true if ::
|
|
282
|
+
return true if ::File.exist?(new_resource.visudo_binary)
|
|
283
283
|
|
|
284
284
|
Chef::Log.warn("The visudo binary cannot be found at '#{new_resource.visudo_binary}'. Skipping sudoer file validation. If visudo is on this system you can specify the path using the 'visudo_binary' property.")
|
|
285
285
|
end
|
|
286
286
|
|
|
287
287
|
def visudo_content(path)
|
|
288
|
-
if ::
|
|
288
|
+
if ::File.exist?(path)
|
|
289
289
|
"cat #{new_resource.config_prefix}/sudoers | #{new_resource.visudo_binary} -cf - && #{new_resource.visudo_binary} -cf %{path}"
|
|
290
290
|
else
|
|
291
291
|
"cat #{new_resource.config_prefix}/sudoers %{path} | #{new_resource.visudo_binary} -cf -"
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
@policy_group
|
|
17
17
|
@policy_name
|
|
18
18
|
@rubygems_url
|
|
19
|
-
@ssl_verify_mode
|
|
20
|
-
@policy_persist_run_list).each do |prop| -%>
|
|
19
|
+
@ssl_verify_mode).each do |prop| -%>
|
|
21
20
|
<% next if instance_variable_get(prop).nil? || instance_variable_get(prop).empty? -%>
|
|
22
21
|
<%=prop.delete_prefix("@") %> <%= instance_variable_get(prop).inspect %>
|
|
23
22
|
<% end -%>
|
|
23
|
+
<%# boolean properties are neither .nil? nor respond to .empty? so they are included below %>
|
|
24
24
|
minimal_ohai <%= @minimal_ohai.inspect %>
|
|
25
|
+
policy_persist_run_list <%= @policy_persist_run_list.inspect %>
|
|
25
26
|
<%# ohai_disabled_plugins and ohai_optional_plugins properties don't match the config value perfectly-%>
|
|
26
27
|
<% %w(@ohai_disabled_plugins
|
|
27
28
|
@ohai_optional_plugins).each do |prop| -%>
|
|
@@ -21,7 +21,7 @@ class Chef
|
|
|
21
21
|
class Resource
|
|
22
22
|
class SwapFile < Chef::Resource
|
|
23
23
|
|
|
24
|
-
provides(:swap_file
|
|
24
|
+
provides(:swap_file) { true }
|
|
25
25
|
|
|
26
26
|
description "Use the **swap_file** resource to create or delete swap files on Linux systems, and optionally to manage the swappiness configuration for a host."
|
|
27
27
|
introduced "14.0"
|
|
@@ -84,7 +84,7 @@ class Chef
|
|
|
84
84
|
|
|
85
85
|
action :remove, description: "Remove a swapfile and disable swap." do
|
|
86
86
|
swapoff if swap_enabled?
|
|
87
|
-
remove_swapfile if ::
|
|
87
|
+
remove_swapfile if ::File.exist?(new_resource.path)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
action_class do
|
|
@@ -129,7 +129,7 @@ class Chef
|
|
|
129
129
|
|
|
130
130
|
def remove_swapfile
|
|
131
131
|
converge_by "remove swap file #{new_resource.path}" do
|
|
132
|
-
::
|
|
132
|
+
::FileUtils.rm(new_resource.path)
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
|
|
@@ -186,7 +186,7 @@ class Chef
|
|
|
186
186
|
def compatible_kernel
|
|
187
187
|
fallocate_location = shell_out("which fallocate").stdout
|
|
188
188
|
Chef::Log.debug("#{new_resource} fallocate location is '#{fallocate_location}'")
|
|
189
|
-
::
|
|
189
|
+
::File.exist?(fallocate_location.chomp)
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
def compatible_filesystem?
|
|
@@ -205,7 +205,7 @@ class Chef
|
|
|
205
205
|
|
|
206
206
|
def persist
|
|
207
207
|
fstab = "/etc/fstab"
|
|
208
|
-
contents = ::
|
|
208
|
+
contents = ::File.readlines(fstab)
|
|
209
209
|
addition = "#{new_resource.path} swap swap defaults 0 0"
|
|
210
210
|
|
|
211
211
|
if contents.any? { |line| line.strip == addition }
|
|
@@ -214,7 +214,7 @@ class Chef
|
|
|
214
214
|
Chef::Log.info("#{new_resource} adding entry to #{fstab} for #{new_resource.path}")
|
|
215
215
|
|
|
216
216
|
contents << "#{addition}\n"
|
|
217
|
-
::
|
|
217
|
+
::File.open(fstab, "w") { |f| f.write(contents.join("")) }
|
|
218
218
|
end
|
|
219
219
|
end
|
|
220
220
|
end
|
data/lib/chef/resource/sysctl.rb
CHANGED
|
@@ -21,8 +21,8 @@ class Chef
|
|
|
21
21
|
class Resource
|
|
22
22
|
class Sysctl < Chef::Resource
|
|
23
23
|
|
|
24
|
-
provides(:sysctl
|
|
25
|
-
provides(:sysctl_param
|
|
24
|
+
provides(:sysctl) { true }
|
|
25
|
+
provides(:sysctl_param) { true }
|
|
26
26
|
|
|
27
27
|
description "Use the **sysctl** resource to set or remove kernel parameters using the `sysctl` command line tool and configuration files in the system's `sysctl.d` directory. Configuration files managed by this resource are named `99-chef-KEYNAME.conf`."
|
|
28
28
|
examples <<~DOC
|
|
@@ -152,7 +152,7 @@ class Chef
|
|
|
152
152
|
|
|
153
153
|
action :remove, description: "Remove the kernel parameter and update the `sysctl` settings." do
|
|
154
154
|
# only converge the resource if the file actually exists to delete
|
|
155
|
-
if ::
|
|
155
|
+
if ::File.exist?("#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr("/", ".")}.conf")
|
|
156
156
|
converge_by "removing sysctl config at #{new_resource.conf_dir}/99-chef-#{new_resource.key.tr("/", ".")}.conf" do
|
|
157
157
|
file "#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr("/", ".")}.conf" do
|
|
158
158
|
action :delete
|
|
@@ -216,9 +216,9 @@ class Chef
|
|
|
216
216
|
# return the value. Raise in case this conf file needs to be created
|
|
217
217
|
# or updated
|
|
218
218
|
def get_sysctld_value(key)
|
|
219
|
-
raise unless ::
|
|
219
|
+
raise unless ::File.exist?("/etc/sysctl.d/99-chef-#{key.tr("/", ".")}.conf")
|
|
220
220
|
|
|
221
|
-
k, v = ::
|
|
221
|
+
k, v = ::File.read("/etc/sysctl.d/99-chef-#{key.tr("/", ".")}.conf").match(/(.*) = (.*)/).captures
|
|
222
222
|
raise "Unknown sysctl key!" if k.nil?
|
|
223
223
|
raise "Unknown sysctl value!" if v.nil?
|
|
224
224
|
|
|
@@ -24,7 +24,7 @@ class Chef
|
|
|
24
24
|
class Resource
|
|
25
25
|
class SystemdUnit < Chef::Resource
|
|
26
26
|
|
|
27
|
-
provides(:systemd_unit
|
|
27
|
+
provides(:systemd_unit) { true }
|
|
28
28
|
|
|
29
29
|
description "Use the **systemd_unit** resource to create, manage, and run [systemd units](https://www.freedesktop.org/software/systemd/man/systemd.html#Concepts)."
|
|
30
30
|
introduced "12.11"
|
|
@@ -23,7 +23,7 @@ class Chef
|
|
|
23
23
|
class Resource
|
|
24
24
|
class Timezone < Chef::Resource
|
|
25
25
|
|
|
26
|
-
provides :timezone
|
|
26
|
+
provides :timezone
|
|
27
27
|
|
|
28
28
|
description "Use the **timezone** resource to change the system timezone on Windows, Linux, and macOS hosts. Timezones are specified in tz database format, with a complete list of available TZ values for Linux and macOS here: <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>. On Windows systems run `tzutil /l` for a complete list of valid timezones."
|
|
29
29
|
introduced "14.6"
|
|
@@ -96,10 +96,10 @@ class Chef
|
|
|
96
96
|
# @since 16.5
|
|
97
97
|
# @return [String] timezone id
|
|
98
98
|
def current_rhel_tz
|
|
99
|
-
return nil unless ::
|
|
99
|
+
return nil unless ::File.exist?("/etc/sysconfig/clock")
|
|
100
100
|
|
|
101
101
|
# https://rubular.com/r/aoj01L3bKBM7wh
|
|
102
|
-
/ZONE="(.*)"/.match(::
|
|
102
|
+
/ZONE="(.*)"/.match(::File.read("/etc/sysconfig/clock"))[1]
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
load_current_value do
|
|
@@ -155,13 +155,13 @@ class Chef
|
|
|
155
155
|
execute "tzdata-update" do
|
|
156
156
|
command "/usr/sbin/tzdata-update"
|
|
157
157
|
action :nothing
|
|
158
|
-
only_if { ::
|
|
158
|
+
only_if { ::File.executable?("/usr/sbin/tzdata-update") }
|
|
159
159
|
subscribes :run, "file[/etc/sysconfig/clock]", :immediately
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
link "/etc/localtime" do
|
|
163
163
|
to "/usr/share/zoneinfo/#{new_resource.timezone}"
|
|
164
|
-
not_if { ::
|
|
164
|
+
not_if { ::File.executable?("/usr/sbin/tzdata-update") }
|
|
165
165
|
end
|
|
166
166
|
when "mac_os_x"
|
|
167
167
|
shell_out!(["sudo", "systemsetup", "-settimezone", new_resource.timezone])
|
|
@@ -22,8 +22,8 @@ class Chef
|
|
|
22
22
|
class User
|
|
23
23
|
class SolarisUser < Chef::Resource::User
|
|
24
24
|
|
|
25
|
-
provides :solaris_user
|
|
26
|
-
provides :user, os: %w{omnios solaris2}
|
|
25
|
+
provides :solaris_user
|
|
26
|
+
provides :user, os: %w{omnios solaris2}
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -23,7 +23,7 @@ class Chef
|
|
|
23
23
|
class Resource
|
|
24
24
|
class UserUlimit < Chef::Resource
|
|
25
25
|
|
|
26
|
-
provides :user_ulimit
|
|
26
|
+
provides :user_ulimit
|
|
27
27
|
|
|
28
28
|
description "Use the **user_ulimit** resource to create individual ulimit files that are installed into the `/etc/security/limits.d/` directory."
|
|
29
29
|
introduced "16.0"
|
|
@@ -22,7 +22,7 @@ class Chef
|
|
|
22
22
|
class Resource
|
|
23
23
|
class YumRepository < Chef::Resource
|
|
24
24
|
|
|
25
|
-
provides(:yum_repository
|
|
25
|
+
provides(:yum_repository) { true }
|
|
26
26
|
|
|
27
27
|
description "Use the **yum_repository** resource to manage a Yum repository configuration file located at `/etc/yum.repos.d/repositoryid.repo` on the local machine. This configuration file specifies which repositories to reference, how to handle cached data, etc."
|
|
28
28
|
introduced "12.14"
|
|
@@ -22,8 +22,8 @@ class Chef
|
|
|
22
22
|
class Resource
|
|
23
23
|
class ZypperPackage < Chef::Resource::Package
|
|
24
24
|
|
|
25
|
-
provides :zypper_package
|
|
26
|
-
provides :package, platform_family: "suse"
|
|
25
|
+
provides :zypper_package
|
|
26
|
+
provides :package, platform_family: "suse"
|
|
27
27
|
|
|
28
28
|
description "Use the **zypper_package** resource to install, upgrade, and remove packages with Zypper for the SUSE Enterprise and openSUSE platforms."
|
|
29
29
|
examples <<~DOC
|
|
@@ -22,8 +22,8 @@ class Chef
|
|
|
22
22
|
class Resource
|
|
23
23
|
class ZypperRepository < Chef::Resource
|
|
24
24
|
|
|
25
|
-
provides(:zypper_repository
|
|
26
|
-
provides(:zypper_repo
|
|
25
|
+
provides(:zypper_repository) { true }
|
|
26
|
+
provides(:zypper_repo) { true } # legacy cookbook compatibility
|
|
27
27
|
|
|
28
28
|
description "Use the **zypper_repository** resource to create Zypper package repositories on SUSE Enterprise Linux and openSUSE systems. This resource maintains full compatibility with the **zypper_repository** resource in the existing **zypper** cookbook."
|
|
29
29
|
introduced "13.3"
|
|
@@ -79,19 +79,37 @@ class Chef
|
|
|
79
79
|
Array(equal_to).map(&:inspect)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
def self.load_from_resources(resources, complete)
|
|
83
|
+
resources.each_with_object({}) do |r, res|
|
|
84
|
+
pth = r["full_path"]
|
|
85
|
+
# Here we do some magic to extract resources from files where there are multiple resources
|
|
86
|
+
# in a file - to do this, we load the file, and take the delta of which resources
|
|
87
|
+
# exist in object space
|
|
88
|
+
existing_classes = []
|
|
89
|
+
ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each { |klass| existing_classes << klass }
|
|
90
|
+
# Load the set of resources from this file
|
|
91
|
+
Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
|
|
92
|
+
# Finally, process every new class added to the object space by that
|
|
93
|
+
ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each do |klass|
|
|
94
|
+
unless existing_classes.include?(klass)
|
|
95
|
+
# Skip over anything which creates resources that start with exactly this - that happens
|
|
96
|
+
# because if there is no non-classed resource in here, LWRPBase.build_from_file builds a
|
|
97
|
+
# dummy object from it - we don't need that polluting out output!
|
|
98
|
+
next if klass.resource_name.start_with?("Chef__ResourceInspector")
|
|
99
|
+
|
|
100
|
+
res[klass.resource_name] = extract_resource(klass, complete)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
82
106
|
def self.extract_cookbook(path, complete)
|
|
83
107
|
path = File.expand_path(path)
|
|
84
108
|
dir, name = File.split(path)
|
|
85
109
|
Chef::Cookbook::FileVendor.fetch_from_disk(path)
|
|
86
110
|
loader = Chef::CookbookLoader.new(dir)
|
|
87
111
|
cookbook = loader.load_cookbook(name)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
resources.each_with_object({}) do |r, res|
|
|
91
|
-
pth = r["full_path"]
|
|
92
|
-
cur = Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
|
|
93
|
-
res[cur.resource_name] = extract_resource(cur, complete)
|
|
94
|
-
end
|
|
112
|
+
load_from_resources(cookbook.files_for(:resources), complete)
|
|
95
113
|
end
|
|
96
114
|
|
|
97
115
|
# If we're given no resources, dump all of Chef's built ins
|
data/lib/chef/run_lock.rb
CHANGED
|
@@ -46,7 +46,7 @@ class Chef
|
|
|
46
46
|
|
|
47
47
|
# Modifies @current_resource, setting the current access control state.
|
|
48
48
|
def set_all!
|
|
49
|
-
if ::
|
|
49
|
+
if ::File.exist?(new_resource.path)
|
|
50
50
|
set_owner
|
|
51
51
|
set_group
|
|
52
52
|
set_mode
|
|
@@ -76,7 +76,7 @@ class Chef
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def lookup_uid
|
|
79
|
-
unless (pwent =
|
|
79
|
+
unless (pwent = Etc.getpwuid(stat.uid)).nil?
|
|
80
80
|
pwent.name
|
|
81
81
|
else
|
|
82
82
|
stat.uid
|
|
@@ -103,7 +103,7 @@ class Chef
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def lookup_gid
|
|
106
|
-
unless (pwent =
|
|
106
|
+
unless (pwent = Etc.getgrgid(stat.gid)).nil?
|
|
107
107
|
pwent.name
|
|
108
108
|
else
|
|
109
109
|
stat.gid
|
|
@@ -128,10 +128,10 @@ class Chef
|
|
|
128
128
|
|
|
129
129
|
def stat
|
|
130
130
|
@stat ||= if @new_resource.instance_of?(Chef::Resource::Link)
|
|
131
|
-
::
|
|
131
|
+
::File.lstat(@new_resource.path)
|
|
132
132
|
else
|
|
133
|
-
realpath = ::
|
|
134
|
-
::
|
|
133
|
+
realpath = ::File.realpath(@new_resource.path)
|
|
134
|
+
::File.stat(realpath)
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
end
|
data/lib/chef/util/backup.rb
CHANGED
|
@@ -30,7 +30,7 @@ class Chef
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def backup!
|
|
33
|
-
if @new_resource.backup != false && @new_resource.backup > 0 && ::
|
|
33
|
+
if @new_resource.backup != false && @new_resource.backup > 0 && ::File.exist?(path)
|
|
34
34
|
do_backup
|
|
35
35
|
# Clean up after the number of backups
|
|
36
36
|
slice_number = @new_resource.backup
|
data/lib/chef/util/diff.rb
CHANGED
|
@@ -60,7 +60,7 @@ class Chef
|
|
|
60
60
|
|
|
61
61
|
def use_tempfile_if_missing(file)
|
|
62
62
|
tempfile = nil
|
|
63
|
-
unless
|
|
63
|
+
unless File.exist?(file)
|
|
64
64
|
Chef::Log.trace("File #{file} does not exist to diff against, using empty tempfile")
|
|
65
65
|
tempfile = Tempfile.new("chef-diff")
|
|
66
66
|
file = tempfile.path
|
|
@@ -131,19 +131,6 @@ class Chef
|
|
|
131
131
|
diff_filesize_threshold = Chef::Config[:diff_filesize_threshold]
|
|
132
132
|
diff_output_threshold = Chef::Config[:diff_output_threshold]
|
|
133
133
|
|
|
134
|
-
# Download files for diffs in Target Mode, then work locally
|
|
135
|
-
if ChefConfig::Config.target_mode?
|
|
136
|
-
connection = Chef.run_context&.transport_connection
|
|
137
|
-
|
|
138
|
-
old_copy = Tempfile.new(old_file)
|
|
139
|
-
connection.download(old_file, old_copy.path) if connection.file(old_file).exist?
|
|
140
|
-
old_file = old_copy.path
|
|
141
|
-
|
|
142
|
-
new_copy = Tempfile.new(new_file)
|
|
143
|
-
connection.download(new_file, new_copy.path) if connection.file(new_file).exist?
|
|
144
|
-
new_file = new_copy.path
|
|
145
|
-
end
|
|
146
|
-
|
|
147
134
|
if ::File.size(old_file) > diff_filesize_threshold || ::File.size(new_file) > diff_filesize_threshold
|
|
148
135
|
return "(file sizes exceed #{diff_filesize_threshold} bytes, diff output suppressed)"
|
|
149
136
|
end
|
data/lib/chef/util/file_edit.rb
CHANGED
|
@@ -29,9 +29,9 @@ class Chef
|
|
|
29
29
|
public
|
|
30
30
|
|
|
31
31
|
def initialize(filepath)
|
|
32
|
-
raise ArgumentError, "File '#{filepath}' does not exist" unless
|
|
32
|
+
raise ArgumentError, "File '#{filepath}' does not exist" unless File.exist?(filepath)
|
|
33
33
|
|
|
34
|
-
@editor = Editor.new(
|
|
34
|
+
@editor = Editor.new(File.open(filepath, &:readlines))
|
|
35
35
|
@original_pathname = filepath
|
|
36
36
|
@file_edited = false
|
|
37
37
|
end
|
|
@@ -85,8 +85,8 @@ class Chef
|
|
|
85
85
|
def write_file
|
|
86
86
|
if @changes
|
|
87
87
|
backup_pathname = original_pathname + ".old"
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
FileUtils.cp(original_pathname, backup_pathname, preserve: true)
|
|
89
|
+
File.open(original_pathname, "w") do |newfile|
|
|
90
90
|
editor.lines.each do |line|
|
|
91
91
|
newfile.puts(line)
|
|
92
92
|
end
|
data/lib/chef/version.rb
CHANGED
data/lib/chef/win32/registry.rb
CHANGED
|
@@ -26,6 +26,11 @@ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
|
|
26
26
|
autoload :Registry, File.expand_path("../monkey_patches/win32/registry", __dir__)
|
|
27
27
|
end
|
|
28
28
|
require_relative "api/registry"
|
|
29
|
+
|
|
30
|
+
require "win32/resolv"
|
|
31
|
+
::Win32::Registry.define_method :export_string do |str, enc = (Encoding.default_internal || "utf-8")|
|
|
32
|
+
str.encode(enc)
|
|
33
|
+
end
|
|
29
34
|
end
|
|
30
35
|
|
|
31
36
|
class Chef
|
data/lib/chef/win32/security.rb
CHANGED
|
@@ -130,6 +130,15 @@ class Chef
|
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
+
def self.clear_account_rights(name)
|
|
134
|
+
return if get_account_right(name) == []
|
|
135
|
+
|
|
136
|
+
with_lsa_policy(name) do |policy_handle, sid|
|
|
137
|
+
result = LsaRemoveAccountRights(policy_handle.read_pointer, sid, true, nil, 1)
|
|
138
|
+
test_and_raise_lsa_nt_status(result)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
133
142
|
def self.adjust_token_privileges(token, privileges)
|
|
134
143
|
token = token.handle if token.respond_to?(:handle)
|
|
135
144
|
old_privileges_size = FFI::Buffer.new(:long).write_long(privileges.size_with_privileges)
|
data/lib/chef.rb
CHANGED
|
@@ -57,7 +57,7 @@ describe Chef::Resource::CookbookFile do
|
|
|
57
57
|
create_resource
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
it_behaves_like "a file resource"
|
|
60
|
+
it_behaves_like "a file resource", :not_supported_on_windows_11
|
|
61
61
|
|
|
62
62
|
# These examples cover CHEF-3467 where unexpected and incorrect
|
|
63
63
|
# permissions can result on Windows because CookbookFile's
|
data/spec/spec_helper.rb
CHANGED
|
@@ -145,6 +145,7 @@ RSpec.configure do |config|
|
|
|
145
145
|
|
|
146
146
|
config.filter_run_excluding windows_only: true unless windows?
|
|
147
147
|
config.filter_run_excluding not_supported_on_windows: true if windows?
|
|
148
|
+
config.filter_run_excluding not_supported_on_windows_11: true if windows_11?
|
|
148
149
|
config.filter_run_excluding not_supported_on_macos: true if macos?
|
|
149
150
|
config.filter_run_excluding macos_only: true unless macos?
|
|
150
151
|
config.filter_run_excluding not_macos_gte_11: true if macos_gte_11?
|
|
@@ -69,8 +69,8 @@ def make_canonical_temp_directory
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
# Check if a cmd exists on the PATH
|
|
72
|
-
def which(cmd)
|
|
73
|
-
paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
|
|
72
|
+
def which(cmd, prepend_path: nil, extra_path: nil)
|
|
73
|
+
paths = Array(prepend_path) + ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ] + Array(extra_path)
|
|
74
74
|
paths.each do |path|
|
|
75
75
|
filename = File.join(path, cmd)
|
|
76
76
|
return filename if File.executable?(filename)
|
|
@@ -65,6 +65,12 @@ def windows_gte_10?
|
|
|
65
65
|
Gem::Requirement.new(">= 10").satisfied_by?(Gem::Version.new(win32_os_version))
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
+
def windows_11?
|
|
69
|
+
return false unless windows?
|
|
70
|
+
|
|
71
|
+
Gem::Requirement.new(">= 10.0.22621").satisfied_by?(Gem::Version.new(win32_os_version))
|
|
72
|
+
end
|
|
73
|
+
|
|
68
74
|
def win32_os_version
|
|
69
75
|
@win32_os_version ||= begin
|
|
70
76
|
wmi = WmiLite::Wmi.new
|
|
@@ -228,6 +234,8 @@ def aes_256_gcm?
|
|
|
228
234
|
end
|
|
229
235
|
|
|
230
236
|
def fips_mode_build?
|
|
237
|
+
return false if ENV.fetch("BUILDKITE_PIPELINE_SLUG", "") =~ /verify$/
|
|
238
|
+
|
|
231
239
|
if ENV.include?("BUILDKITE_LABEL") # try keying directly off Buildkite environments
|
|
232
240
|
# regex version of chef/chef-foundation:.expeditor/release.omnibus.yml:fips-platforms
|
|
233
241
|
[/el-.*-x86_64/, /el-.*-ppc64/, /el-.*aarch/, /ubuntu-/, /windows-/, /amazon-2/].any? do |os_arch|
|
|
@@ -245,14 +245,14 @@ shared_examples_for "a file resource" do
|
|
|
245
245
|
|
|
246
246
|
include_context "deploying with move"
|
|
247
247
|
|
|
248
|
-
describe "when deploying via tmpdir" do
|
|
248
|
+
describe "when deploying via tmpdir", :not_supported_on_windows_11 do
|
|
249
249
|
|
|
250
250
|
include_context "deploying via tmpdir"
|
|
251
251
|
|
|
252
252
|
it_behaves_like "a configured file resource"
|
|
253
253
|
end
|
|
254
254
|
|
|
255
|
-
describe "when deploying via destdir" do
|
|
255
|
+
describe "when deploying via destdir", :not_supported_on_windows_11 do
|
|
256
256
|
|
|
257
257
|
include_context "deploying via destdir"
|
|
258
258
|
|
|
@@ -912,7 +912,7 @@ shared_examples_for "a configured file resource" do
|
|
|
912
912
|
dummy_desc
|
|
913
913
|
end
|
|
914
914
|
|
|
915
|
-
it_behaves_like "a securable resource without existing target"
|
|
915
|
+
it_behaves_like "a securable resource without existing target", :not_supported_on_windows_11
|
|
916
916
|
|
|
917
917
|
context "when the target file has the wrong content" do
|
|
918
918
|
before(:each) do
|