@ -100,14 +100,16 @@ class IncludeRole(TaskInclude):
dep_chain = list ( self . _parent_role . _parents )
dep_chain = list ( self . _parent_role . _parents )
dep_chain . append ( self . _parent_role )
dep_chain . append ( self . _parent_role )
p_block = self . build_parent_block ( )
blocks = actual_role . compile ( play = myplay , dep_chain = dep_chain )
blocks = actual_role . compile ( play = myplay , dep_chain = dep_chain )
for b in blocks :
for b in blocks :
b . _parent = self
b . _parent = p_block
# updated available handlers in play
# updated available handlers in play
handlers = actual_role . get_handler_blocks ( play = myplay )
handlers = actual_role . get_handler_blocks ( play = myplay )
for h in handlers :
for h in handlers :
h . _parent = self
h . _parent = p_block
myplay . handlers = myplay . handlers + handlers
myplay . handlers = myplay . handlers + handlers
return blocks , handlers
return blocks , handlers
@ -143,22 +145,11 @@ class IncludeRole(TaskInclude):
from_key = key . replace ( ' _from ' , ' ' )
from_key = key . replace ( ' _from ' , ' ' )
ir . _from_files [ from_key ] = basename ( ir . args . get ( key ) )
ir . _from_files [ from_key ] = basename ( ir . args . get ( key ) )
apply_attrs = ir . args . pop ( ' apply ' , { } )
apply_attrs = ir . args . get ( ' apply ' , { } )
if apply_attrs and ir . action != ' include_role ' :
if apply_attrs and ir . action != ' include_role ' :
raise AnsibleParserError ( ' Invalid options for %s : apply ' % ir . action , obj = data )
raise AnsibleParserError ( ' Invalid options for %s : apply ' % ir . action , obj = data )
elif apply_attrs :
elif not isinstance ( apply_attrs , dict ) :
apply_attrs [ ' block ' ] = [ ]
raise AnsibleParserError ( ' Expected a dict for apply but got %s instead ' % type ( apply_attrs ) , obj = data )
p_block = Block . load (
apply_attrs ,
play = block . _play ,
parent_block = block ,
role = role ,
task_include = task_include ,
use_handlers = block . _use_handlers ,
variable_manager = variable_manager ,
loader = loader ,
)
ir . _parent = p_block
# manual list as otherwise the options would set other task parameters we don't want.
# manual list as otherwise the options would set other task parameters we don't want.
for option in my_arg_names . intersection ( IncludeRole . OTHER_ARGS ) :
for option in my_arg_names . intersection ( IncludeRole . OTHER_ARGS ) :