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

Better detection of whether a service is managed by systemd or not.

This commit is contained in:
Michael DeHaan 2013-02-24 11:58:05 -05:00
parent 596c98320a
commit 3c40ce5700

View file

@ -364,8 +364,12 @@ class LinuxService(Service):
# service is managed by upstart
self.enable_cmd = location['update-rc.d']
elif location.get('systemctl', None):
# service is managed by systemd
self.enable_cmd = location['systemctl']
# verify service is managed by systemd
rc, out, err = self.execute_command("%s --all" % (location['systemctl']))
look_for = "%s.service" % self.name
if look_for in out:
self.enable_cmd = location['systemctl']
# Locate a tool for runtime service management (start, stop etc.)
self.svc_cmd = ''
@ -447,7 +451,7 @@ class LinuxService(Service):
def service_enable(self):
if self.enable_cmd is None:
self.module.fail_json(msg='unable to find enable binary')
self.module.fail_json(msg='service name not recognized')
# FIXME: we use chkconfig or systemctl
# to decide whether to run the command here but need something