Skip to content

Commit

Permalink
Properly copy the role path when the IncludeRole object is copied
Browse files Browse the repository at this point in the history
This exposed some additional errors in logic in IncludeFile, which
had to be fixed to deal with the fact that the role path (unlike paths
from includes) are always absolute paths.

Fixes ansible#27345
  • Loading branch information
jimi-c authored and bcoca committed Aug 4, 2017
1 parent c770d65 commit e0b0e61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/ansible/playbook/included_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ def get_original_host(host):
parent_include = parent_include._parent
continue
if isinstance(parent_include, IncludeRole):
parent_include_dir = os.path.dirname(parent_include._role_path)
parent_include_dir = parent_include._role_path
else:
parent_include_dir = os.path.dirname(templar.template(parent_include.args.get('_raw_params')))
if cumulative_path is None:
cumulative_path = parent_include_dir
elif not os.path.isabs(cumulative_path):
if cumulative_path is not None and not os.path.isabs(cumulative_path):
cumulative_path = os.path.join(parent_include_dir, cumulative_path)
else:
cumulative_path = parent_include_dir
include_target = templar.template(include_result['include'])
if original_task._role:
new_basedir = os.path.join(original_task._role._role_path, 'tasks', cumulative_path)
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/playbook/role_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def copy(self, exclude_parent=False, exclude_tasks=False):
new_me._from_files = self._from_files.copy()
new_me._parent_role = self._parent_role
new_me._role_name = self._role_name
new_me._role_path = self._role_path

return new_me

Expand Down

0 comments on commit e0b0e61

Please sign in to comment.