1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Check for systemd ownership of a service even if an init.d script exists

Also slight modification to the error message in the earlier commit that
modified the update-rc.d detection portion of the code

Fixes #3474
This commit is contained in:
James Cammarata 2013-09-10 19:27:54 -05:00
parent 7c8aa669cf
commit 9a3a3e648b

View file

@ -407,6 +407,10 @@ class LinuxService(Service):
# Locate a tool for enable options
if location.get('chkconfig', None) and os.path.exists("/etc/init.d/%s" % self.name):
if check_systemd(self.name):
# service is managed by systemd
self.enable_cmd = location['systemctl']
else:
# we are using a standard SysV service
self.enable_cmd = location['chkconfig']
elif location.get('update-rc.d', None):
@ -420,7 +424,7 @@ class LinuxService(Service):
# service is managed by with SysV init scripts, but with update-rc.d
self.enable_cmd = location['update-rc.d']
else:
self.module.fail_json(msg="update-rc.d found but couldn't determine how the service is managed")
self.module.fail_json(msg="service not found: %s" % self.name)
elif location.get('rc-service', None) and not location.get('systemctl', None):
# service is managed by OpenRC
self.svc_cmd = location['rc-service']