Fix name parameter templating in include_role module (#36372)
An IncludedFile() object built using the original_task will have its _task bound to the original_task. The iterative reassignment of original_task._role_name during with_item loops leaves all returned included_files with the same ._task._role_name (the final name from the with_items list). This commit builds IncludedFile() objects from an original_task.copy() to avoid the problematic binding.
This commit is contained in:
parent
6c3e565ba3
commit
54e70fc783
1 changed files with 5 additions and 4 deletions
|
@ -146,13 +146,14 @@ class IncludedFile:
|
|||
if role_name is not None:
|
||||
role_name = templar.template(role_name)
|
||||
|
||||
original_task._role_name = role_name
|
||||
for from_arg in original_task.FROM_ARGS:
|
||||
new_task = original_task.copy()
|
||||
new_task._role_name = role_name
|
||||
for from_arg in new_task.FROM_ARGS:
|
||||
if from_arg in include_variables:
|
||||
from_key = from_arg.replace('_from', '')
|
||||
original_task._from_files[from_key] = templar.template(include_variables[from_arg])
|
||||
new_task._from_files[from_key] = templar.template(include_variables[from_arg])
|
||||
|
||||
inc_file = IncludedFile("role", include_variables, original_task, is_role=True)
|
||||
inc_file = IncludedFile("role", include_variables, new_task, is_role=True)
|
||||
|
||||
try:
|
||||
pos = included_files.index(inc_file)
|
||||
|
|
Loading…
Reference in a new issue