From e84931b9c24e8a358933dd2dd51c63bf06f12cfc Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 24 Jul 2018 08:54:58 -0400 Subject: [PATCH] don't assume all delegation subkeys exist (#43032) * don't assume all delegation subkeys exist fixes #43026 * add tests (cherry picked from commit cdc762dd9e09780869d26ec409061b6bd8657be9) --- lib/ansible/executor/task_result.py | 3 ++- .../targets/delegate_to/delegate_and_nolog.yml | 8 ++++++++ test/integration/targets/delegate_to/runme.sh | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/integration/targets/delegate_to/delegate_and_nolog.yml diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py index cb718b9e0df..149aa5b68c3 100644 --- a/lib/ansible/executor/task_result.py +++ b/lib/ansible/executor/task_result.py @@ -124,7 +124,8 @@ class TaskResult: if sub in self._result: x[sub] = {} for key in _SUB_PRESERVE[sub]: - x[sub][key] = self._result[sub][key] + if key in self._result[sub]: + x[sub][key] = self._result[sub][key] result._result = x elif self._result: diff --git a/test/integration/targets/delegate_to/delegate_and_nolog.yml b/test/integration/targets/delegate_to/delegate_and_nolog.yml new file mode 100644 index 00000000000..d8ed64fe2fb --- /dev/null +++ b/test/integration/targets/delegate_to/delegate_and_nolog.yml @@ -0,0 +1,8 @@ +- hosts: testhost + gather_facts: false + tasks: + - name: no log filtering caused delegation to fail https://github.com/ansible/ansible/issues/43026 + become: False + no_log: true + debug: + delegate_to: localhost diff --git a/test/integration/targets/delegate_to/runme.sh b/test/integration/targets/delegate_to/runme.sh index 3d2873ee447..c7c64683c13 100755 --- a/test/integration/targets/delegate_to/runme.sh +++ b/test/integration/targets/delegate_to/runme.sh @@ -6,3 +6,5 @@ ANSIBLE_SSH_ARGS='-C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHos ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook test_delegate_to.yml -i ../../inventory -v "$@" ansible-playbook test_loop_control.yml -v "$@" + +ansible-playbook delegate_and_nolog.yml -v "$@"