mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-04 07:19:10 -07:00
Make sure PlayContext is copied when iterating in a with_ loop
This commit is contained in:
parent
c16961db60
commit
8774ff5f57
1 changed files with 5 additions and 2 deletions
|
@ -188,15 +188,18 @@ class TaskExecutor:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tmp_task = self._task.copy()
|
tmp_task = self._task.copy()
|
||||||
|
tmp_play_context = self._play_context.copy()
|
||||||
except AnsibleParserError as e:
|
except AnsibleParserError as e:
|
||||||
results.append(dict(failed=True, msg=str(e)))
|
results.append(dict(failed=True, msg=str(e)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# now we swap the internal task with the copy, execute,
|
# now we swap the internal task and play context with their copies,
|
||||||
# and swap them back so we can do the next iteration cleanly
|
# execute, and swap them back so we can do the next iteration cleanly
|
||||||
(self._task, tmp_task) = (tmp_task, self._task)
|
(self._task, tmp_task) = (tmp_task, self._task)
|
||||||
|
(self._play_context, tmp_play_context) = (tmp_play_context, self._play_context)
|
||||||
res = self._execute(variables=task_vars)
|
res = self._execute(variables=task_vars)
|
||||||
(self._task, tmp_task) = (tmp_task, self._task)
|
(self._task, tmp_task) = (tmp_task, self._task)
|
||||||
|
(self._play_context, tmp_play_context) = (tmp_play_context, self._play_context)
|
||||||
|
|
||||||
# now update the result with the item info, and append the result
|
# now update the result with the item info, and append the result
|
||||||
# to the list of results
|
# to the list of results
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue