Fix relative paths for included files

Also modifies the Play class to not include become* fields in the
post-validation step.

Fixes #11353
pull/8127/merge
James Cammarata 9 years ago
parent 2673eb0afb
commit bcbcfc79be

@ -19,6 +19,8 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
from ansible.template import Templar
class IncludedFile:
@ -59,8 +61,22 @@ class IncludedFile:
continue
original_task = iterator.get_original_task(res._host, res._task)
if original_task and original_task._role:
include_file = loader.path_dwim_relative(original_task._role._role_path, 'tasks', include_result['include'])
if original_task:
if original_task._role:
include_file = loader.path_dwim_relative(original_task._role._role_path, 'tasks', include_result['include'])
elif original_task._task_include:
# handle relative includes by walking up the list of parent include
# tasks and checking the relative result to see if it exists
parent_include = original_task._task_include
while parent_include is not None:
parent_include_dir = os.path.dirname(parent_include.args.get('_raw_params'))
include_file = loader.path_dwim_relative(loader.get_basedir(), parent_include_dir, include_result['include'])
if os.path.exists(include_file):
break
else:
parent_include = parent_include._task_include
else:
include_file = loader.path_dwim(res._task.args.get('_raw_params'))
else:
include_file = loader.path_dwim(res._task.args.get('_raw_params'))

@ -232,6 +232,14 @@ class Play(Base, Taggable, Become):
'''
return value
# disable validation on various fields which will be validated later in other objects
def _post_validate_become(self, attr, value, templar):
return value
def _post_validate_become_user(self, attr, value, templar):
return value
def _post_validate_become_method(self, attr, value, templar):
return value
# FIXME: post_validation needs to ensure that become/su/sudo have only 1 set
def _compile_roles(self):

Loading…
Cancel
Save