Check rc and print error message if any.
It is probably good to use stdout before printing a generic error message as well.
This commit is contained in:
parent
c46e030100
commit
1a8cdb5e3e
1 changed files with 9 additions and 1 deletions
|
@ -992,8 +992,16 @@ class OpenBsdService(Service):
|
||||||
if self.module.check_mode:
|
if self.module.check_mode:
|
||||||
self.module.exit_json(changed=True, msg="changing service enablement")
|
self.module.exit_json(changed=True, msg="changing service enablement")
|
||||||
|
|
||||||
# XXX check rc ?
|
|
||||||
rc, stdout, stderr = self.execute_command("%s %s" % (self.enable_cmd, action))
|
rc, stdout, stderr = self.execute_command("%s %s" % (self.enable_cmd, action))
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
self.changed = True
|
self.changed = True
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
Loading…
Reference in a new issue