test-module: check availability of special attrs
This commit is contained in:
parent
5d2927c9a0
commit
7231f7da84
2 changed files with 26 additions and 0 deletions
21
test/integration/targets/test_infra/library/test.py
Normal file
21
test/integration/targets/test_infra/library/test.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(),
|
||||||
|
)
|
||||||
|
result = {
|
||||||
|
'selinux_special_fs': module._selinux_special_fs,
|
||||||
|
'tmpdir': module._tmpdir,
|
||||||
|
'keep_remote_files': module._keep_remote_files,
|
||||||
|
'version': module.ansible_version,
|
||||||
|
}
|
||||||
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
|
@ -22,9 +22,14 @@ echo "ensure playbook output shows assert/fail works (True)"
|
||||||
echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
|
echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
|
||||||
echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
|
echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
# ensure test-module script works well
|
# ensure test-module script works well
|
||||||
PING_MODULE_PATH="$(pwd)/../../../../lib/ansible/modules/system/ping.py"
|
PING_MODULE_PATH="$(pwd)/../../../../lib/ansible/modules/system/ping.py"
|
||||||
../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)"
|
../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)"
|
||||||
|
|
||||||
|
# ensure module.ansible_version is defined when using test-module
|
||||||
|
../../../../hacking/test-module -m library/test.py -I ansible_python_interpreter="$(which python)" <<< '{"ANSIBLE_MODULE_ARGS": {}}'
|
||||||
|
|
||||||
# ensure exercising module code locally works
|
# ensure exercising module code locally works
|
||||||
python -m ansible.modules.files.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'
|
python -m ansible.modules.files.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'
|
||||||
|
|
Loading…
Reference in a new issue