chef 18.4.2 → 18.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -1
- data/chef.gemspec +7 -7
- data/lib/chef/application/client.rb +12 -0
- data/lib/chef/client.rb +10 -16
- data/lib/chef/compliance/runner.rb +10 -0
- data/lib/chef/cookbook/chefignore.rb +4 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +7 -1
- data/lib/chef/cookbook_manifest.rb +2 -2
- data/lib/chef/file_access_control/unix.rb +9 -9
- data/lib/chef/file_cache.rb +17 -2
- data/lib/chef/file_content_management/deploy/target_io.rb +29 -0
- data/lib/chef/file_content_management/deploy.rb +4 -1
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/mixin/file_class.rb +3 -1
- data/lib/chef/mixin/get_source_from_package.rb +1 -1
- data/lib/chef/mixin/openssl_helper.rb +1 -1
- data/lib/chef/node/attribute.rb +3 -11
- data/lib/chef/node/immutable_collections.rb +15 -8
- data/lib/chef/node/mixin/state_tracking.rb +6 -3
- data/lib/chef/node.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +8 -0
- data/lib/chef/provider/.gitkeep +0 -0
- 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 +42 -29
- 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 +2 -3
- 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 +2 -11
- data/lib/chef/provider/package/bff.rb +3 -3
- data/lib/chef/provider/package/chocolatey.rb +54 -24
- 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 +5 -3
- data/lib/chef/provider/package/ips.rb +2 -2
- data/lib/chef/provider/package/openbsd.rb +3 -2
- 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/powershell.rb +1 -0
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/package/snap.rb +2 -1
- data/lib/chef/provider/package/snap_tm.rb +79 -0
- data/lib/chef/provider/package/solaris.rb +4 -4
- data/lib/chef/provider/package/zypper.rb +4 -5
- 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 +2 -3
- 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/service/windows.rb +0 -1
- 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 +7 -2
- data/lib/chef/provider/user/pw.rb +3 -3
- data/lib/chef/provider/user/solaris.rb +7 -7
- data/lib/chef/provider/user.rb +7 -8
- data/lib/chef/provider/yum_repository.rb +1 -3
- data/lib/chef/provider/zypper_repository.rb +1 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/.gitkeep +0 -0
- data/lib/chef/resource/alternatives.rb +2 -2
- data/lib/chef/resource/apt_preference.rb +1 -1
- data/lib/chef/resource/apt_repository.rb +7 -9
- 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_client_systemd_timer.rb +5 -0
- data/lib/chef/resource/chef_gem.rb +1 -1
- 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/execute.rb +8 -6
- 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 +5 -4
- data/lib/chef/resource/hostname.rb +11 -10
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/ifconfig.rb +1 -1
- data/lib/chef/resource/inspec_input.rb +3 -1
- 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/powershell_package.rb +4 -0
- 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 +3 -4
- data/lib/chef/resource/rhsm_subscription.rb +8 -9
- 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 +24 -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 +1 -1
- data/lib/chef/resource/swap_file.rb +6 -6
- data/lib/chef/resource/sysctl.rb +6 -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/run_lock.rb +3 -0
- data/lib/chef/scan_access_control.rb +6 -6
- data/lib/chef/target_io/dir.rb +12 -0
- data/lib/chef/target_io/etc.rb +16 -0
- data/lib/chef/target_io/file.rb +12 -0
- data/lib/chef/target_io/fileutils.rb +12 -0
- data/lib/chef/target_io/http.rb +22 -0
- data/lib/chef/target_io/io.rb +12 -0
- data/lib/chef/target_io/shadow.rb +44 -0
- data/lib/chef/target_io/train/dir.rb +69 -0
- data/lib/chef/target_io/train/etc.rb +112 -0
- data/lib/chef/target_io/train/file.rb +219 -0
- data/lib/chef/target_io/train/fileutils.rb +220 -0
- data/lib/chef/target_io/train/http.rb +117 -0
- data/lib/chef/target_io/train/io.rb +13 -0
- data/lib/chef/target_io/train/shadow.rb +52 -0
- data/lib/chef/target_io/train_compat.rb +7 -0
- data/lib/chef/target_io.rb +9 -0
- data/lib/chef/util/backup.rb +1 -1
- data/lib/chef/util/diff.rb +14 -1
- data/lib/chef/util/file_edit.rb +4 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef.rb +2 -0
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/integration/client/fips_spec.rb +11 -2
- data/spec/integration/client/open_ssl_spec.rb +20 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/support/platform_helpers.rb +20 -7
- data/spec/unit/client_spec.rb +0 -16
- data/spec/unit/file_cache_spec.rb +64 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +6 -1
- data/spec/unit/provider/apt_repository_spec.rb +1 -1
- data/spec/unit/provider/package/chocolatey_spec.rb +17 -12
- data/spec/unit/provider/package/windows_spec.rb +5 -5
- data/spec/unit/provider/package/zypper_spec.rb +0 -10
- data/spec/unit/provider/route_spec.rb +6 -4
- data/spec/unit/resource/rhsm_repo_spec.rb +1 -0
- data/spec/unit/resource/rhsm_subscription_spec.rb +2 -0
- metadata +31 -10
@@ -18,7 +18,7 @@ class Chef
|
|
18
18
|
class SelinuxPermissive < Chef::Resource
|
19
19
|
unified_mode true
|
20
20
|
|
21
|
-
provides :selinux_permissive
|
21
|
+
provides :selinux_permissive, target_mode: true
|
22
22
|
|
23
23
|
description "Use the **selinux_permissive** resource to allow some domains to misbehave without stopping them. This is not as good as setting specific policies, but better than disabling SELinux entirely."
|
24
24
|
introduced "18.0"
|
@@ -61,4 +61,4 @@ class Chef
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
-
end
|
64
|
+
end
|
@@ -19,7 +19,7 @@ class Chef
|
|
19
19
|
class SelinuxPort < Chef::Resource
|
20
20
|
unified_mode true
|
21
21
|
|
22
|
-
provides :selinux_port
|
22
|
+
provides :selinux_port, target_mode: true
|
23
23
|
|
24
24
|
description "Use the **selinux_port** resource to assign a network port to a specific SELinux context. For example, running a web server on a non-standard port."
|
25
25
|
introduced "18.0"
|
@@ -115,4 +115,4 @@ class Chef
|
|
115
115
|
|
116
116
|
end
|
117
117
|
end
|
118
|
-
end
|
118
|
+
end
|
@@ -19,7 +19,7 @@ class Chef
|
|
19
19
|
class SelinuxState < Chef::Resource
|
20
20
|
unified_mode true
|
21
21
|
|
22
|
-
provides :selinux_state
|
22
|
+
provides :selinux_state, target_mode: true
|
23
23
|
|
24
24
|
description "Use **selinux_state** resource to manages the SELinux state on the system. It does this by using the `setenforce` command and rendering the `/etc/selinux/config` file from a template."
|
25
25
|
introduced "18.0"
|
@@ -163,4 +163,4 @@ class Chef
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
166
|
-
end
|
166
|
+
end
|
@@ -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, target_mode: true
|
26
|
+
provides :package, platform_family: "smartos", target_mode: true
|
27
27
|
|
28
28
|
description "Use the **smartos_package** resource to manage packages for the SmartOS platform."
|
29
29
|
|
@@ -22,10 +22,33 @@ class Chef
|
|
22
22
|
class Resource
|
23
23
|
class SnapPackage < Chef::Resource::Package
|
24
24
|
|
25
|
-
provides :snap_package
|
25
|
+
provides :snap_package, target_mode: true
|
26
26
|
|
27
27
|
description "Use the **snap_package** resource to manage snap packages on Debian and Ubuntu platforms."
|
28
28
|
introduced "15.0"
|
29
|
+
examples <<~DOC
|
30
|
+
**Install a package**
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
snap_package 'hello'
|
34
|
+
```
|
35
|
+
|
36
|
+
**Upgrade a package**
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
snap_package 'hello' do
|
40
|
+
action :upgrade
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
**Install a package with classic confinement**
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
snap_package 'hello' do
|
48
|
+
options 'classic'
|
49
|
+
end
|
50
|
+
```
|
51
|
+
DOC
|
29
52
|
|
30
53
|
allowed_actions :install, :upgrade, :remove, :purge
|
31
54
|
|
@@ -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, target_mode: true
|
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, target_mode: true
|
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) { true }
|
28
|
+
provides(:sudo, target_mode: true) { 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 ::File.readlines("#{new_resource.config_prefix}/sudoers").grep(/includedir/).empty?
|
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 ::TargetIO::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
|
+
Chef::Log.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 ::File.exist?(new_resource.visudo_binary)
|
282
|
+
return true if ::TargetIO::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 ::File.exist?(path)
|
288
|
+
if ::TargetIO::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 -"
|
@@ -10,7 +10,6 @@
|
|
10
10
|
@https_proxy
|
11
11
|
@ftp_proxy
|
12
12
|
@log_level
|
13
|
-
@minimal_ohai
|
14
13
|
@named_run_list
|
15
14
|
@no_proxy
|
16
15
|
@pid_file
|
@@ -22,6 +21,7 @@
|
|
22
21
|
<% next if instance_variable_get(prop).nil? || instance_variable_get(prop).empty? -%>
|
23
22
|
<%=prop.delete_prefix("@") %> <%= instance_variable_get(prop).inspect %>
|
24
23
|
<% end -%>
|
24
|
+
minimal_ohai <%= @minimal_ohai.inspect %>
|
25
25
|
<%# ohai_disabled_plugins and ohai_optional_plugins properties don't match the config value perfectly-%>
|
26
26
|
<% %w(@ohai_disabled_plugins
|
27
27
|
@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) { true }
|
24
|
+
provides(:swap_file, target_mode: true) { 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 ::File.exist?(new_resource.path)
|
87
|
+
remove_swapfile if ::TargetIO::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
|
-
::FileUtils.rm(new_resource.path)
|
132
|
+
::TargetIO::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
|
-
::File.exist?(fallocate_location.chomp)
|
189
|
+
::TargetIO::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 = ::File.readlines(fstab)
|
208
|
+
contents = ::TargetIO::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
|
-
::File.open(fstab, "w") { |f| f.write(contents.join("")) }
|
217
|
+
::TargetIO::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) { true }
|
25
|
-
provides(:sysctl_param) { true }
|
24
|
+
provides(:sysctl, target_mode: true) { true }
|
25
|
+
provides(:sysctl_param, target_mode: true) { 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
|
@@ -103,6 +103,7 @@ class Chef
|
|
103
103
|
property :comment, [Array, String],
|
104
104
|
description: "Comments, placed above the resource setting in the generated file. For multi-line comments, use an array of strings, one per line.",
|
105
105
|
default: [],
|
106
|
+
desired_state: false,
|
106
107
|
introduced: "15.8"
|
107
108
|
|
108
109
|
property :conf_dir, String,
|
@@ -151,7 +152,7 @@ class Chef
|
|
151
152
|
|
152
153
|
action :remove, description: "Remove the kernel parameter and update the `sysctl` settings." do
|
153
154
|
# only converge the resource if the file actually exists to delete
|
154
|
-
if ::File.exist?("#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr("/", ".")}.conf")
|
155
|
+
if ::TargetIO::File.exist?("#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr("/", ".")}.conf")
|
155
156
|
converge_by "removing sysctl config at #{new_resource.conf_dir}/99-chef-#{new_resource.key.tr("/", ".")}.conf" do
|
156
157
|
file "#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr("/", ".")}.conf" do
|
157
158
|
action :delete
|
@@ -215,9 +216,9 @@ class Chef
|
|
215
216
|
# return the value. Raise in case this conf file needs to be created
|
216
217
|
# or updated
|
217
218
|
def get_sysctld_value(key)
|
218
|
-
raise unless ::File.exist?("/etc/sysctl.d/99-chef-#{key.tr("/", ".")}.conf")
|
219
|
+
raise unless ::TargetIO::File.exist?("/etc/sysctl.d/99-chef-#{key.tr("/", ".")}.conf")
|
219
220
|
|
220
|
-
k, v = ::File.read("/etc/sysctl.d/99-chef-#{key.tr("/", ".")}.conf").match(/(.*) = (.*)/).captures
|
221
|
+
k, v = ::Target_IO::File.read("/etc/sysctl.d/99-chef-#{key.tr("/", ".")}.conf").match(/(.*) = (.*)/).captures
|
221
222
|
raise "Unknown sysctl key!" if k.nil?
|
222
223
|
raise "Unknown sysctl value!" if v.nil?
|
223
224
|
|
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
class Resource
|
25
25
|
class SystemdUnit < Chef::Resource
|
26
26
|
|
27
|
-
provides(:systemd_unit) { true }
|
27
|
+
provides(:systemd_unit, target_mode: true) { 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, target_mode: true
|
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 ::File.exist?("/etc/sysconfig/clock")
|
99
|
+
return nil unless ::TargetIO::File.exist?("/etc/sysconfig/clock")
|
100
100
|
|
101
101
|
# https://rubular.com/r/aoj01L3bKBM7wh
|
102
|
-
/ZONE="(.*)"/.match(::File.read("/etc/sysconfig/clock"))[1]
|
102
|
+
/ZONE="(.*)"/.match(::TargetIO::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 { ::File.executable?("/usr/sbin/tzdata-update") }
|
158
|
+
only_if { ::TargetIO::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 { ::File.executable?("/usr/sbin/tzdata-update") }
|
164
|
+
not_if { ::TargetIO::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, target_mode: true
|
26
|
+
provides :user, os: %w{omnios solaris2}, target_mode: true
|
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, target_mode: true
|
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) { true }
|
25
|
+
provides(:yum_repository, target_mode: true) { 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, target_mode: true
|
26
|
+
provides :package, platform_family: "suse", target_mode: true
|
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) { true }
|
26
|
-
provides(:zypper_repo) { true } # legacy cookbook compatibility
|
25
|
+
provides(:zypper_repository, target_mode: true) { true }
|
26
|
+
provides(:zypper_repo, target_mode: true) { 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"
|
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 ::File.exist?(new_resource.path)
|
49
|
+
if ::TargetIO::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 = Etc.getpwuid(stat.uid)).nil?
|
79
|
+
unless (pwent = TargetIO::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 = Etc.getgrgid(stat.gid)).nil?
|
106
|
+
unless (pwent = TargetIO::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
|
-
::File.lstat(@new_resource.path)
|
131
|
+
::TargetIO::File.lstat(@new_resource.path)
|
132
132
|
else
|
133
|
-
realpath = ::File.realpath(@new_resource.path)
|
134
|
-
::File.stat(realpath)
|
133
|
+
realpath = ::TargetIO::File.realpath(@new_resource.path)
|
134
|
+
::TargetIO::File.stat(realpath)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module TargetIO
|
2
|
+
class Dir
|
3
|
+
class << self
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
5
|
+
Chef::Log.debug format("Dir::%s(%s)", m.to_s, args.join(", "))
|
6
|
+
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::Dir : ::Dir
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module TargetIO
|
2
|
+
class Etc
|
3
|
+
class << self
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
5
|
+
Chef::Log.debug format("Etc::%s(%s)", m.to_s, args.join(", "))
|
6
|
+
|
7
|
+
if ChefConfig::Config.target_mode? && !Chef.run_context.transport_connection.os.unix?
|
8
|
+
raise "Etc support only on Unix, this is " + Chef.run_context.transport_connection.platform.title
|
9
|
+
end
|
10
|
+
|
11
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::Etc : ::Etc
|
12
|
+
backend.send(m, *args, **kwargs, &block)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module TargetIO
|
2
|
+
class File
|
3
|
+
class << self
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
5
|
+
Chef::Log.debug format("File::%s(%s)", m.to_s, args.join(", "))
|
6
|
+
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::File : ::File
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module TargetIO
|
2
|
+
class FileUtils
|
3
|
+
class << self
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
5
|
+
Chef::Log.debug format("FileUtils::%s(%s)", m.to_s, args.join(", "))
|
6
|
+
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::FileUtils : ::FileUtils
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "forwardable" unless defined?(Forwardable)
|
2
|
+
|
3
|
+
require_relative "../http/simple"
|
4
|
+
require_relative "train/http"
|
5
|
+
|
6
|
+
module TargetIO
|
7
|
+
class HTTP
|
8
|
+
extend Forwardable
|
9
|
+
def_delegators :@http_class, :get, :head, :patch, :post, :put, :delete
|
10
|
+
|
11
|
+
# Only for Chef::Provider::RemoteFile::HTTP
|
12
|
+
def_delegators :@http_class, :streaming_request, :streaming_request_with_progress, :last_response
|
13
|
+
|
14
|
+
def initialize(url, http_client_opts = {})
|
15
|
+
if ::ChefConfig::Config.target_mode?
|
16
|
+
@http_class = TargetIO::TrainCompat::HTTP.new(url, http_client_opts)
|
17
|
+
else
|
18
|
+
@http_class = Chef::HTTP::Simple.new(url, http_client_opts)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module TargetIO
|
2
|
+
class IO
|
3
|
+
class << self
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
5
|
+
Chef::Log.debug format("IO::%s(%s)", m.to_s, args.join(", "))
|
6
|
+
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::IO : ::IO
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module TargetIO
|
2
|
+
module Shadow
|
3
|
+
# sp_namp - pointer to null-terminated user name.
|
4
|
+
# sp_pwdp - pointer to null-terminated password.
|
5
|
+
# sp_lstchg - days since Jan 1, 1970 password was last
|
6
|
+
# changed.
|
7
|
+
# sp_min - days before which password may not be changed.
|
8
|
+
# sp_max - days after which password must be changed.
|
9
|
+
# sp_warn - days before password is to expire that user is
|
10
|
+
# warned of pending password expiration.
|
11
|
+
# sp_inact - days after password expires that account is
|
12
|
+
# considered inactive and disabled.
|
13
|
+
# sp_expire - days since Jan 1, 1970 when account will be
|
14
|
+
# disabled
|
15
|
+
# sp_loginclass - pointer to null-terminated user login class.
|
16
|
+
Entry = Struct.new(
|
17
|
+
:sp_namp,
|
18
|
+
:sp_pwdp,
|
19
|
+
:sp_lstchg,
|
20
|
+
:sp_min,
|
21
|
+
:sp_max,
|
22
|
+
:sp_warn,
|
23
|
+
:sp_inact,
|
24
|
+
:sp_expire,
|
25
|
+
:sp_loginclass
|
26
|
+
)
|
27
|
+
|
28
|
+
class Passwd
|
29
|
+
class << self
|
30
|
+
|
31
|
+
def method_missing(m, *args, **kwargs, &block)
|
32
|
+
Chef::Log.debug format("Shadow::Passwd::%s(%s)", m.to_s, args.join(", "))
|
33
|
+
|
34
|
+
if ChefConfig::Config.target_mode? && !Chef.run_context.transport_connection.os.unix?
|
35
|
+
raise "Shadow support only on Unix, this is " + Chef.run_context.transport_connection.platform.title
|
36
|
+
end
|
37
|
+
|
38
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::Shadow::Passwd : ::Shadow::Passwd
|
39
|
+
backend.send(m, *args, **kwargs, &block)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|