mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Various small fixes to boolean usage, using module.params.get and default values
This commit is contained in:
@@ -68,13 +68,17 @@ def main():
|
||||
)
|
||||
)
|
||||
|
||||
if module.params['fail'] in BOOLEANS_TRUE and module.params['rc'] == 0:
|
||||
module.params['rc'] = 1
|
||||
fail = module.boolean(module.params.get('fail'))
|
||||
msg = module.params.get('msg')
|
||||
rc = module.params.get('rc')
|
||||
|
||||
if module.params['fail'] in BOOLEANS_TRUE:
|
||||
module.fail_json(rc=module.params['rc'], msg=module.params['msg'])
|
||||
if fail and rc == 0:
|
||||
rc = 1
|
||||
|
||||
if fail:
|
||||
module.fail_json(rc=rc, msg=msg)
|
||||
else:
|
||||
module.exit_json(msg=module.params['msg'])
|
||||
module.exit_json(msg=msg)
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
||||
|
||||
Reference in New Issue
Block a user