Fixes to the service module for Ubuntu 12.04 (LTS)
Fixes #3615 Fixes #3572
This commit is contained in:
parent
9a3a3e648b
commit
b2741f451e
1 changed files with 18 additions and 1 deletions
|
@ -576,6 +576,7 @@ class LinuxService(Service):
|
|||
action = 'enable'
|
||||
else:
|
||||
action = 'disable'
|
||||
|
||||
(rc, out, err) = self.execute_command("%s -n %s %s" \
|
||||
% (self.enable_cmd, self.name, action))
|
||||
self.changed = False
|
||||
|
@ -583,6 +584,12 @@ class LinuxService(Service):
|
|||
if line.startswith('rename'):
|
||||
self.changed = True
|
||||
break
|
||||
elif self.enable and line.find('do not exist') != -1:
|
||||
self.changed = True
|
||||
break
|
||||
elif not self.enable and line.find('already exist') != -1:
|
||||
self.changed = True
|
||||
break
|
||||
|
||||
if self.module.check_mode:
|
||||
self.module.exit_json(changed=self.changed)
|
||||
|
@ -590,7 +597,17 @@ class LinuxService(Service):
|
|||
if not self.changed:
|
||||
return
|
||||
|
||||
return self.execute_command("%s %s %s" % (self.enable_cmd, self.name, action))
|
||||
if self.enable:
|
||||
# make sure the init.d symlinks are created
|
||||
# otherwise enable might not work
|
||||
(rc, out, err) = self.execute_command("%s %s defaults" \
|
||||
% (self.enable_cmd, self.name))
|
||||
if rc != 0:
|
||||
return (rc, out, err)
|
||||
|
||||
return self.execute_command("%s %s enable" % (self.enable_cmd, self.name))
|
||||
else:
|
||||
return self.execute_command("%s -f %s remove" % (self.enable_cmd, self.name))
|
||||
|
||||
# we change argument depending on real binary used:
|
||||
# - update-rc.d and systemctl wants enable/disable
|
||||
|
|
Loading…
Reference in a new issue