Tweak error checking for "enabled" code.

Based on input from @jarmani:
* A return value of 2 now means a service does not exist. Instead of
  trying to handle the different meanings of rc after running "status",
  just look at stderr to know if something failed.
* Skip looking at stdout to make the code cleaner. Any errors should
  turn up on stderr.
reviewable/pr18780/r1
Patrik Lundin 10 years ago committed by Jonathan Armani
parent c6dd88c1d1
commit 5f37624eb4

@ -979,6 +979,9 @@ class OpenBsdService(Service):
rc, stdout, stderr = self.execute_command("%s %s %s" % (self.enable_cmd, 'status', self.name))
if stderr:
self.module.fail_json(msg=stderr)
if self.enable:
action = "enable %s flags %s" % (self.name, self.arguments)
args = self.arguments
@ -987,8 +990,6 @@ class OpenBsdService(Service):
else:
action = "disable %s" % self.name
if rc == 1:
if stderr:
self.module.fail_json(msg=stderr)
return
if self.module.check_mode:
@ -999,8 +1000,6 @@ class OpenBsdService(Service):
if rc != 0:
if stderr:
self.module.fail_json(msg=stderr)
elif stdout:
self.module.fail_json(msg=stdout)
else:
self.module.fail_json(msg="rcctl failed to modify service enablement")

Loading…
Cancel
Save