Skip to content

Commit

Permalink
Don't include dependent roles in the dep chain for include_role
Browse files Browse the repository at this point in the history
The dependency chain should not include roles below the parent, as it
can introduce very weird things like conditionals from child deps impacting
non-related roles.

Fixes ansible#25136
  • Loading branch information
jimi-c committed Jun 22, 2017
1 parent 9cc35b0 commit 495a809
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/ansible/playbook/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
# 2. one of the appropriate config options was set
if 'import_role' in task_ds:
is_static = True

if ir.static is not None:
display.deprecated("The use of 'static' for 'include_role' has been deprecated. "
"Use 'import_role' for static inclusion, or 'include_role' for dynamic inclusion")
Expand All @@ -315,6 +316,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
(not needs_templating and ir.all_parents_static() and not ir.loop)
)
display.debug('Determined that if include_role static is %s' % str(is_static))

if is_static:
# uses compiled list from object
t = task_list.extend(ir.get_block_list(variable_manager=variable_manager, loader=loader))
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/playbook/role_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_block_list(self, play=None, variable_manager=None, loader=None):
dep_chain = []
else:
dep_chain = list(self._parent_role._parents)
dep_chain.extend(self._parent_role.get_all_dependencies())
dep_chain.append(self._parent_role)

blocks = actual_role.compile(play=myplay, dep_chain=dep_chain)
Expand Down Expand Up @@ -115,7 +114,7 @@ def load(data, block=None, role=None, task_include=None, variable_manager=None,
if option in ir.args:
setattr(ir, option, ir.args.get(option))

return ir.load_data(data, variable_manager=variable_manager, loader=loader)
return ir

def copy(self, exclude_parent=False, exclude_tasks=False):

Expand Down

0 comments on commit 495a809

Please sign in to comment.