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
@@ -29,13 +29,13 @@ class Chef
|
|
29
29
|
class SystemdUnit < Chef::Provider
|
30
30
|
include Chef::Mixin::Which
|
31
31
|
|
32
|
-
provides :systemd_unit
|
32
|
+
provides :systemd_unit, target_mode: true
|
33
33
|
|
34
34
|
def load_current_resource
|
35
35
|
@current_resource = Chef::Resource::SystemdUnit.new(new_resource.name)
|
36
36
|
|
37
37
|
current_resource.unit_name(new_resource.unit_name)
|
38
|
-
current_resource.content(::File.read(unit_path)) if ::File.exist?(unit_path)
|
38
|
+
current_resource.content(::TargetIO::File.read(unit_path)) if ::TargetIO::File.exist?(unit_path)
|
39
39
|
current_resource.user(new_resource.user)
|
40
40
|
current_resource.enabled(enabled?)
|
41
41
|
current_resource.active(active?)
|
@@ -86,7 +86,7 @@ class Chef
|
|
86
86
|
end
|
87
87
|
|
88
88
|
action :delete, description: "Delete a systemd unit file, if it exists." do
|
89
|
-
if ::File.exist?(unit_path)
|
89
|
+
if ::TargetIO::File.exist?(unit_path)
|
90
90
|
converge_by("deleting unit: #{new_resource.unit_name}") do
|
91
91
|
manage_unit_file(:delete)
|
92
92
|
daemon_reload if new_resource.triggers_reload
|
@@ -23,7 +23,7 @@ require_relative "file"
|
|
23
23
|
class Chef
|
24
24
|
class Provider
|
25
25
|
class Template < Chef::Provider::File
|
26
|
-
provides :template
|
26
|
+
provides :template, target_mode: true
|
27
27
|
|
28
28
|
def initialize(new_resource, run_context)
|
29
29
|
@content_class = Chef::Provider::Template::Content
|
@@ -20,8 +20,8 @@ class Chef
|
|
20
20
|
class Provider
|
21
21
|
class User
|
22
22
|
class Aix < Chef::Provider::User
|
23
|
-
provides :user, os: "aix"
|
24
|
-
provides :aix_user
|
23
|
+
provides :user, os: "aix", target_mode: true
|
24
|
+
provides :aix_user, target_mode: true
|
25
25
|
|
26
26
|
# The ruby-shadow gem is not supported on aix.
|
27
27
|
def supports_ruby_shadow?
|
@@ -124,7 +124,7 @@ class Chef
|
|
124
124
|
return unless updating_home? && new_resource.manage_home
|
125
125
|
|
126
126
|
# -m option does not work on aix, so move dir.
|
127
|
-
if ::File.directory?(current_resource.home)
|
127
|
+
if ::TargetIO::File.directory?(current_resource.home)
|
128
128
|
logger.trace("Changing users home directory from #{current_resource.home} to #{new_resource.home}")
|
129
129
|
FileUtils.mv current_resource.home, new_resource.home
|
130
130
|
else
|
@@ -20,14 +20,19 @@ class Chef
|
|
20
20
|
class Provider
|
21
21
|
class User
|
22
22
|
class Linux < Chef::Provider::User
|
23
|
-
provides :linux_user
|
24
|
-
provides :user, os: "linux"
|
23
|
+
provides :linux_user, target_mode: true
|
24
|
+
provides :user, os: "linux", target_mode: true
|
25
25
|
|
26
26
|
def load_current_resource
|
27
27
|
super
|
28
28
|
load_shadow_options
|
29
29
|
end
|
30
30
|
|
31
|
+
def supports_ruby_shadow?
|
32
|
+
# For target mode, ruby-shadow is redirected to a file-based implementation
|
33
|
+
true unless ChefConfig::Config.target_mode?
|
34
|
+
end
|
35
|
+
|
31
36
|
def compare_user
|
32
37
|
user_changed = super
|
33
38
|
|
@@ -22,12 +22,12 @@ class Chef
|
|
22
22
|
class Provider
|
23
23
|
class User
|
24
24
|
class Pw < Chef::Provider::User
|
25
|
-
provides :pw_user
|
26
|
-
provides :user, os: "freebsd"
|
25
|
+
provides :pw_user, target_mode: true
|
26
|
+
provides :user, os: "freebsd", target_mode: true
|
27
27
|
|
28
28
|
def load_current_resource
|
29
29
|
super
|
30
|
-
raise Chef::Exceptions::User, "Could not find binary /usr/sbin/pw for #{new_resource}" unless ::File.exist?("/usr/sbin/pw")
|
30
|
+
raise Chef::Exceptions::User, "Could not find binary /usr/sbin/pw for #{new_resource}" unless ::TargetIO::File.exist?("/usr/sbin/pw")
|
31
31
|
end
|
32
32
|
|
33
33
|
def create_user
|
@@ -24,8 +24,8 @@ class Chef
|
|
24
24
|
class Provider
|
25
25
|
class User
|
26
26
|
class Solaris < Chef::Provider::User
|
27
|
-
provides :solaris_user
|
28
|
-
provides :user, os: %w{openindiana illumos omnios solaris2 smartos}
|
27
|
+
provides :solaris_user, target_mode: true
|
28
|
+
provides :user, os: %w{openindiana illumos omnios solaris2 smartos}, target_mode: true
|
29
29
|
|
30
30
|
PASSWORD_FILE = "/etc/shadow".freeze
|
31
31
|
|
@@ -46,7 +46,7 @@ class Chef
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def check_lock
|
49
|
-
user = IO.read(PASSWORD_FILE).match(/^#{Regexp.escape(new_resource.username)}:([^:]*):/)
|
49
|
+
user = TargetIO::IO.read(PASSWORD_FILE).match(/^#{Regexp.escape(new_resource.username)}:([^:]*):/)
|
50
50
|
|
51
51
|
# If we're in whyrun mode, and the user is not created, we assume it will be
|
52
52
|
return false if whyrun_mode? && user.nil?
|
@@ -122,7 +122,7 @@ class Chef
|
|
122
122
|
# a pipe to passwd(1) or evaluating modern ruby-shadow. See https://github.com/chef/chef/pull/721
|
123
123
|
def write_shadow_file
|
124
124
|
buffer = Tempfile.new("shadow", "/etc")
|
125
|
-
::File.open(PASSWORD_FILE) do |shadow_file|
|
125
|
+
::TargetIO::File.open(PASSWORD_FILE) do |shadow_file|
|
126
126
|
shadow_file.each do |entry|
|
127
127
|
user = entry.split(":").first
|
128
128
|
if user == new_resource.username
|
@@ -140,10 +140,10 @@ class Chef
|
|
140
140
|
uid = s.uid
|
141
141
|
gid = s.gid
|
142
142
|
|
143
|
-
FileUtils.chown uid, gid, buffer.path
|
144
|
-
FileUtils.chmod mode, buffer.path
|
143
|
+
TargetIO::FileUtils.chown uid, gid, buffer.path
|
144
|
+
TargetIO::FileUtils.chmod mode, buffer.path
|
145
145
|
|
146
|
-
FileUtils.mv buffer.path, PASSWORD_FILE
|
146
|
+
TargetIO::FileUtils.mv buffer.path, PASSWORD_FILE
|
147
147
|
end
|
148
148
|
|
149
149
|
def updated_password(entry)
|
data/lib/chef/provider/user.rb
CHANGED
@@ -36,7 +36,7 @@ class Chef
|
|
36
36
|
|
37
37
|
def convert_group_name
|
38
38
|
if new_resource.gid.is_a?(String) && new_resource.gid.to_i == 0
|
39
|
-
new_resource.gid(Etc.getgrnam(new_resource.gid).gid)
|
39
|
+
new_resource.gid(TargetIO::Etc.getgrnam(new_resource.gid).gid)
|
40
40
|
end
|
41
41
|
rescue ArgumentError
|
42
42
|
@group_name_resolved = false
|
@@ -47,7 +47,7 @@ class Chef
|
|
47
47
|
current_resource.username(new_resource.username)
|
48
48
|
|
49
49
|
begin
|
50
|
-
user_info = Etc.getpwnam(new_resource.username)
|
50
|
+
user_info = TargetIO::Etc.getpwnam(new_resource.username)
|
51
51
|
rescue ArgumentError
|
52
52
|
@user_exists = false
|
53
53
|
logger.trace("#{new_resource} user does not exist")
|
@@ -68,10 +68,13 @@ class Chef
|
|
68
68
|
|
69
69
|
begin
|
70
70
|
require "shadow"
|
71
|
+
|
72
|
+
# Cannot use this library remotely
|
73
|
+
@shadow_lib_ok = false if ChefConfig::Config.target_mode?
|
71
74
|
rescue LoadError
|
72
75
|
@shadow_lib_ok = false
|
73
76
|
else
|
74
|
-
@shadow_info = Shadow::Passwd.getspnam(new_resource.username)
|
77
|
+
@shadow_info = TargetIO::Shadow::Passwd.getspnam(new_resource.username)
|
75
78
|
# This conditional remains in place until we can sort out whether we need it.
|
76
79
|
# Currently removing it causes tests to fail, but that /seems/ to be mocking/setup issues.
|
77
80
|
# Some notes for context:
|
@@ -153,11 +156,7 @@ class Chef
|
|
153
156
|
new_val = new_resource.send(user_attrib)
|
154
157
|
cur_val = current_resource.send(user_attrib)
|
155
158
|
if !new_val.nil? && new_val.to_s != cur_val.to_s
|
156
|
-
|
157
|
-
@change_desc << "change #{user_attrib} from ******** to ********"
|
158
|
-
else
|
159
|
-
@change_desc << "change #{user_attrib} from #{cur_val} to #{new_val}"
|
160
|
-
end
|
159
|
+
@change_desc << "change #{user_attrib} from #{cur_val} to #{new_val}"
|
161
160
|
end
|
162
161
|
end
|
163
162
|
|
@@ -25,7 +25,7 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
25
25
|
class Chef
|
26
26
|
class Provider
|
27
27
|
class ZypperRepository < Chef::Provider
|
28
|
-
provides :zypper_repository, platform_family: "suse"
|
28
|
+
provides :zypper_repository, platform_family: "suse", target_mode: true
|
29
29
|
|
30
30
|
def load_current_resource; end
|
31
31
|
|
data/lib/chef/providers.rb
CHANGED
@@ -74,6 +74,7 @@ require_relative "provider/package/cab"
|
|
74
74
|
require_relative "provider/package/powershell"
|
75
75
|
require_relative "provider/package/msu"
|
76
76
|
require_relative "provider/package/snap"
|
77
|
+
require_relative "provider/package/snap_tm"
|
77
78
|
require_relative "provider/package/habitat"
|
78
79
|
|
79
80
|
require_relative "provider/service/arch"
|
File without changes
|
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
class Resource
|
24
24
|
class Alternatives < Chef::Resource
|
25
25
|
|
26
|
-
provides(:alternatives) { true }
|
26
|
+
provides(:alternatives, target_mode: true) { true }
|
27
27
|
|
28
28
|
description "Use the **alternatives** resource to configure command alternatives in Linux using the alternatives or update-alternatives packages."
|
29
29
|
introduced "16.0"
|
@@ -113,7 +113,7 @@ class Chef
|
|
113
113
|
|
114
114
|
requirements.assert(:install, :set, :remove) do |a|
|
115
115
|
a.assertion do
|
116
|
-
::File.exist?(new_resource.path)
|
116
|
+
::TargetIO::File.exist?(new_resource.path)
|
117
117
|
end
|
118
118
|
|
119
119
|
a.whyrun("Assuming file #{new_resource.path} already exists or was created already")
|
@@ -22,7 +22,7 @@ class Chef
|
|
22
22
|
class Resource
|
23
23
|
class AptPreference < Chef::Resource
|
24
24
|
|
25
|
-
provides(:apt_preference) { true }
|
25
|
+
provides(:apt_preference, target_mode: true) { true }
|
26
26
|
|
27
27
|
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."
|
28
28
|
introduced "13.3"
|
@@ -17,7 +17,6 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require_relative "../resource"
|
20
|
-
require_relative "../http/simple"
|
21
20
|
require "tmpdir" unless defined?(Dir.mktmpdir)
|
22
21
|
module Addressable
|
23
22
|
autoload :URI, "addressable/uri"
|
@@ -27,7 +26,7 @@ class Chef
|
|
27
26
|
class Resource
|
28
27
|
class AptRepository < Chef::Resource
|
29
28
|
|
30
|
-
provides(:apt_repository) { true }
|
29
|
+
provides(:apt_repository, target_mode: true) { true }
|
31
30
|
|
32
31
|
description "Use the **apt_repository** resource to specify additional APT repositories. Adding a new repository will update the APT package cache immediately."
|
33
32
|
introduced "12.9"
|
@@ -99,7 +98,6 @@ class Chef
|
|
99
98
|
```
|
100
99
|
|
101
100
|
**Add repository that needs custom options**:
|
102
|
-
|
103
101
|
```ruby
|
104
102
|
apt_repository 'corretto' do
|
105
103
|
uri 'https://apt.corretto.aws'
|
@@ -173,7 +171,7 @@ class Chef
|
|
173
171
|
default: true, desired_state: false
|
174
172
|
|
175
173
|
property :options, [String, Array],
|
176
|
-
description: "Additional options to set for the repository
|
174
|
+
description: "Additional options to set for the repository",
|
177
175
|
default: [], coerce: proc { |x| Array(x) }
|
178
176
|
|
179
177
|
default_action :add
|
@@ -289,8 +287,8 @@ class Chef
|
|
289
287
|
def install_key_from_uri(key)
|
290
288
|
key_name = key.gsub(/[^0-9A-Za-z\-]/, "_")
|
291
289
|
cached_keyfile = ::File.join(Chef::Config[:file_cache_path], key_name)
|
292
|
-
tmp_dir = Dir.mktmpdir(".gpg")
|
293
|
-
at_exit { FileUtils.remove_entry(tmp_dir) }
|
290
|
+
tmp_dir = TargetIO::Dir.mktmpdir(".gpg")
|
291
|
+
at_exit { TargetIO::FileUtils.remove_entry(tmp_dir) }
|
294
292
|
|
295
293
|
declare_resource(key_type(key), cached_keyfile) do
|
296
294
|
source key
|
@@ -360,7 +358,7 @@ class Chef
|
|
360
358
|
# @return [void]
|
361
359
|
def install_ppa_key(owner, repo)
|
362
360
|
url = "https://launchpad.net/api/1.0/~#{owner}/+archive/#{repo}"
|
363
|
-
key_id =
|
361
|
+
key_id = TargetIO::HTTP.new(url).get("signing_key_fingerprint").delete('"')
|
364
362
|
install_key_from_keyserver(key_id, "keyserver.ubuntu.com")
|
365
363
|
rescue Net::HTTPClientException => e
|
366
364
|
raise "Could not access Launchpad ppa API: #{e.message}"
|
@@ -434,7 +432,7 @@ class Chef
|
|
434
432
|
# @return [void]
|
435
433
|
def cleanup_legacy_file!
|
436
434
|
legacy_path = "/etc/apt/sources.list.d/#{new_resource.name}.list"
|
437
|
-
if new_resource.name != new_resource.repo_name && ::File.exist?(legacy_path)
|
435
|
+
if new_resource.name != new_resource.repo_name && ::TargetIO::File.exist?(legacy_path)
|
438
436
|
converge_by "Cleaning up legacy #{legacy_path} repo file" do
|
439
437
|
file legacy_path do
|
440
438
|
action :delete
|
@@ -500,7 +498,7 @@ class Chef
|
|
500
498
|
return unless debian?
|
501
499
|
|
502
500
|
cleanup_legacy_file!
|
503
|
-
if ::File.exist?("/etc/apt/sources.list.d/#{new_resource.repo_name}.list")
|
501
|
+
if ::TargetIO::File.exist?("/etc/apt/sources.list.d/#{new_resource.repo_name}.list")
|
504
502
|
converge_by "Removing #{new_resource.repo_name} repository from /etc/apt/sources.list.d/" do
|
505
503
|
apt_update new_resource.name do
|
506
504
|
ignore_failure true
|
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
class Resource
|
24
24
|
class AptUpdate < Chef::Resource
|
25
25
|
|
26
|
-
provides(:apt_update) { true }
|
26
|
+
provides(:apt_update, target_mode: true) { true }
|
27
27
|
|
28
28
|
description "Use the **apt_update** resource to manage APT repository updates on Debian and Ubuntu platforms."
|
29
29
|
introduced "12.7"
|
@@ -62,8 +62,8 @@ class Chef
|
|
62
62
|
#
|
63
63
|
# @return [Boolean]
|
64
64
|
def apt_up_to_date?
|
65
|
-
::File.exist?("#{STAMP_DIR}/update-success-stamp") &&
|
66
|
-
::File.mtime("#{STAMP_DIR}/update-success-stamp") > Time.now - new_resource.frequency
|
65
|
+
::TargetIO::File.exist?("#{STAMP_DIR}/update-success-stamp") &&
|
66
|
+
::TargetIO::File.mtime("#{STAMP_DIR}/update-success-stamp") > Time.now - new_resource.frequency
|
67
67
|
end
|
68
68
|
|
69
69
|
def do_update
|
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
class Resource
|
24
24
|
class BffPackage < Chef::Resource::Package
|
25
25
|
|
26
|
-
provides :bff_package
|
26
|
+
provides :bff_package, target_mode: true
|
27
27
|
|
28
28
|
description "Use the **bff_package** resource to manage packages for the AIX platform using the installp utility. When a package is installed from a local file, it must be added to the node using the **remote_file** or **cookbook_file** resources."
|
29
29
|
introduced "12.0"
|
@@ -21,7 +21,7 @@ class Chef
|
|
21
21
|
class Resource
|
22
22
|
class ChefClientConfig < Chef::Resource
|
23
23
|
|
24
|
-
provides :chef_client_config
|
24
|
+
provides :chef_client_config, target_mode: true
|
25
25
|
|
26
26
|
description "Use the **chef_client_config** resource to create a client.rb file in the #{ChefUtils::Dist::Infra::PRODUCT} configuration directory. See the [client.rb docs](https://docs.chef.io/config_rb_client/) for more details on options available in the client.rb configuration file."
|
27
27
|
introduced "16.6"
|
@@ -198,7 +198,8 @@ class Chef
|
|
198
198
|
introduced: "17.3"
|
199
199
|
|
200
200
|
property :minimal_ohai, [true, false],
|
201
|
-
description: "Run a minimal set of Ohai plugins providing data necessary for the execution of #{ChefUtils::Dist::Infra::PRODUCT}'s built-in resources. Setting this to true will skip many large and time consuming data sets such as `cloud` or `packages`. Setting this
|
201
|
+
description: "Run a minimal set of Ohai plugins providing data necessary for the execution of #{ChefUtils::Dist::Infra::PRODUCT}'s built-in resources. Setting this to true will skip many large and time consuming data sets such as `cloud` or `packages`. Setting this to true may break cookbooks that assume all Ohai data will be present.",
|
202
|
+
default: false
|
202
203
|
|
203
204
|
property :start_handlers, Array,
|
204
205
|
description: %q(An array of hashes that contain a report handler class and the arguments to pass to that class on initialization. The hash should include `class` and `argument` keys where `class` is a String and `argument` is an array of quoted String values. For example: `[{'class' => 'MyHandler', %w('"argument1"', '"argument2"')}]`),
|
@@ -103,6 +103,10 @@ class Chef
|
|
103
103
|
coerce: proc { |x| Integer(x) },
|
104
104
|
callbacks: { "should be a positive Integer" => proc { |v| v > 0 } }
|
105
105
|
|
106
|
+
property :service_umask, [Integer, String],
|
107
|
+
description: "Fix umask for hardened systems that have a changed default umask. This changes the chef-client umask so any files or folders are created with new umask. Recommend setting to stand install default of 0022.",
|
108
|
+
introduced: "18.5"
|
109
|
+
|
106
110
|
action :add, description: "Add a systemd timer that runs #{ChefUtils::Dist::Infra::PRODUCT}." do
|
107
111
|
systemd_unit "#{new_resource.job_name}.service" do
|
108
112
|
content service_content
|
@@ -175,6 +179,7 @@ class Chef
|
|
175
179
|
"Install" => { "WantedBy" => "multi-user.target" },
|
176
180
|
}
|
177
181
|
|
182
|
+
unit["Service"]["UMask"] = new_resource.service_umask if new_resource.service_umask
|
178
183
|
unit["Service"]["ConditionACPower"] = "true" unless new_resource.run_on_battery
|
179
184
|
unit["Service"]["CPUQuota"] = "#{new_resource.cpu_quota}%" if new_resource.cpu_quota
|
180
185
|
unit["Service"]["Environment"] = new_resource.environment.collect { |k, v| "\"#{k}=#{v}\"" } unless new_resource.environment.empty?
|
@@ -20,7 +20,7 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
20
20
|
class Chef
|
21
21
|
class Resource
|
22
22
|
class ChefSleep < Chef::Resource
|
23
|
-
provides :chef_sleep
|
23
|
+
provides :chef_sleep, target_mode: true
|
24
24
|
|
25
25
|
description "Use the **chef_sleep** resource to pause (sleep) for a number of seconds during a #{ChefUtils::Dist::Infra::PRODUCT} run. Only use this resource when a command or service exits successfully but is not ready for the next step in a recipe."
|
26
26
|
introduced "15.5"
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
class CookbookFile < Chef::Resource::File
|
29
29
|
include Chef::Mixin::Securable
|
30
30
|
|
31
|
-
provides :cookbook_file
|
31
|
+
provides :cookbook_file, target_mode: true
|
32
32
|
|
33
33
|
description "Use the **cookbook_file** resource to transfer files from a sub-directory of COOKBOOK_NAME/files/ to a specified path located on a host that is running the #{ChefUtils::Dist::Infra::PRODUCT}. The file is selected according to file specificity, which allows different source files to be used based on the hostname, host platform (operating system, distro, or as appropriate), or platform version. Files that are located in the COOKBOOK_NAME/files/default sub-directory may be used on any platform.\n\nDuring a #{ChefUtils::Dist::Infra::PRODUCT} run, the checksum for each local file is calculated and then compared against the checksum for the same file as it currently exists in the cookbook on the #{ChefUtils::Dist::Server::PRODUCT}. A file is not transferred when the checksums match. Only files that require an update are transferred from the #{ChefUtils::Dist::Server::PRODUCT} to a node."
|
34
34
|
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
|
29
29
|
use "cron_shared"
|
30
30
|
|
31
|
-
provides :cron
|
31
|
+
provides :cron, target_mode: true
|
32
32
|
|
33
33
|
description "Use the **cron** resource to manage cron entries for time-based job scheduling. Properties for a schedule will default to * if not provided. The cron resource requires access to a crontab program, typically cron. Warning: The cron resource should only be used to modify an entry in a crontab file. The `cron_d` resource directly manages `cron.d` files. This resource ships in #{ChefUtils::Dist::Infra::PRODUCT} 14.4 or later and can also be found in the [cron](https://github.com/chef-cookbooks/cron) cookbook) for previous #{ChefUtils::Dist::Infra::PRODUCT} releases."
|
34
34
|
|
@@ -26,7 +26,7 @@ class Chef
|
|
26
26
|
|
27
27
|
use "cron_shared"
|
28
28
|
|
29
|
-
provides :cron_d
|
29
|
+
provides :cron_d, target_mode: true
|
30
30
|
|
31
31
|
introduced "14.4"
|
32
32
|
description "Use the **cron_d** resource to manage cron job files in the `/etc/cron.d` directory. Warning: #{ChefUtils::Dist::Infra::PRODUCT} also ships with the **cron** resource for managing the monolithic `/etc/crontab` file on platforms that lack cron.d support. See the [cron resource](/resources/cron/) for information on using that resource."
|
@@ -23,7 +23,7 @@ require_relative "../resource"
|
|
23
23
|
class Chef
|
24
24
|
class Resource
|
25
25
|
class CronAccess < Chef::Resource
|
26
|
-
provides :cron_access
|
26
|
+
provides :cron_access, target_mode: true
|
27
27
|
provides(:cron_manage) # legacy name @todo in Chef 15 we should { true } this so it wins over the cookbook
|
28
28
|
|
29
29
|
introduced "14.4"
|
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
class Resource
|
26
26
|
class Directory < Chef::Resource
|
27
27
|
|
28
|
-
provides :directory
|
28
|
+
provides :directory, target_mode: true
|
29
29
|
|
30
30
|
description "Use the **directory** resource to manage a directory, which is a hierarchy"\
|
31
31
|
" of folders that comprises all of the information stored on a computer."\
|
@@ -22,7 +22,7 @@ class Chef
|
|
22
22
|
class Resource
|
23
23
|
class DpkgPackage < Chef::Resource::Package
|
24
24
|
|
25
|
-
provides :dpkg_package
|
25
|
+
provides :dpkg_package, target_mode: true
|
26
26
|
|
27
27
|
description "Use the **dpkg_package** resource to manage packages for the dpkg platform. When a package is installed from a local file, it must be added to the node using the **remote_file** or **cookbook_file** resources."
|
28
28
|
|
@@ -442,14 +442,14 @@ class Chef
|
|
442
442
|
NetworkService have this right when running as a service. This is necessary
|
443
443
|
even if the user is an Administrator.
|
444
444
|
|
445
|
-
This right can be added and checked in a recipe using this example:
|
445
|
+
This right can be added and checked in a recipe using this example (will not take effect in the same Chef run):
|
446
446
|
|
447
447
|
```ruby
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
448
|
+
windows_user_privilege 'add assign token privilege' do
|
449
|
+
principal '<user>'
|
450
|
+
privilege 'SeAssignPrimaryTokenPrivilege'
|
451
|
+
action :add
|
452
|
+
end
|
453
453
|
```
|
454
454
|
|
455
455
|
The following example shows how to run `mkdir test_dir` from a Chef Infra Client
|
@@ -492,9 +492,11 @@ class Chef
|
|
492
492
|
|
493
493
|
**Run a command with an external input file**:
|
494
494
|
|
495
|
+
```ruby
|
495
496
|
execute 'md5sum' do
|
496
497
|
input File.read(__FILE__)
|
497
498
|
end
|
499
|
+
```
|
498
500
|
EXAMPLES
|
499
501
|
|
500
502
|
# The ResourceGuardInterpreter wraps a resource's guards in another resource. That inner resource
|
@@ -37,7 +37,7 @@ class Chef
|
|
37
37
|
provides :json
|
38
38
|
|
39
39
|
def verify(path, opts = {})
|
40
|
-
Chef::JSONCompat.parse(IO.read(path))
|
40
|
+
Chef::JSONCompat.parse(TargetIO::IO.read(path))
|
41
41
|
true
|
42
42
|
rescue Chef::Exceptions::JSON::ParseError => e
|
43
43
|
Chef::Log.error("Json syntax verify failed with : #{e.message}")
|
data/lib/chef/resource/file.rb
CHANGED
@@ -29,7 +29,7 @@ class Chef
|
|
29
29
|
class File < Chef::Resource
|
30
30
|
include Chef::Mixin::Securable
|
31
31
|
|
32
|
-
provides :file
|
32
|
+
provides :file, target_mode: true
|
33
33
|
|
34
34
|
description "Use the **file** resource to manage files directly on a node. Note: Use the **cookbook_file** resource to copy a file from a cookbook's `/files` directory. Use the **template** resource to create a file based on a template in a cookbook's `/templates` directory. And use the **remote_file** resource to transfer a file to a node from a remote location."
|
35
35
|
|
@@ -25,8 +25,8 @@ require_relative "../provider/package/freebsd/pkgng"
|
|
25
25
|
class Chef
|
26
26
|
class Resource
|
27
27
|
class FreebsdPackage < Chef::Resource::Package
|
28
|
-
provides :freebsd_package
|
29
|
-
provides :package, platform: "freebsd"
|
28
|
+
provides :freebsd_package, target_mode: true
|
29
|
+
provides :package, platform: "freebsd", target_mode: true
|
30
30
|
|
31
31
|
description "Use the **freebsd_package** resource to manage packages for the FreeBSD platform."
|
32
32
|
|
data/lib/chef/resource/group.rb
CHANGED
@@ -22,7 +22,7 @@ class Chef
|
|
22
22
|
class Resource
|
23
23
|
class HabitatPackage < Chef::Resource::Package
|
24
24
|
|
25
|
-
provides :habitat_package
|
25
|
+
provides :habitat_package, target_mode: true
|
26
26
|
use "habitat_shared"
|
27
27
|
description "Use the **habitat_package** to install or remove Chef Habitat packages from Habitat Builder."
|
28
28
|
introduced "17.3"
|
@@ -21,7 +21,7 @@ class Chef
|
|
21
21
|
class Resource
|
22
22
|
class HabitatSup < Chef::Resource
|
23
23
|
|
24
|
-
provides
|
24
|
+
provides(:habitat_sup, target_mode: true) do |_node|
|
25
25
|
false
|
26
26
|
end
|
27
27
|
|
@@ -186,10 +186,10 @@ class Chef
|
|
186
186
|
habitat_install new_resource.name do
|
187
187
|
license new_resource.license
|
188
188
|
hab_version new_resource.sup_version if new_resource.sup_version
|
189
|
-
not_if { ::File.exist?("/bin/hab") }
|
190
|
-
not_if { ::File.exist?("/usr/bin/hab") }
|
191
|
-
not_if { ::File.exist?("c:/habitat/hab.exe") }
|
192
|
-
not_if { ::File.exist?("c:/ProgramData/Habitat/hab.exe") }
|
189
|
+
not_if { ::TargetIO::File.exist?("/bin/hab") }
|
190
|
+
not_if { ::TargetIO::File.exist?("/usr/bin/hab") }
|
191
|
+
not_if { ::TargetIO::File.exist?("c:/habitat/hab.exe") }
|
192
|
+
not_if { ::TargetIO::File.exist?("c:/ProgramData/Habitat/hab.exe") }
|
193
193
|
end
|
194
194
|
|
195
195
|
habitat_package "core/hab-sup" do
|
@@ -205,7 +205,7 @@ class Chef
|
|
205
205
|
if windows?
|
206
206
|
directory "C:/hab/sup/default/config" do
|
207
207
|
recursive true
|
208
|
-
only_if { ::Dir.exist?("C:/hab") }
|
208
|
+
only_if { ::TargetIO::Dir.exist?("C:/hab") }
|
209
209
|
only_if { use_toml_config }
|
210
210
|
action :create
|
211
211
|
end
|
@@ -235,14 +235,14 @@ class Chef
|
|
235
235
|
keep_latest_packages: new_resource.keep_latest
|
236
236
|
)
|
237
237
|
only_if { use_toml_config }
|
238
|
-
only_if { ::Dir.exist?("C:/hab/sup/default/config") }
|
238
|
+
only_if { ::TargetIO::Dir.exist?("C:/hab/sup/default/config") }
|
239
239
|
end
|
240
240
|
else
|
241
241
|
directory "/hab/sup/default/config" do
|
242
242
|
mode "0755"
|
243
243
|
recursive true
|
244
244
|
only_if { use_toml_config }
|
245
|
-
only_if { ::Dir.exist?("/hab") }
|
245
|
+
only_if { ::TargetIO::Dir.exist?("/hab") }
|
246
246
|
action :create
|
247
247
|
end
|
248
248
|
|
@@ -271,7 +271,7 @@ class Chef
|
|
271
271
|
keep_latest_packages: new_resource.keep_latest
|
272
272
|
)
|
273
273
|
only_if { use_toml_config }
|
274
|
-
only_if { ::Dir.exist?("/hab/sup/default/config") }
|
274
|
+
only_if { ::TargetIO::Dir.exist?("/hab/sup/default/config") }
|
275
275
|
end
|
276
276
|
end
|
277
277
|
end
|