Preserve original variables when using a loop (#59426)

Fixes #59414
This commit is contained in:
Martin Krizek 2019-07-24 11:35:14 +02:00 committed by GitHub
parent 5a7f579d86
commit 1010363c0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -423,7 +423,7 @@ class TaskExecutor:
for plugin_type, plugin_name in iteritems(clear_plugins):
for var in C.config.get_plugin_vars(plugin_type, plugin_name):
if var in task_vars:
if var in task_vars and var not in self._job_vars:
del task_vars[var]
self._task.no_log = no_log

View file

@ -344,3 +344,18 @@
loop_var: "{{ loop_var_name }}"
vars:
loop_var_name: templated_loop_var_name
# https://github.com/ansible/ansible/issues/59414
- name: Test preserving original connection related vars
debug:
var: ansible_remote_tmp
vars:
ansible_remote_tmp: /tmp/test1
with_items:
- 1
- 2
register: loop_out
- assert:
that:
- loop_out['results'][1]['ansible_remote_tmp'] == '/tmp/test1'