@ -33,9 +33,10 @@ display = Display()
class IncludedFile :
def __init__ ( self , filename , args , task , is_role = False ) :
def __init__ ( self , filename , args , vars , task , is_role = False ) :
self . _filename = filename
self . _args = args
self . _vars = vars
self . _task = task
self . _hosts = [ ]
self . _is_role = is_role
@ -47,10 +48,13 @@ class IncludedFile:
raise ValueError ( )
def __eq__ ( self , other ) :
return other . _filename == self . _filename and other . _args == self . _args and other . _task . _parent . _uuid == self . _task . _parent . _uuid
return ( other . _filename == self . _filename and
other . _args == self . _args and
other . _vars == self . _vars and
other . _task . _parent . _uuid == self . _task . _parent . _uuid )
def __repr__ ( self ) :
return " %s ( %s ): %s " % ( self . _filename , self . _args , self . _hosts )
return " %s ( args=%s vars= %s ): %s " % ( self . _filename , self . _arg s, self . _var s, self . _hosts )
@staticmethod
def process_include_results ( results , iterator , loader , variable_manager ) :
@ -81,20 +85,21 @@ class IncludedFile:
except KeyError :
task_vars = task_vars_cache [ cache_key ] = variable_manager . get_vars ( play = iterator . _play , host = original_host , task = original_task )
include_variables = include_result . get ( ' include_variables ' , dict ( ) )
include_args = include_result . get ( ' include_args ' , dict ( ) )
special_vars = { }
loop_var = ' item '
index_var = None
if original_task . loop_control :
loop_var = original_task . loop_control . loop_var
index_var = original_task . loop_control . index_var
if loop_var in include_result :
task_vars [ loop_var ] = include_variable s[ loop_var ] = include_result [ loop_var ]
task_vars [ loop_var ] = special_var s[ loop_var ] = include_result [ loop_var ]
if index_var and index_var in include_result :
task_vars [ index_var ] = include_variable s[ index_var ] = include_result [ index_var ]
task_vars [ index_var ] = special_var s[ index_var ] = include_result [ index_var ]
if ' _ansible_item_label ' in include_result :
task_vars [ ' _ansible_item_label ' ] = include_variable s[ ' _ansible_item_label ' ] = include_result [ ' _ansible_item_label ' ]
if original_task . no_log and ' _ansible_no_log ' not in include_ variable s:
task_vars [ ' _ansible_no_log ' ] = include_variable s[ ' _ansible_no_log ' ] = original_task . no_log
task_vars [ ' _ansible_item_label ' ] = special_var s[ ' _ansible_item_label ' ] = include_result [ ' _ansible_item_label ' ]
if original_task . no_log and ' _ansible_no_log ' not in include_ arg s:
task_vars [ ' _ansible_no_log ' ] = special_var s[ ' _ansible_no_log ' ] = original_task . no_log
# get search path for this task to pass to lookup plugins that may be used in pathing to
# the included file
@ -166,21 +171,21 @@ class IncludedFile:
include_file = loader . path_dwim ( include_result [ ' include ' ] )
include_file = templar . template ( include_file )
inc_file = IncludedFile ( include_file , include_ variable s, original_task )
inc_file = IncludedFile ( include_file , include_ args, special_var s, original_task )
else :
# template the included role's name here
role_name = include_ variable s. pop ( ' name ' , include_ variable s. pop ( ' role ' , None ) )
role_name = include_ arg s. pop ( ' name ' , include_ arg s. pop ( ' role ' , None ) )
if role_name is not None :
role_name = templar . template ( role_name )
new_task = original_task . copy ( )
new_task . _role_name = role_name
for from_arg in new_task . FROM_ARGS :
if from_arg in include_ variable s:
if from_arg in include_ arg s:
from_key = from_arg . replace ( ' _from ' , ' ' )
new_task . _from_files [ from_key ] = templar . template ( include_ variable s. pop ( from_arg ) )
new_task . _from_files [ from_key ] = templar . template ( include_ arg s. pop ( from_arg ) )
inc_file = IncludedFile ( role_name , include_ variable s, new_task , is_role = True )
inc_file = IncludedFile ( role_name , include_ args, special_var s, new_task , is_role = True )
idx = 0
orig_inc_file = inc_file