mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
system/service module initctl location usage (#19712)
* Call initctl version based on initctl's retrieved location * Remove the use of start/stop/restart in favor of initctl * Provide correct argument order for initctl usage
This commit is contained in:
parent
3f0c47196e
commit
025b52938e
1 changed files with 9 additions and 6 deletions
|
@ -490,7 +490,7 @@ class LinuxService(Service):
|
|||
self.upstart_version = LooseVersion('0.0.0')
|
||||
try:
|
||||
version_re = re.compile(r'\(upstart (.*)\)')
|
||||
rc,stdout,stderr = self.module.run_command('initctl version')
|
||||
rc,stdout,stderr = self.module.run_command('%s version' % location['initctl'])
|
||||
if rc == 0:
|
||||
res = version_re.search(stdout)
|
||||
if res:
|
||||
|
@ -498,9 +498,7 @@ class LinuxService(Service):
|
|||
except:
|
||||
pass # we'll use the default of 0.0.0
|
||||
|
||||
if location.get('start', False):
|
||||
# upstart -- rather than being managed by one command, start/stop/restart are actual commands
|
||||
self.svc_cmd = ''
|
||||
self.svc_cmd = location['initctl']
|
||||
|
||||
elif location.get('rc-service', False):
|
||||
# service is managed by OpenRC
|
||||
|
@ -922,8 +920,13 @@ class LinuxService(Service):
|
|||
arguments = self.arguments
|
||||
if self.svc_cmd:
|
||||
if not self.svc_cmd.endswith("systemctl"):
|
||||
# SysV and OpenRC take the form <cmd> <name> <action>
|
||||
svc_cmd = "%s %s" % (self.svc_cmd, self.name)
|
||||
if self.svc_cmd.endswith("initctl"):
|
||||
# initctl commands take the form <cmd> <action> <name>
|
||||
svc_cmd = self.svc_cmd
|
||||
arguments = "%s %s" % (self.name, arguments)
|
||||
else:
|
||||
# SysV and OpenRC take the form <cmd> <name> <action>
|
||||
svc_cmd = "%s %s" % (self.svc_cmd, self.name)
|
||||
else:
|
||||
# systemd commands take the form <cmd> <action> <name>
|
||||
svc_cmd = self.svc_cmd
|
||||
|
|
Loading…
Reference in a new issue