summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-02-03 14:57:22 -0800
committerGitHub <noreply@github.com>2021-02-03 14:57:22 -0800
commit3d586a3b038db3c7cba86b7393c0d3b7e0840161 (patch)
tree4cd5a124456a222938ddfc07cc6d15b70b923e6b /lib/chef
parentef07092cade60b92914a128a1065bc87909af465 (diff)
parente89693875cef26ba22941fd8b042dcbe758e70e3 (diff)
downloadchef-3d586a3b038db3c7cba86b7393c0d3b7e0840161.tar.gz
Merge pull request #10976 from joshuamiller01/handle_sysv_compat_case_for_systemd_service_enabled
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/provider/service/systemd.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index 9b0cf3abd8..f8fac18bc3 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -202,6 +202,11 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
end
def is_enabled?
+ # if the service is in sysv compat mode, shellout to determine if enabled
+ if systemd_service_status["UnitFileState"] == "bad"
+ options, args = get_systemctl_options_args
+ return shell_out(systemctl_path, args, "is-enabled", new_resource.service_name, "--quiet", **options).exitstatus == 0
+ end
# See https://github.com/systemd/systemd/blob/master/src/systemctl/systemctl-is-enabled.c
# Note: enabled-runtime is excluded because this is volatile, and the state of enabled-runtime
# specifically means that the service is not enabled