Fixing bugs in include + loops

Fixes #11872
This commit is contained in:
James Cammarata 2015-08-11 01:28:42 -04:00
parent 7666bde666
commit 169d316704
4 changed files with 11 additions and 6 deletions

View file

@ -51,6 +51,8 @@ class IncludedFile:
if res._task.action == 'include':
if res._task.loop:
if 'results' not in res._result:
continue
include_results = res._result['results']
else:
include_results = [ res._result ]
@ -82,13 +84,13 @@ class IncludedFile:
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']
templar = Templar(loader=loader, variables=task_vars)
include_file = templar.template(include_file)
inc_file = IncludedFile(include_file, include_variables, original_task)

View file

@ -113,7 +113,7 @@ class CallbackBase:
else:
self.v2_playbook_item_on_ok(newres)
del result._result['results']
#del result._result['results']
def set_play_context(self, play_context):
pass

View file

@ -68,10 +68,11 @@ class CallbackModule(CallbackBase):
if result._task.loop and 'results' in result._result:
self._process_items(result)
else:
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result and result._task.action != 'include':
msg += " => %s" % self._dump_results(result._result)
self._display.display(msg, color=color)
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result and result._task.action != 'include':
msg += " => %s" % self._dump_results(result._result)
self._display.display(msg, color=color)
self._handle_warnings(result._result)

View file

@ -412,7 +412,9 @@ class StrategyBase:
# set the vars for this task from those specified as params to the include
for b in block_list:
b.vars.update(included_file._args.copy())
temp_vars = b.vars.copy()
temp_vars.update(included_file._args.copy())
b.vars = temp_vars
return block_list