Skip to content

Commit

Permalink
no_log even when task_result doesn't provide key
Browse files Browse the repository at this point in the history
 - now also checks task property
 - added reproducer to tests for unreachable status on item loop
  • Loading branch information
bcoca authored and abadger committed Jun 12, 2018
1 parent 40d2df0 commit 336b376
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ansible/executor/task_result.py
Expand Up @@ -112,7 +112,7 @@ def clean_copy(self):
else:
ignore = _IGNORE

if self._result.get('_ansible_no_log', False):
if self._task.no_log or self._result.get('_ansible_no_log', False):
x = {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"}
for preserve in _PRESERVE:
if preserve in self._result:
Expand Down
27 changes: 27 additions & 0 deletions test/integration/targets/no_log/no_log_local.yml
Expand Up @@ -63,3 +63,30 @@
- name: args should be logged when task-level no_log overrides play-level
shell: echo "LOG_ME_OVERRIDE"
no_log: false

- name: Add a fake host for next play
add_host:
hostname: fake

- name: use 'fake' unreachable host to force unreachable error
hosts: fake
gather_facts: no
connection: ssh
tasks:
- name: Fail to run a lineinfile task
vars:
logins:
- machine: foo
login: bar
password: DO_NOT_LOG_UNREACHABLE_ITEM
- machine: two
login: three
password: DO_NOT_LOG_UNREACHABLE_ITEM
lineinfile:
path: /dev/null
mode: 0600
create: true
insertafter: EOF
line: "machine {{ item.machine }} login {{ item.login }} password {{ item.password }}"
loop: "{{ logins }}"
no_log: true

0 comments on commit 336b376

Please sign in to comment.