Debian Codegraph @

test/integration/targets/callback_results/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 # we are looking to verify the callback for v2_retry_runner gets a correct task name, include
6 # if the value needs templating based on results of previous tasks
7 OUTFILE="callback_output_copy.out"
8 trap 'rm -rf "${OUTFILE}"' EXIT
9
10 # test task retry name
11 EXPECTED_REGEX="^.*TASK.*18236 callback task template fix OUTPUT 2"
12 ansible-playbook "$@" -i ../../inventory task_name.yml | tee "${OUTFILE}"
13 echo "Grepping for ${EXPECTED_REGEX} in stdout."
14 grep -e "${EXPECTED_REGEX}" "${OUTFILE}"
15
16 # check variables are interpolated in 'started'
17 UNTEMPLATED_STARTED="^.*\[started .*{{.*}}.*$"
18 echo "Checking we dont have untemplated started in stdout."
19 if grep -e "${UNTEMPLATED_STARTED}" "${OUTFILE}"; then
20 exit 1
21 fi
22
23 # test connection tracking
24 ANSIBLE_CALLBACKS_ENABLED=track_connections ansible-playbook "$@" -i ../../inventory connection_name.yml | tee "${OUTFILE}"
25 grep "FOUND EXPECTED EVENTS" "${OUTFILE}"
26
27 # test configuring display_skipped_hosts using --extra-vars
28 hide_skipped="$(ansible-playbook skip_hosts.yml -v --extra-vars @./callback_vars.yml "$@")"
29 if [[ "$hide_skipped" == *skip_reason* ]]; then
30 echo "Failed to configure display_skipped_hosts (false)"
31 exit 1
32 fi
33 include_skipped="$(ansible-playbook skip_hosts.yml -v --extra-vars @./callback_vars.yml --extra-vars indirect_extra=true "$@")"
34 if [[ "$include_skipped" != *skip_reason* ]]; then
35 echo "Failed to configure display_skipped_hosts (true)"
36 exit 1
37 fi
38 include_skipped="$(ansible-playbook skip_hosts.yml -v --extra-vars @./callback_vars.yml --extra-vars indirect_extra='{{ omit }}' "$@")"
39 if [[ "$include_skipped" != *skip_reason* ]]; then
40 echo "Failed to omit display_skipped_hosts (default true)"
41 exit 1
42 fi