mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Don't use _raw_params for IncludeRole objects (#26601)
IncludeRole objects don't use _raw_params for the name/etc. of roles like regular incudes, but the code for finding relative includes assumed that all includes had a _raw_params field. This fixes that by correctly checking the parent object type and using the appropriate field. Fixes #26525
This commit is contained in:
parent
bf63301b34
commit
640d057f3f
2 changed files with 9 additions and 1 deletions
|
@ -22,6 +22,7 @@ __metaclass__ = type
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ansible.playbook.task_include import TaskInclude
|
from ansible.playbook.task_include import TaskInclude
|
||||||
|
from ansible.playbook.role_include import IncludeRole
|
||||||
from ansible.template import Templar
|
from ansible.template import Templar
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -101,7 +102,10 @@ class IncludedFile:
|
||||||
if not isinstance(parent_include, TaskInclude):
|
if not isinstance(parent_include, TaskInclude):
|
||||||
parent_include = parent_include._parent
|
parent_include = parent_include._parent
|
||||||
continue
|
continue
|
||||||
parent_include_dir = os.path.dirname(templar.template(parent_include.args.get('_raw_params')))
|
if isinstance(parent_include, IncludeRole):
|
||||||
|
parent_include_dir = os.path.dirname(parent_include._role_path)
|
||||||
|
else:
|
||||||
|
parent_include_dir = os.path.dirname(templar.template(parent_include.args.get('_raw_params')))
|
||||||
if cumulative_path is None:
|
if cumulative_path is None:
|
||||||
cumulative_path = parent_include_dir
|
cumulative_path = parent_include_dir
|
||||||
elif not os.path.isabs(cumulative_path):
|
elif not os.path.isabs(cumulative_path):
|
||||||
|
|
|
@ -58,6 +58,7 @@ class IncludeRole(TaskInclude):
|
||||||
self._from_files = {}
|
self._from_files = {}
|
||||||
self._parent_role = role
|
self._parent_role = role
|
||||||
self._role_name = None
|
self._role_name = None
|
||||||
|
self._role_path = None
|
||||||
|
|
||||||
def get_block_list(self, play=None, variable_manager=None, loader=None):
|
def get_block_list(self, play=None, variable_manager=None, loader=None):
|
||||||
|
|
||||||
|
@ -74,6 +75,9 @@ class IncludeRole(TaskInclude):
|
||||||
actual_role = Role.load(ri, myplay, parent_role=self._parent_role, from_files=self._from_files)
|
actual_role = Role.load(ri, myplay, parent_role=self._parent_role, from_files=self._from_files)
|
||||||
actual_role._metadata.allow_duplicates = self.allow_duplicates
|
actual_role._metadata.allow_duplicates = self.allow_duplicates
|
||||||
|
|
||||||
|
# save this for later use
|
||||||
|
self._role_path = actual_role._role_path
|
||||||
|
|
||||||
# compile role with parent roles as dependencies to ensure they inherit
|
# compile role with parent roles as dependencies to ensure they inherit
|
||||||
# variables
|
# variables
|
||||||
if not self._parent_role:
|
if not self._parent_role:
|
||||||
|
|
Loading…
Reference in a new issue