chef 18.5.0 → 18.7.3
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 +11 -6
- data/chef-universal-mingw-ucrt.gemspec +1 -1
- data/chef.gemspec +19 -15
- data/lib/chef/application/client.rb +0 -12
- data/lib/chef/client.rb +1 -10
- data/lib/chef/compliance/default_attributes.rb +2 -2
- data/lib/chef/compliance/runner.rb +6 -11
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
- data/lib/chef/cookbook/synchronizer.rb +0 -5
- data/lib/chef/event_dispatch/dispatcher.rb +0 -1
- 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/dnf/dnf_helper.py +7 -0
- 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 +2 -2
- 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/registry_key.rb +6 -0
- 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 +90 -15
- 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/registry_key.rb +18 -0
- 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.rb +1 -0
- data/lib/chef/resource_inspector.rb +25 -7
- data/lib/chef/resource_reporter.rb +1 -0
- 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/util/powershell/ps_credential.rb +10 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/registry.rb +5 -1
- data/lib/chef/win32/security.rb +9 -0
- data/lib/chef.rb +0 -2
- data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +6 -6
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/registry_spec.rb +276 -609
- 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/tiny_server.rb +5 -2
- data/spec/unit/mixin/homebrew_spec.rb +118 -0
- data/spec/unit/provider/apt_repository_spec.rb +14 -9
- data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
- data/spec/unit/provider/package/homebrew_spec.rb +4 -1
- data/spec/unit/provider/registry_key_spec.rb +18 -17
- 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
- data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
- metadata +36 -44
- 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
- /data/spec/functional/assets/yumrepo-empty/repodata/{01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 → 01a3b-filelists.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo-empty/repodata/{401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz → 401dc-filelists.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo-empty/repodata/{5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 → 5dc1e-primary.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo-empty/repodata/{6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz → 6bf96-other.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo-empty/repodata/{7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 → 7c365-other.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo-empty/repodata/{dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz → dabe2-primary.xml.gz} +0 -0
data/lib/chef/provider/route.rb
CHANGED
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
class Provider
|
26
26
|
class Route < Chef::Provider
|
27
27
|
|
28
|
-
provides :route
|
28
|
+
provides :route
|
29
29
|
|
30
30
|
attr_accessor :is_running
|
31
31
|
|
@@ -98,7 +98,7 @@ class Chef
|
|
98
98
|
# For linux, we use /proc/net/route file to read proc table info
|
99
99
|
return unless linux?
|
100
100
|
|
101
|
-
route_file = ::
|
101
|
+
route_file = ::File.open("/proc/net/route", "r")
|
102
102
|
|
103
103
|
# Read all routes
|
104
104
|
while (line = route_file.gets)
|
@@ -186,24 +186,24 @@ class Chef
|
|
186
186
|
network_file_name = "/etc/sysconfig/network"
|
187
187
|
converge_by("write route default route to #{network_file_name}") do
|
188
188
|
logger.trace("#{new_resource} writing default route #{new_resource.gateway} to #{network_file_name}")
|
189
|
-
if ::
|
189
|
+
if ::File.exist?(network_file_name)
|
190
190
|
network_file = ::Chef::Util::FileEdit.new(network_file_name)
|
191
191
|
network_file.search_file_replace_line(/^GATEWAY=/, "GATEWAY=#{new_resource.gateway}")
|
192
192
|
network_file.insert_line_if_no_match(/^GATEWAY=/, "GATEWAY=#{new_resource.gateway}")
|
193
193
|
network_file.write_file
|
194
194
|
else
|
195
|
-
::
|
196
|
-
|
197
|
-
|
195
|
+
network_file = ::File.new(network_file_name, "w")
|
196
|
+
network_file.puts("GATEWAY=#{new_resource.gateway}")
|
197
|
+
network_file.close
|
198
198
|
end
|
199
199
|
end
|
200
200
|
else
|
201
201
|
network_file_name = "/etc/sysconfig/network-scripts/route-#{k}"
|
202
202
|
converge_by("write route route.#{k}\n#{conf[k]} to #{network_file_name}") do
|
203
|
-
::
|
204
|
-
|
205
|
-
end
|
203
|
+
network_file = ::File.new(network_file_name, "w")
|
204
|
+
network_file.puts(conf[k])
|
206
205
|
logger.trace("#{new_resource} writing route.#{k}\n#{conf[k]}")
|
206
|
+
network_file.close
|
207
207
|
end
|
208
208
|
end
|
209
209
|
end
|
@@ -57,7 +57,7 @@ class Chef
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def enable_service
|
60
|
-
|
60
|
+
Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
|
61
61
|
|
62
62
|
if @new_resource.priority.is_a? Integer
|
63
63
|
create_symlink(2, "S", @new_resource.priority)
|
@@ -72,7 +72,7 @@ class Chef
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def disable_service
|
75
|
-
|
75
|
+
Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
|
76
76
|
|
77
77
|
if @new_resource.priority.is_a? Integer
|
78
78
|
create_symlink(2, "K", 100 - @new_resource.priority)
|
@@ -86,13 +86,13 @@ class Chef
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def create_symlink(run_level, status, priority)
|
89
|
-
::
|
89
|
+
::File.symlink("/etc/rc.d/init.d/#{@new_resource.service_name}", "/etc/rc.d/rc#{run_level}.d/#{status}#{priority}#{@new_resource.service_name}")
|
90
90
|
end
|
91
91
|
|
92
92
|
def set_current_resource_attributes
|
93
93
|
# assuming run level 2 for aix
|
94
94
|
is_enabled = false
|
95
|
-
files =
|
95
|
+
files = Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"])
|
96
96
|
|
97
97
|
priority = {}
|
98
98
|
|
@@ -20,7 +20,7 @@ require_relative "init"
|
|
20
20
|
|
21
21
|
class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
22
22
|
|
23
|
-
provides :service, platform_family: "arch"
|
23
|
+
provides :service, platform_family: "arch"
|
24
24
|
|
25
25
|
def self.supports?(resource, action)
|
26
26
|
service_script_exist?(:etc_rcd, resource.service_name)
|
@@ -32,8 +32,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def load_current_resource
|
35
|
-
raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::
|
36
|
-
raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless /DAEMONS=\((.*)\)/m.match?(::
|
35
|
+
raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exist?("/etc/rc.conf")
|
36
|
+
raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless /DAEMONS=\((.*)\)/m.match?(::File.read("/etc/rc.conf"))
|
37
37
|
|
38
38
|
super
|
39
39
|
|
@@ -50,7 +50,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
50
50
|
# )
|
51
51
|
def daemons
|
52
52
|
entries = []
|
53
|
-
if ::
|
53
|
+
if ::File.read("/etc/rc.conf") =~ /DAEMONS=\((.*)\)/m
|
54
54
|
entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/, " ").split(" ") if $1.length > 0
|
55
55
|
end
|
56
56
|
|
@@ -61,8 +61,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
61
61
|
|
62
62
|
# FIXME: Multiple entries of DAEMONS will cause very bad results :)
|
63
63
|
def update_daemons(entries)
|
64
|
-
content = ::
|
65
|
-
::
|
64
|
+
content = ::File.read("/etc/rc.conf").gsub(/DAEMONS=\((.*)\)/m, "DAEMONS=(#{entries.join(" ")})")
|
65
|
+
::File.open("/etc/rc.conf", "w") do |f|
|
66
66
|
f.write(content)
|
67
67
|
end
|
68
68
|
end
|
@@ -22,7 +22,7 @@ class Chef
|
|
22
22
|
class Provider
|
23
23
|
class Service
|
24
24
|
class Debian < Chef::Provider::Service::Init
|
25
|
-
provides :service, platform_family: "debian"
|
25
|
+
provides :service, platform_family: "debian" do
|
26
26
|
debianrcd?
|
27
27
|
end
|
28
28
|
|
@@ -46,7 +46,7 @@ class Chef
|
|
46
46
|
shared_resource_requirements
|
47
47
|
requirements.assert(:all_actions) do |a|
|
48
48
|
update_rcd = "/usr/sbin/update-rc.d"
|
49
|
-
a.assertion { ::
|
49
|
+
a.assertion { ::File.exist? update_rcd }
|
50
50
|
a.failure_message Chef::Exceptions::Service, "#{update_rcd} does not exist!"
|
51
51
|
# no whyrun recovery - this is a base system component of debian
|
52
52
|
# distros and must be present
|
@@ -73,10 +73,10 @@ class Chef
|
|
73
73
|
|
74
74
|
# returns a list of levels that the service should be stopped or started on
|
75
75
|
def parse_init_file(path)
|
76
|
-
return [] unless ::
|
76
|
+
return [] unless ::File.exist?(path)
|
77
77
|
|
78
78
|
in_info = false
|
79
|
-
::
|
79
|
+
::File.readlines(path).each_with_object([]) do |line, acc|
|
80
80
|
if /^### BEGIN INIT INFO/.match?(line)
|
81
81
|
in_info = true
|
82
82
|
elsif /^### END INIT INFO/.match?(line)
|
@@ -95,7 +95,7 @@ class Chef
|
|
95
95
|
|
96
96
|
levels = parse_init_file(@init_command)
|
97
97
|
levels.each do |level|
|
98
|
-
rc_files.push
|
98
|
+
rc_files.push Dir.glob("/etc/rc#{level}.d/[SK][0-9][0-9]#{current_resource.service_name}")
|
99
99
|
end
|
100
100
|
|
101
101
|
rc_files.flatten.each do |line|
|
@@ -26,7 +26,7 @@ class Chef
|
|
26
26
|
|
27
27
|
attr_reader :enabled_state_found
|
28
28
|
|
29
|
-
provides :service, os: %w{freebsd netbsd}
|
29
|
+
provides :service, os: %w{freebsd netbsd}
|
30
30
|
|
31
31
|
include Chef::Mixin::ShellOut
|
32
32
|
|
@@ -34,9 +34,9 @@ class Chef
|
|
34
34
|
super
|
35
35
|
@enabled_state_found = false
|
36
36
|
@init_command = nil
|
37
|
-
if ::
|
37
|
+
if ::File.exist?("/etc/rc.d/#{new_resource.service_name}")
|
38
38
|
@init_command = "/etc/rc.d/#{new_resource.service_name}"
|
39
|
-
elsif ::
|
39
|
+
elsif ::File.exist?("/usr/local/etc/rc.d/#{new_resource.service_name}")
|
40
40
|
@init_command = "/usr/local/etc/rc.d/#{new_resource.service_name}"
|
41
41
|
end
|
42
42
|
end
|
@@ -118,11 +118,11 @@ class Chef
|
|
118
118
|
private
|
119
119
|
|
120
120
|
def read_rc_conf
|
121
|
-
::
|
121
|
+
::File.open("/etc/rc.conf", "r", &:readlines)
|
122
122
|
end
|
123
123
|
|
124
124
|
def write_rc_conf(lines)
|
125
|
-
::
|
125
|
+
::File.open("/etc/rc.conf", "w") do |file|
|
126
126
|
lines.each { |line| file.puts(line) }
|
127
127
|
end
|
128
128
|
end
|
@@ -131,7 +131,7 @@ class Chef
|
|
131
131
|
def service_enable_variable_name
|
132
132
|
@service_enable_variable_name ||=
|
133
133
|
if init_command
|
134
|
-
::
|
134
|
+
::File.open(init_command) do |rcscript|
|
135
135
|
rcscript.each_line do |line|
|
136
136
|
if line =~ /^name="?(\w+)"?/
|
137
137
|
return $1 + "_enable"
|
@@ -150,7 +150,7 @@ class Chef
|
|
150
150
|
|
151
151
|
def determine_enabled_status!
|
152
152
|
var_name = service_enable_variable_name
|
153
|
-
if ::
|
153
|
+
if ::File.exist?("/etc/rc.conf") && var_name
|
154
154
|
read_rc_conf.each do |line|
|
155
155
|
case line
|
156
156
|
when /^#{Regexp.escape(var_name)}="(\w+)"/
|
@@ -22,7 +22,7 @@ require_relative "../../util/path_helper"
|
|
22
22
|
|
23
23
|
class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
24
24
|
|
25
|
-
provides :service, platform_family: "gentoo"
|
25
|
+
provides :service, platform_family: "gentoo"
|
26
26
|
|
27
27
|
def load_current_resource
|
28
28
|
supports[:status] = true if supports[:status].nil?
|
@@ -32,10 +32,10 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
|
32
32
|
super
|
33
33
|
|
34
34
|
@current_resource.enabled(
|
35
|
-
|
35
|
+
Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}").any? do |file|
|
36
36
|
@found_script = true
|
37
|
-
exists = ::
|
38
|
-
readable = ::
|
37
|
+
exists = ::File.exist? file
|
38
|
+
readable = ::File.readable? file
|
39
39
|
logger.trace "#{@new_resource} exists: #{exists}, readable: #{readable}"
|
40
40
|
exists && readable
|
41
41
|
end
|
@@ -47,7 +47,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
|
47
47
|
|
48
48
|
def define_resource_requirements
|
49
49
|
requirements.assert(:all_actions) do |a|
|
50
|
-
a.assertion { ::
|
50
|
+
a.assertion { ::File.exist?("/sbin/rc-update") }
|
51
51
|
a.failure_message Chef::Exceptions::Service, "/sbin/rc-update does not exist"
|
52
52
|
# no whyrun recovery -t his is a core component whose presence is
|
53
53
|
# unlikely to be affected by what we do in the course of a chef run
|
@@ -26,7 +26,7 @@ class Chef
|
|
26
26
|
|
27
27
|
attr_accessor :init_command
|
28
28
|
|
29
|
-
provides :service, os: "!windows"
|
29
|
+
provides :service, os: "!windows"
|
30
30
|
|
31
31
|
def self.supports?(resource, action)
|
32
32
|
service_script_exist?(:initd, resource.service_name)
|
@@ -42,7 +42,7 @@ class Chef
|
|
42
42
|
shared_resource_requirements
|
43
43
|
requirements.assert(:start, :stop, :restart, :reload) do |a|
|
44
44
|
a.assertion do
|
45
|
-
custom_command_for_action?(action) || ::
|
45
|
+
custom_command_for_action?(action) || ::File.exist?(default_init_command)
|
46
46
|
end
|
47
47
|
a.failure_message(Chef::Exceptions::Service, "#{default_init_command} does not exist!")
|
48
48
|
a.whyrun("Init script '#{default_init_command}' doesn't exist, assuming a prior action would have created it.") do
|
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
class Service
|
25
25
|
class Insserv < Chef::Provider::Service::Init
|
26
26
|
|
27
|
-
provides :service, platform_family: %w{debian rhel fedora suse amazon}
|
27
|
+
provides :service, platform_family: %w{debian rhel fedora suse amazon} do
|
28
28
|
insserv?
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ class Chef
|
|
38
38
|
# Look for a /etc/rc.*/SnnSERVICE link to signify that the service would be started in a runlevel
|
39
39
|
service_name = Chef::Util::PathHelper.escape_glob_dir(current_resource.service_name)
|
40
40
|
|
41
|
-
if
|
41
|
+
if Dir.glob("/etc/rc*/**/S*#{service_name}").empty?
|
42
42
|
current_resource.enabled false
|
43
43
|
else
|
44
44
|
current_resource.enabled true
|
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
class Service
|
25
25
|
class Openbsd < Chef::Provider::Service::Init
|
26
26
|
|
27
|
-
provides :service, os: "openbsd"
|
27
|
+
provides :service, os: "openbsd"
|
28
28
|
|
29
29
|
attr_reader :init_command, :rc_conf, :rc_conf_local, :enabled_state_found
|
30
30
|
|
@@ -33,9 +33,9 @@ class Chef
|
|
33
33
|
|
34
34
|
def initialize(new_resource, run_context)
|
35
35
|
super
|
36
|
-
@rc_conf = ::
|
37
|
-
@rc_conf_local = ::
|
38
|
-
@init_command = ::
|
36
|
+
@rc_conf = ::File.read(RC_CONF_PATH) rescue ""
|
37
|
+
@rc_conf_local = ::File.read(RC_CONF_LOCAL_PATH) rescue ""
|
38
|
+
@init_command = ::File.exist?(rcd_script_path) ? rcd_script_path : nil
|
39
39
|
new_resource.status_command("#{default_init_command} check")
|
40
40
|
end
|
41
41
|
|
@@ -129,8 +129,8 @@ class Chef
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def update_rcl(value)
|
132
|
-
|
133
|
-
::
|
132
|
+
FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.exist? RC_CONF_LOCAL_PATH
|
133
|
+
::File.write(RC_CONF_LOCAL_PATH, value)
|
134
134
|
@rc_conf_local = value
|
135
135
|
end
|
136
136
|
|
@@ -139,7 +139,7 @@ class Chef
|
|
139
139
|
@bsevn ||= begin
|
140
140
|
result = nil
|
141
141
|
if rcd_script_found?
|
142
|
-
::
|
142
|
+
::File.open(init_command) do |rcscript|
|
143
143
|
if m = rcscript.read.match(/^# \$OpenBSD: (\w+)[(.rc),]?/)
|
144
144
|
result = m[1] + "_flags"
|
145
145
|
end
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
# @api private
|
29
29
|
attr_accessor :current_run_levels
|
30
30
|
|
31
|
-
provides :service, platform_family: "rpm_based"
|
31
|
+
provides :service, platform_family: "rpm_based" do
|
32
32
|
redhatrcd?
|
33
33
|
end
|
34
34
|
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
|
57
57
|
requirements.assert(:all_actions) do |a|
|
58
58
|
chkconfig_file = "/sbin/chkconfig"
|
59
|
-
a.assertion { ::
|
59
|
+
a.assertion { ::File.exist? chkconfig_file }
|
60
60
|
a.failure_message Chef::Exceptions::Service, "#{chkconfig_file} does not exist!"
|
61
61
|
end
|
62
62
|
|
@@ -80,7 +80,7 @@ class Chef
|
|
80
80
|
|
81
81
|
super
|
82
82
|
|
83
|
-
if ::
|
83
|
+
if ::File.exist?("/sbin/chkconfig")
|
84
84
|
chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", returns: [0, 1])
|
85
85
|
unless run_levels.nil? || run_levels.empty?
|
86
86
|
all_levels_match = true
|
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
class Solaris < Chef::Provider::Service
|
26
26
|
attr_reader :maintenance
|
27
27
|
|
28
|
-
provides :service, os: "solaris2"
|
28
|
+
provides :service, os: "solaris2"
|
29
29
|
|
30
30
|
def initialize(new_resource, run_context = nil)
|
31
31
|
super
|
@@ -39,7 +39,7 @@ class Chef
|
|
39
39
|
@current_resource.service_name(@new_resource.service_name)
|
40
40
|
|
41
41
|
[@init_command, @status_command].each do |cmd|
|
42
|
-
unless ::
|
42
|
+
unless ::File.executable? cmd
|
43
43
|
raise Chef::Exceptions::Service, "#{cmd} not executable!"
|
44
44
|
end
|
45
45
|
end
|
@@ -26,7 +26,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
26
26
|
|
27
27
|
include Chef::Mixin::Which
|
28
28
|
|
29
|
-
provides
|
29
|
+
provides :service, os: "linux", target_mode: true do |node|
|
30
30
|
systemd?
|
31
31
|
end
|
32
32
|
|
@@ -106,7 +106,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
106
106
|
if new_resource.user
|
107
107
|
raise NotImplementedError, "#{new_resource} does not support the user property on a target_mode host (yet)" if Chef::Config.target_mode?
|
108
108
|
|
109
|
-
uid =
|
109
|
+
uid = Etc.getpwnam(new_resource.user).uid
|
110
110
|
options = {
|
111
111
|
environment: {
|
112
112
|
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus",
|
@@ -124,9 +124,9 @@ class Chef
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
# Get enabled/disabled state by reading job configuration file
|
127
|
-
if ::
|
127
|
+
if ::File.exist?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
|
128
128
|
logger.trace("#{@new_resource} found #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
|
129
|
-
::
|
129
|
+
::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}", "r") do |file|
|
130
130
|
while line = file.gets
|
131
131
|
case line
|
132
132
|
when /^start on/
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
class Provider
|
28
28
|
class Subversion < Chef::Provider
|
29
29
|
|
30
|
-
provides :subversion
|
30
|
+
provides :subversion
|
31
31
|
|
32
32
|
SVN_INFO_PATTERN = /^([\w\s]+): (.+)$/.freeze
|
33
33
|
|
@@ -48,7 +48,7 @@ class Chef
|
|
48
48
|
# Make sure the parent dir exists, or else fail.
|
49
49
|
# for why run, print a message explaining the potential error.
|
50
50
|
parent_directory = ::File.dirname(new_resource.destination)
|
51
|
-
a.assertion { ::
|
51
|
+
a.assertion { ::File.directory?(parent_directory) }
|
52
52
|
a.failure_message(Chef::Exceptions::MissingParentDirectory,
|
53
53
|
"Cannot clone #{new_resource} to #{new_resource.destination}, the enclosing directory #{parent_directory} does not exist")
|
54
54
|
a.whyrun("Directory #{parent_directory} does not exist, assuming it would have been created")
|
@@ -81,7 +81,7 @@ class Chef
|
|
81
81
|
|
82
82
|
action :sync, description: "Update the source to the specified version, or get a new clone or checkout. This action causes a hard reset of the index and working tree, discarding any uncommitted changes." do
|
83
83
|
assert_target_directory_valid!
|
84
|
-
if ::
|
84
|
+
if ::File.exist?(::File.join(new_resource.destination, ".svn"))
|
85
85
|
current_rev = find_current_revision
|
86
86
|
logger.trace "#{new_resource} current revision: #{current_rev} target revision: #{revision_int}"
|
87
87
|
unless current_revision_matches_target_revision?
|
@@ -134,7 +134,7 @@ class Chef
|
|
134
134
|
alias :revision_slug :revision_int
|
135
135
|
|
136
136
|
def find_current_revision
|
137
|
-
return nil unless ::
|
137
|
+
return nil unless ::File.exist?(::File.join(new_resource.destination, ".svn"))
|
138
138
|
|
139
139
|
command = scm(:info)
|
140
140
|
svn_info = shell_out!(command, **run_options(cwd: cwd, returns: [0, 1])).stdout
|
@@ -214,7 +214,7 @@ class Chef
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def target_dir_non_existent_or_empty?
|
217
|
-
!::
|
217
|
+
!::File.exist?(new_resource.destination) || Dir.entries(new_resource.destination).sort == [".", ".."]
|
218
218
|
end
|
219
219
|
|
220
220
|
def svn_binary
|
@@ -224,7 +224,7 @@ class Chef
|
|
224
224
|
|
225
225
|
def assert_target_directory_valid!
|
226
226
|
target_parent_directory = ::File.dirname(new_resource.destination)
|
227
|
-
unless ::
|
227
|
+
unless ::File.directory?(target_parent_directory)
|
228
228
|
msg = "Cannot clone #{new_resource} to #{new_resource.destination}, the enclosing directory #{target_parent_directory} does not exist"
|
229
229
|
raise Chef::Exceptions::MissingParentDirectory, msg
|
230
230
|
end
|
@@ -238,9 +238,9 @@ class Chef
|
|
238
238
|
require "etc" unless defined?(Etc)
|
239
239
|
case user
|
240
240
|
when Integer
|
241
|
-
|
241
|
+
Etc.getpwuid(user).dir
|
242
242
|
else
|
243
|
-
|
243
|
+
Etc.getpwnam(user.to_s).dir
|
244
244
|
end
|
245
245
|
end
|
246
246
|
end
|
@@ -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
|
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(::
|
38
|
+
current_resource.content(::File.read(unit_path)) if ::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 ::
|
89
|
+
if ::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
|
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"
|
24
|
+
provides :aix_user
|
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 ::
|
127
|
+
if ::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,19 +20,14 @@ 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
|
24
|
+
provides :user, os: "linux"
|
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
|
-
|
36
31
|
def compare_user
|
37
32
|
user_changed = super
|
38
33
|
|
@@ -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
|
26
|
+
provides :user, os: "freebsd"
|
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 ::
|
30
|
+
raise Chef::Exceptions::User, "Could not find binary /usr/sbin/pw for #{new_resource}" unless ::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
|
28
|
+
provides :user, os: %w{openindiana illumos omnios solaris2 smartos}
|
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 =
|
49
|
+
user = 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
|
-
::
|
125
|
+
::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
|
-
|
144
|
-
|
143
|
+
FileUtils.chown uid, gid, buffer.path
|
144
|
+
FileUtils.chmod mode, buffer.path
|
145
145
|
|
146
|
-
|
146
|
+
FileUtils.mv buffer.path, PASSWORD_FILE
|
147
147
|
end
|
148
148
|
|
149
149
|
def updated_password(entry)
|
@@ -85,7 +85,12 @@ class Chef
|
|
85
85
|
@net_user.update(**set_options)
|
86
86
|
end
|
87
87
|
|
88
|
+
def clear_account_rights(name)
|
89
|
+
Chef::ReservedNames::Win32::Security.clear_account_rights(name)
|
90
|
+
end
|
91
|
+
|
88
92
|
def remove_user
|
93
|
+
clear_account_rights(new_resource.username)
|
89
94
|
@net_user.delete
|
90
95
|
end
|
91
96
|
|