Commit 169d3167 by James Cammarata

Fixing bugs in include + loops

Fixes #11872
parent 7666bde6
...@@ -51,6 +51,8 @@ class IncludedFile: ...@@ -51,6 +51,8 @@ class IncludedFile:
if res._task.action == 'include': if res._task.action == 'include':
if res._task.loop: if res._task.loop:
if 'results' not in res._result:
continue
include_results = res._result['results'] include_results = res._result['results']
else: else:
include_results = [ res._result ] include_results = [ res._result ]
...@@ -82,13 +84,13 @@ class IncludedFile: ...@@ -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 = 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) #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()) include_variables = include_result.get('include_variables', dict())
if 'item' in include_result: if 'item' in include_result:
include_variables['item'] = include_result['item'] include_variables['item'] = include_result['item']
task_vars['item'] = include_result['item'] task_vars['item'] = include_result['item']
templar = Templar(loader=loader, variables=task_vars)
include_file = templar.template(include_file) include_file = templar.template(include_file)
inc_file = IncludedFile(include_file, include_variables, original_task) inc_file = IncludedFile(include_file, include_variables, original_task)
......
...@@ -113,7 +113,7 @@ class CallbackBase: ...@@ -113,7 +113,7 @@ class CallbackBase:
else: else:
self.v2_playbook_item_on_ok(newres) self.v2_playbook_item_on_ok(newres)
del result._result['results'] #del result._result['results']
def set_play_context(self, play_context): def set_play_context(self, play_context):
pass pass
......
...@@ -68,10 +68,11 @@ class CallbackModule(CallbackBase): ...@@ -68,10 +68,11 @@ class CallbackModule(CallbackBase):
if result._task.loop and 'results' in result._result: if result._task.loop and 'results' in result._result:
self._process_items(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': 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) msg += " => %s" % self._dump_results(result._result)
self._display.display(msg, color=color) self._display.display(msg, color=color)
self._handle_warnings(result._result) self._handle_warnings(result._result)
......
...@@ -412,7 +412,9 @@ class StrategyBase: ...@@ -412,7 +412,9 @@ class StrategyBase:
# set the vars for this task from those specified as params to the include # set the vars for this task from those specified as params to the include
for b in block_list: 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 return block_list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment