Merge "Fix no_log bug with result lists"

This commit is contained in:
Zuul 2018-03-15 17:15:37 +00:00 committed by Gerrit Code Review
commit 7510cf2973
2 changed files with 36 additions and 3 deletions

View File

@ -9,3 +9,31 @@
msg: setec astronomy
no_log: true
with_sequence: start=0 end=2
# The next section tests that the results object is still usable
# by other tasks even if we're censoring the output in zuul_json.
- name: Find files
block:
- name: Create file
copy:
content: ""
dest: "{{ ansible_user_dir }}/setec_astronomy"
- name: Find files
find:
path: "{{ ansible_user_dir }}"
file_type: any
register: src_files
- name: Dereference files
stat:
path: "{{ item.path }}"
with_items: "{{ src_files.files }}"
register: src_paths
- name: Print path
debug:
msg: "{{ item.stat.path }}"
when:
- item.stat.isreg
with_items: "{{ src_paths.results }}"
no_log: true

View File

@ -22,15 +22,16 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import copy
import json
import os
from ansible.plugins.callback import CallbackBase
try:
# It's here in 2.4
# It's here in 2.3
from ansible.vars import strip_internal_keys
except ImportError:
# It's here in 2.3
# It's here in 2.4
from ansible.vars.manager import strip_internal_keys
from zuul.ansible import logconfig
@ -120,7 +121,11 @@ class CallbackModule(CallbackBase):
censored="the output has been hidden due to the fact that"
" 'no_log: true' was specified for this result")
else:
clean_result = strip_internal_keys(result._result)
# strip_internal_keys makes a deep copy of dict items, but
# not lists, so we need to create our own complete deep
# copy first so we don't modify the original.
myresult = copy.deepcopy(result._result)
clean_result = strip_internal_keys(myresult)
for index, item_result in enumerate(
clean_result.get('results', [])):