diff --git a/lib/ansible/executor/process/result.py b/lib/ansible/executor/process/result.py index 7fbee9a1b65..8810001702c 100644 --- a/lib/ansible/executor/process/result.py +++ b/lib/ansible/executor/process/result.py @@ -142,12 +142,6 @@ class ResultProcess(multiprocessing.Process): result_items = [ result._result ] for result_item in result_items: - #if 'include' in result_item: - # include_variables = result_item.get('include_variables', dict()) - # if 'item' in result_item: - # include_variables['item'] = result_item['item'] - # self._send_result(('include', result._host, result._task, result_item['include'], include_variables)) - #elif 'add_host' in result_item: if 'add_host' in result_item: # this task added a new host (add_host module) self._send_result(('add_host', result_item)) diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py index 74fdfbc9034..92bf325f5b4 100644 --- a/lib/ansible/playbook/included_file.py +++ b/lib/ansible/playbook/included_file.py @@ -19,6 +19,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +from ansible.template import Templar + class IncludedFile: def __init__(self, filename, args, task): @@ -38,7 +40,7 @@ class IncludedFile: return "%s (%s): %s" % (self._filename, self._args, self._hosts) @staticmethod - def process_include_results(results, tqm, iterator, loader): + def process_include_results(results, tqm, iterator, loader, variable_manager): included_files = [] for res in results: @@ -62,10 +64,16 @@ class IncludedFile: else: include_file = loader.path_dwim(res._task.args.get('_raw_params')) + task_vars = variable_manager.get_vars(loader=loader, play=iterator._play, host=res._host, task=original_task) + #task_vars = tqm.add_tqm_variables(task_vars, play=iterator._play) + templar = Templar(loader=loader, variables=task_vars) + include_variables = include_result.get('include_variables', dict()) if 'item' in include_result: include_variables['item'] = include_result['item'] + task_vars['item'] = include_result['item'] + include_file = templar.template(include_file) inc_file = IncludedFile(include_file, include_variables, original_task) try: diff --git a/lib/ansible/plugins/strategies/linear.py b/lib/ansible/plugins/strategies/linear.py index 1ce9677f8f9..70ab50d8eac 100644 --- a/lib/ansible/plugins/strategies/linear.py +++ b/lib/ansible/plugins/strategies/linear.py @@ -213,7 +213,7 @@ class StrategyModule(StrategyBase): host_results.extend(results) try: - included_files = IncludedFile.process_include_results(host_results, self._tqm, iterator=iterator, loader=self._loader) + included_files = IncludedFile.process_include_results(host_results, self._tqm, iterator=iterator, loader=self._loader, variable_manager=self._variable_manager) except AnsibleError, e: return False