Implementing includes in the free strategy

pull/11864/head
James Cammarata 9 years ago
parent 2b9b3a08a1
commit fad44862a5

@ -21,6 +21,8 @@ __metaclass__ = type
import time
from ansible.errors import *
from ansible.playbook.included_file import IncludedFile
from ansible.plugins.strategies import StrategyBase
try:
@ -140,6 +142,31 @@ class StrategyModule(StrategyBase):
results = self._process_pending_results(iterator)
host_results.extend(results)
try:
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
if len(included_files) > 0:
for included_file in included_files:
# included hosts get the task list while those excluded get an equal-length
# list of noop tasks, to make sure that they continue running in lock-step
try:
new_blocks = self._load_included_file(included_file, iterator=iterator)
except AnsibleError, e:
for host in included_file._hosts:
iterator.mark_host_failed(host)
self._display.warning(str(e))
continue
for host in hosts_left:
if host in included_file._hosts:
task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=included_file._task)
final_blocks = []
for new_block in new_blocks:
final_blocks.append(new_block.filter_tagged_tasks(play_context, task_vars))
iterator.add_tasks(host, final_blocks)
# pause briefly so we don't spin lock
time.sleep(0.05)

@ -194,8 +194,8 @@ class StrategyModule(StrategyBase):
if self._take_step(task):
choose_step = False
else:
break
skip_rest = True
break
self._display.debug("getting variables")
task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=task)

Loading…
Cancel
Save