Commit b2741f45 by James Cammarata

Fixes to the service module for Ubuntu 12.04 (LTS)

Fixes #3615
Fixes #3572
parent 9a3a3e64
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment