2016-10-12 21:57:53 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -ux
|
|
|
|
|
|
|
|
# ensure fail/assert work locally and can stop execution with non-zero exit code
|
|
|
|
PB_OUT=$(ansible-playbook -i inventory.local test_test_infra.yml)
|
|
|
|
APB_RC=$?
|
|
|
|
echo "$PB_OUT"
|
|
|
|
echo "rc was $APB_RC (must be non-zero)"
|
2017-10-17 16:37:05 +00:00
|
|
|
[ ${APB_RC} -ne 0 ]
|
2016-10-12 21:57:53 +00:00
|
|
|
echo "ensure playbook output shows assert/fail works (True)"
|
|
|
|
echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
|
|
|
|
echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
|
|
|
|
|
|
|
|
# ensure we work using all specified test args, overridden inventory, etc
|
|
|
|
PB_OUT=$(ansible-playbook -i ../../inventory test_test_infra.yml "$@")
|
|
|
|
APB_RC=$?
|
|
|
|
echo "$PB_OUT"
|
|
|
|
echo "rc was $APB_RC (must be non-zero)"
|
2017-10-17 16:37:05 +00:00
|
|
|
[ ${APB_RC} -ne 0 ]
|
2016-10-12 21:57:53 +00:00
|
|
|
echo "ensure playbook output shows assert/fail works (True)"
|
|
|
|
echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
|
|
|
|
echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
|
2018-06-01 19:02:56 +00:00
|
|
|
|
2018-10-07 23:46:49 +00:00
|
|
|
set -e
|
|
|
|
|
2018-06-01 19:02:56 +00:00
|
|
|
# ensure test-module script works well
|
2019-01-17 06:34:09 +00:00
|
|
|
PING_MODULE_PATH="../../../../lib/ansible/modules/system/ping.py"
|
2018-06-01 19:02:56 +00:00
|
|
|
../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)"
|
2018-09-19 14:10:55 +00:00
|
|
|
|
2018-10-07 23:46:49 +00:00
|
|
|
# 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": {}}'
|
|
|
|
|
2018-09-19 14:10:55 +00:00
|
|
|
# ensure exercising module code locally works
|
|
|
|
python -m ansible.modules.files.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'
|