Debian Codegraph @

test/integration/targets/ansible_log/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 export ANSIBLE_DEPRECATION_WARNINGS=1 # re-enable deprecation warnings, since this test is looking for one
6
7 ALOG=${OUTPUT_DIR}/ansible_log_test.log
8
9 # no log enabled
10 ansible-playbook logit.yml
11 # ensure file is not created
12 [ ! -f "${ALOG}" ]
13
14 # log enabled
15 ANSIBLE_LOG_PATH=${ALOG} ansible-playbook logit.yml
16 # ensure log file is created
17 [ -f "${ALOG}" ]
18
19 # Ensure tasks and log levels appear
20 grep -q '\[normal task\]' "${ALOG}"
21 grep -q 'INFO| TASK \[force warning\]' "${ALOG}"
22 grep -q 'INFO| \[DEPRECATION WARNING\]: Conditionals should not be surrounded by templating delimiters' "${ALOG}"
23 rm "${ALOG}"
24
25 # inline grep should fail if EXEC was present
26 set +e
27 ANSIBLE_LOG_PATH=${ALOG} ANSIBLE_LOG_VERBOSITY=3 ansible-playbook -v logit.yml | tee /dev/stderr | grep -q EXEC
28 rc=$?
29 set -e
30 if [ "$rc" == "0" ]; then
31 false # fail if we found EXEC in stdout
32 fi
33 grep -q EXEC "${ALOG}"
34
35 # Test that setting verbosity with no log won't crash
36 ANSIBLE_LOG_VERBOSITY=2 ansible-playbook logit.yml