diff options
author | Joshua Miller <joshmiller@fb.com> | 2021-02-02 20:22:09 -0500 |
---|---|---|
committer | Joshua Miller <joshmiller@fb.com> | 2021-02-02 20:34:30 -0500 |
commit | e89693875cef26ba22941fd8b042dcbe758e70e3 (patch) | |
tree | 3c9ab667b6a4357acfe09898495abd601f7b6519 /lib/chef/provider | |
parent | 2a84adbe13744e4fda11a10c9cb8ef2691acb692 (diff) | |
download | chef-e89693875cef26ba22941fd8b042dcbe758e70e3.tar.gz |
Handle sysv compat mode when checking enabled status for systemd service
Signed-off-by: Joshua Miller <joshmiller@fb.com>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/service/systemd.rb | 5 |
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 |