Fixing includes where the included file is "{{item}}"

This commit is contained in:
James Cammarata 2015-07-06 14:30:56 -04:00
parent 46b33152c8
commit 1d8ccfb99f
3 changed files with 10 additions and 8 deletions

View file

@ -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))

View file

@ -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:

View file

@ -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