diff options
author | Matt Clay <matt@mystile.com> | 2016-10-13 18:09:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-13 18:09:25 +0200 |
commit | 75e4645ee70434e2706845ca9fe96d5823616eea (patch) | |
tree | 360f27f11eeb33ba993ae3f30764589b3981e99c /test/integration/targets/async/library | |
parent | Split out var_blending test into targets dir. (#17996) (diff) | |
download | ansible-75e4645ee70434e2706845ca9fe96d5823616eea.tar.xz ansible-75e4645ee70434e2706845ca9fe96d5823616eea.zip |
Migrate Linux CI roles to test targets. (#17997)
Diffstat (limited to 'test/integration/targets/async/library')
-rw-r--r-- | test/integration/targets/async/library/async_test.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/integration/targets/async/library/async_test.py b/test/integration/targets/async/library/async_test.py new file mode 100644 index 0000000000..5c77a27c8d --- /dev/null +++ b/test/integration/targets/async/library/async_test.py @@ -0,0 +1,39 @@ +import sys +import json +from ansible.module_utils.basic import AnsibleModule + +def main(): + if "--interactive" in sys.argv: + import ansible.module_utils.basic + ansible.module_utils.basic._ANSIBLE_ARGS = json.dumps(dict( + ANSIBLE_MODULE_ARGS=dict( + fail_mode="graceful" + ) + )) + + module = AnsibleModule(argument_spec = dict( + fail_mode = dict(type='list', default=['success']) + ) + ) + + result = dict(changed=True) + + fail_mode = module.params['fail_mode'] + + try: + if 'leading_junk' in fail_mode: + print("leading junk before module output") + + if 'graceful' in fail_mode: + module.fail_json(msg="failed gracefully") + + if 'exception' in fail_mode: + raise Exception('failing via exception') + + module.exit_json(**result) + + finally: + if 'trailing_junk' in fail_mode: + print("trailing junk after module output") + +main()
\ No newline at end of file |