Moving over all lookup plugins to v2

This commit is contained in:
James Cammarata
2015-01-09 09:37:31 -06:00
parent 45f8e6f3b0
commit 1544dde932
54 changed files with 1650 additions and 37 deletions

View File

@@ -60,6 +60,7 @@ class PlayState:
(rescue/always)
'''
self._parent_iterator = parent_iterator
self._run_state = ITERATING_SETUP
self._failed_state = FAILED_NONE
self._task_list = parent_iterator._play.compile()
@@ -104,6 +105,8 @@ class PlayState:
if self._gather_facts == 'smart' and not self._host.gathered_facts or boolean(self._gather_facts):
self._host.set_gathered_facts(True)
task = Task()
# FIXME: this is not the best way to get this...
task.set_loader(self._parent_iterator._play._loader)
task.action = 'setup'
break
elif run_state == ITERATING_TASKS:

View File

@@ -97,9 +97,23 @@ class WorkerProcess(multiprocessing.Process):
try:
if not self._main_q.empty():
debug("there's work to be done!")
(host, task, job_vars, connection_info) = self._main_q.get(block=False)
(host, task, basedir, job_vars, connection_info) = self._main_q.get(block=False)
debug("got a task/handler to work on: %s" % task)
# because the task queue manager starts workers (forks) before the
# playbook is loaded, set the basedir of the loader inherted by
# this fork now so that we can find files correctly
self._loader.set_basedir(basedir)
# Serializing/deserializing tasks does not preserve the loader attribute,
# since it is passed to the worker during the forking of the process and
# would be wasteful to serialize. So we set it here on the task now, and
# the task handles updating parent/child objects as needed.
task.set_loader(self._loader)
# apply the given task's information to the connection info,
# which may override some fields already set by the play or
# the options specified on the command line
new_connection_info = connection_info.set_task_override(task)
# execute the task and build a TaskResult from the result

View File

@@ -58,7 +58,7 @@ class TaskExecutor:
try:
items = self._get_loop_items()
if items:
if items is not None:
if len(items) > 0:
item_results = self._run_loop(items)
res = dict(results=item_results)
@@ -84,7 +84,7 @@ class TaskExecutor:
items = None
if self._task.loop and self._task.loop in lookup_loader:
items = lookup_loader.get(self._task.loop).run(terms=self._task.loop_args, variables=self._job_vars)
items = lookup_loader.get(self._task.loop, loader=self._loader).run(terms=self._task.loop_args, variables=self._job_vars)
return items