From 336b3762b23a64e355cfa3efba11ddf5bdd7f0d8 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 7 Jun 2018 17:38:20 -0400 Subject: [PATCH] no_log even when task_result doesn't provide key - now also checks task property - added reproducer to tests for unreachable status on item loop --- lib/ansible/executor/task_result.py | 2 +- .../targets/no_log/no_log_local.yml | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py index 8d2eddf803a..f7e95d4c821 100644 --- a/lib/ansible/executor/task_result.py +++ b/lib/ansible/executor/task_result.py @@ -112,7 +112,7 @@ class TaskResult: 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: diff --git a/test/integration/targets/no_log/no_log_local.yml b/test/integration/targets/no_log/no_log_local.yml index bf02468f224..69a55fdb4fe 100644 --- a/test/integration/targets/no_log/no_log_local.yml +++ b/test/integration/targets/no_log/no_log_local.yml @@ -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