mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Ensure exit_json returns failed = False
This is required for modules that may return a non-zero `rc` value for a successful run, similar to #24865 for Windows fixing **win_chocolatey**. We also disable the dependency on `rc` value only, even if `failed` was set. Adapted unit and integration tests to the new scheme. Updated raw, shell, script, expect to take `rc` into account.
This commit is contained in:
parent
1f78715848
commit
0e160d5c7e
17 changed files with 68 additions and 56 deletions
|
@ -221,7 +221,7 @@ def main():
|
|||
if out is None:
|
||||
out = ''
|
||||
|
||||
ret = dict(
|
||||
result = dict(
|
||||
cmd=args,
|
||||
stdout=out.rstrip('\r\n'),
|
||||
rc=rc,
|
||||
|
@ -231,11 +231,12 @@ def main():
|
|||
changed=True,
|
||||
)
|
||||
|
||||
if rc is not None:
|
||||
module.exit_json(**ret)
|
||||
else:
|
||||
ret['msg'] = 'command exceeded timeout'
|
||||
module.fail_json(**ret)
|
||||
if rc is None:
|
||||
module.fail_json(msg='command exceeded timeout', **result)
|
||||
elif rc != 0:
|
||||
module.fail_json(msg='non-zero return code', **result)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue