mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
fix tempating issues with no_log and loops (#44468)
* fix tempating issues with no_log and loops - task is no log if any item is - added test cases fixes #43294
This commit is contained in:
27
test/integration/targets/no_log/dynamic.yml
Normal file
27
test/integration/targets/no_log/dynamic.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
- name: test dynamic no log
|
||||
hosts: testhost
|
||||
gather_facts: no
|
||||
ignore_errors: yes
|
||||
tasks:
|
||||
- name: no loop, task fails, dynamic no_log
|
||||
debug:
|
||||
msg: "SHOW {{ var_does_not_exist }}"
|
||||
no_log: "{{ not (unsafe_show_logs|bool) }}"
|
||||
|
||||
- name: loop, task succeeds, dynamic does no_log
|
||||
debug:
|
||||
msg: "SHOW {{ item }}"
|
||||
loop:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
no_log: "{{ not (unsafe_show_logs|bool) }}"
|
||||
|
||||
- name: loop, task fails, dynamic no_log
|
||||
debug:
|
||||
msg: "SHOW {{ var_does_not_exist }}"
|
||||
loop:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
no_log: "{{ not (unsafe_show_logs|bool) }}"
|
||||
@@ -4,6 +4,12 @@ set -eux
|
||||
|
||||
# This test expects 7 loggable vars and 0 non-loggable ones.
|
||||
# If either mismatches it fails, run the ansible-playbook command to debug.
|
||||
|
||||
[ "$(ansible-playbook no_log_local.yml -i ../../inventory -vvvvv "$@" | awk \
|
||||
'BEGIN { logme = 0; nolog = 0; } /LOG_ME/ { logme += 1;} /DO_NOT_LOG/ { nolog += 1;} END { printf "%d/%d", logme, nolog; }')" = "26/0" ]
|
||||
|
||||
# deal with corner cases with no log and loops
|
||||
# no log enabled, should produce 6 censored messages
|
||||
[ "$(ansible-playbook dynamic.yml -i ../../inventory -vvvvv "$@" -e unsafe_show_logs=no|grep -c 'output has been hidden')" = "6" ]
|
||||
|
||||
# no log disabled, should produce 0 censored
|
||||
[ "$(ansible-playbook dynamic.yml -i ../../inventory -vvvvv "$@" -e unsafe_show_logs=yes|grep -c 'output has been hidden')" = "0" ]
|
||||
|
||||
Reference in New Issue
Block a user