Return correct value for services that must be enabled in Systemd, not in SysV

This fixes situations, when a server switched from SysV to Systemd.
SysV symlinks are still in place and Salt incorrectly determines, that
service is already enabled.

For example:
~$ salt-call --local service.enabled spamassassin
[INFO    ] Executing command 'systemctl is-enabled spamassassin.service'
[INFO    ] Executing command 'runlevel' in directory '/root'
local:
    True

However:

~$ systemctl is-enabled spamassassin.service
disabled

~$ find /etc/rc*.d/ -name
'*spamassassin'
/etc/rc0.d/K02spamassassin
/etc/rc1.d/K02spamassassin
/etc/rc2.d/S02spamassassin
/etc/rc3.d/S02spamassassin
/etc/rc4.d/S02spamassassin
/etc/rc5.d/S02spamassassin
/etc/rc6.d/K02spamassassin
This commit is contained in:
Mikhael A 2016-03-04 14:18:08 +03:00 committed by rallytime
parent bd0496eef5
commit 45d563d5ac

View file

@ -779,9 +779,11 @@ def enabled(name, **kwargs): # pylint: disable=unused-argument
# string will be non-empty.
if bool(__salt__['cmd.run'](cmd, python_shell=False)):
return True
else:
elif name in _get_sysv_services():
return _sysv_enabled(name)
return False
def disabled(name):
'''