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

* Do not add connection vars to the output results

* Also revert the delgated scenario JIC

* Added regression test
pull/70866/head
Jordan Borean 4 years ago committed by GitHub
parent 7a42d27462
commit 5e1a968983
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

@ -707,13 +707,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