Return extra information from service module

If _do_enable() is run and returns rc == 0, set changed=True
Add enabled and state to result if they are supplied when the module is
run.
This commit is contained in:
Stephen Fromm 2012-08-01 14:58:32 -07:00
parent 64374ed7f2
commit 85f628ae26

View file

@ -158,6 +158,8 @@ def main():
if module.params['enabled']:
rc_enable, out_enable, err_enable = _do_enable(name, enable)
if rc == 0:
changed = True
rc += rc_enable
out += out_enable
err += err_enable
@ -201,6 +203,10 @@ def main():
module.fail_json(msg=err)
result = {"changed": changed}
if module.params['enabled']:
result['enabled'] = module.params['enabled']
if state:
result['state'] = state
rc, stdout, stderr = _run("%s %s status" % (SERVICE, name))
module.exit_json(**result);