Do not add connection vars to the output results (#70853) (#70855)

* Do not add connection vars to the output results

* Also revert the delgated scenario JIC

* Added regression test

(cherry picked from commit 5e1a968983)
pull/70857/head
Jordan Borean 4 years ago committed by GitHub
parent 6dd05dfe67
commit e9c9c02e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Stop adding the connection variables to the output results

@ -798,13 +798,8 @@ class TaskExecutor:
# also now add conneciton vars results when delegating
if self._task.delegate_to:
result["_ansible_delegated_vars"] = {'ansible_delegated_host': self._task.delegate_to}
for k in plugin_vars + RETURN_VARS:
if k in cvars and cvars[k] is not None:
result["_ansible_delegated_vars"][k] = cvars[k]
else:
for k in plugin_vars + RETURN_VARS:
if k in cvars and cvars[k] is not None:
result[k] = cvars[k]
for k in plugin_vars:
result["_ansible_delegated_vars"][k] = cvars.get(k)
# and return
display.debug("attempt loop complete, returning result")

@ -8,3 +8,16 @@ set -eux
ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
LC_ALL=C LANG=C ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
# Check that connection vars do not appear in the output
# https://github.com/ansible/ansible/pull/70853
trap "rm out.txt" EXIT
ansible all -i "${INVENTORY}" -m set_fact -a "testing=value" -v | tee out.txt
if grep 'ansible_host' out.txt
then
echo "FAILURE: Connection vars in output"
exit 1
else
echo "SUCCESS: Connection vars not found"
fi

Loading…
Cancel
Save