Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear 'connection related' plugin vars for next loop iteration #59024

Merged
merged 3 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Do not re-use remote_user from previous loop iteration (https://github.com/ansible/ansible/issues/58876)
13 changes: 13 additions & 0 deletions lib/ansible/executor/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,19 @@ def _run_loop(self, items):
results.append(res)
del task_vars[loop_var]

# clear 'connection related' plugin variables for next iteration
clear_plugins = {
'connection': self._connection._load_name,
'shell': self._connection._shell._load_name
}
if self._play_context.become:
clear_plugins['become'] = self._get_become(self._play_context.become_method)._load_name

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:
del task_vars[var]

mkrizek marked this conversation as resolved.
Show resolved Hide resolved
bcoca marked this conversation as resolved.
Show resolved Hide resolved
self._task.no_log = no_log

return results
Expand Down