Debian Codegraph @

test/integration/targets/infra/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -ux
4
5 # ensure fail/assert work locally and can stop execution with non-zero exit code
6 PB_OUT=$(ansible-playbook -i inventory.local test_test_infra.yml)
7 APB_RC=$?
8 echo "$PB_OUT"
9 echo "rc was $APB_RC (must be non-zero)"
10 [ ${APB_RC} -ne 0 ]
11 echo "ensure playbook output shows assert/fail works (True)"
12 echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
13 echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
14
15 # ensure we work using all specified test args, overridden inventory, etc
16 PB_OUT=$(ansible-playbook -i ../../inventory test_test_infra.yml "$@")
17 APB_RC=$?
18 echo "$PB_OUT"
19 echo "rc was $APB_RC (must be non-zero)"
20 [ ${APB_RC} -ne 0 ]
21 echo "ensure playbook output shows assert/fail works (True)"
22 echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
23 echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
24
25 set -e
26
27 PING_MODULE_PATH="../../../../lib/ansible/modules/ping.py"
28
29 # ensure test-module.py script works without passing Python interpreter path
30 ../../../../hacking/test-module.py -m "$PING_MODULE_PATH"
31
32 # ensure test-module.py script works well
33 ../../../../hacking/test-module.py -m "$PING_MODULE_PATH" -I ansible_python_interpreter="${ANSIBLE_TEST_PYTHON_INTERPRETER}"
34
35 # ensure module.ansible_version is defined when using test-module.py
36 ../../../../hacking/test-module.py -m library/test.py -I ansible_python_interpreter="${ANSIBLE_TEST_PYTHON_INTERPRETER}" <<< '{"ANSIBLE_MODULE_ARGS": {}}'
37
38 # ensure exercising module code locally works
39 python -m ansible.modules.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'