Debian Codegraph @

test/integration/targets/no_log/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux -o pipefail
4
5 # test was originally written to assume invocation was always injected
6 export ANSIBLE_INJECT_INVOCATION=1
7
8 # ensure _ansible_no_log returned by actions is actually respected
9 ansible-playbook ansible_no_log_in_result.yml -vvvvv > "${OUTPUT_DIR}/output.log" 2> /dev/null
10
11 [ "$(grep -c "action result should be masked" "${OUTPUT_DIR}/output.log")" = "0" ]
12 [ "$(grep -c "the output has been hidden" "${OUTPUT_DIR}/output.log")" = "4" ]
13
14 # This test expects 7 loggable vars and 0 non-loggable ones.
15 # If either mismatches it fails, run the ansible-playbook command to debug.
16 [ "$(ansible-playbook no_log_local.yml -i ../../inventory -vvvvv "$@" | awk \
17 'BEGIN { logme = 0; nolog = 0; } /LOG_ME/ { logme += 1;} /DO_NOT_LOG/ { nolog += 1;} END { printf "%d/%d", logme, nolog; }')" = "26/0" ]
18
19 # deal with corner cases with no log and loops
20 # no log enabled, should produce 6 censored messages
21 [ "$(ansible-playbook dynamic.yml -i ../../inventory -vvvvv "$@" -e unsafe_show_logs=no|grep -c 'output has been hidden')" = "7" ]
22
23 # no log disabled, should produce 0 censored
24 [ "$(ansible-playbook dynamic.yml -i ../../inventory -vvvvv "$@" -e unsafe_show_logs=yes|grep -c 'output has been hidden')" = "0" ]
25
26 # test no log for sub options
27 [ "$(ansible-playbook no_log_suboptions.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'SECRET')" = "0" ]
28
29 # test invalid data passed to a suboption
30 [ "$(ansible-playbook no_log_suboptions_invalid.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'SECRET')" = "0" ]
31
32 # test variations on ANSIBLE_NO_LOG
33 [ "$(ansible-playbook no_log_config.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'the output has been hidden')" = "1" ]
34 [ "$(ANSIBLE_NO_LOG=0 ansible-playbook no_log_config.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'the output has been hidden')" = "1" ]
35 [ "$(ANSIBLE_NO_LOG=1 ansible-playbook no_log_config.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'the output has been hidden')" = "5" ]
36
37 # Ensure module no_log masking handles secrets that are substrings of other secrets correctly
38 [ "$(ansible-playbook sub_masking.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'SEC')" = "0" ]