mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Finish up plugin porting to global display
Also remove display = display which does nothing
This commit is contained in:
parent
2bd695ed42
commit
62979efa14
39 changed files with 68 additions and 92 deletions
|
@ -36,7 +36,6 @@ from ansible.utils.unicode import to_bytes
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -36,7 +36,6 @@ from ansible.vars import VariableManager
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -33,7 +33,6 @@ from ansible.utils import module_docs
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -40,7 +40,6 @@ from ansible.playbook.role.requirement import RoleRequirement
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -35,7 +35,6 @@ from ansible.vars import VariableManager
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -35,7 +35,6 @@ from ansible.utils.cmd_functions import run_cmd
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -29,7 +29,6 @@ from ansible.cli import CLI
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -37,7 +37,6 @@ from ansible.utils.unicode import to_unicode
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -39,7 +39,6 @@ from ansible.vars.unsafe_proxy import UnsafeProxy
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -35,7 +35,6 @@ from ansible.template import Templar
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
@ -161,10 +160,6 @@ class TaskQueueManager:
|
|||
elif callback_needs_whitelist and (C.DEFAULT_CALLBACK_WHITELIST is None or callback_name not in C.DEFAULT_CALLBACK_WHITELIST):
|
||||
continue
|
||||
|
||||
# is it too late to change the API for v2 callback plugins?
|
||||
# display is not necessary.
|
||||
self._callback_plugins.append(callback_plugin(display))
|
||||
else:
|
||||
self._callback_plugins.append(callback_plugin())
|
||||
|
||||
self._callbacks_loaded = True
|
||||
|
|
|
@ -25,7 +25,6 @@ from ansible.playbook.attribute import Attribute, FieldAttribute
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -34,7 +34,6 @@ from ansible.vars import preprocess_vars
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -39,7 +39,6 @@ __all__ = ['PlayContext']
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -42,7 +42,6 @@ VALID_SPEC_KEYS = [
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -38,7 +38,6 @@ from ansible.playbook.taggable import Taggable
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -26,7 +26,6 @@ from ansible.errors import AnsibleError
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -21,7 +21,6 @@ from ansible.plugins.action import ActionBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -29,7 +29,6 @@ from ansible.plugins.action import ActionBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
1
lib/ansible/plugins/cache/base.py
vendored
1
lib/ansible/plugins/cache/base.py
vendored
|
@ -31,6 +31,7 @@ except ImportError:
|
|||
|
||||
class BaseCacheModule(with_metaclass(ABCMeta, object)):
|
||||
|
||||
# Backwards compat only. Just import the global display instead
|
||||
_display = display
|
||||
|
||||
@abstractmethod
|
||||
|
|
1
lib/ansible/plugins/cache/jsonfile.py
vendored
1
lib/ansible/plugins/cache/jsonfile.py
vendored
|
@ -37,7 +37,6 @@ from ansible.utils.unicode import to_bytes
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -30,6 +30,12 @@ from ansible import constants as C
|
|||
from ansible.vars import strip_internal_keys
|
||||
from ansible.utils.unicode import to_unicode
|
||||
|
||||
try:
|
||||
from __main__ import display as global_display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
global_display = Display()
|
||||
|
||||
__all__ = ["CallbackBase"]
|
||||
|
||||
|
||||
|
@ -41,8 +47,12 @@ class CallbackBase:
|
|||
custom actions.
|
||||
'''
|
||||
|
||||
def __init__(self, display):
|
||||
def __init__(self, display=None):
|
||||
if display:
|
||||
self._display = display
|
||||
else:
|
||||
self._display = global_display
|
||||
|
||||
if self._display.verbosity >= 4:
|
||||
name = getattr(self, 'CALLBACK_NAME', 'unnamed')
|
||||
ctype = getattr(self, 'CALLBACK_TYPE', 'old')
|
||||
|
|
|
@ -33,7 +33,6 @@ from ansible.utils.encrypt import key_for_hostname, keyczar_encrypt, keyczar_dec
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -33,7 +33,6 @@ from ansible.module_utils.basic import is_executable
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -39,7 +39,6 @@ from ansible.plugins.connection import ConnectionBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -33,7 +33,6 @@ from ansible.plugins.connection import ConnectionBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -33,7 +33,6 @@ from ansible.plugins.connection import ConnectionBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -32,7 +32,6 @@ from ansible.plugins.connection import ConnectionBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -45,7 +45,6 @@ from ansible.utils.path import makedirs_safe
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -36,7 +36,6 @@ from ansible.utils.unicode import to_bytes, to_unicode
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -49,7 +49,6 @@ from ansible.utils.unicode import to_bytes, to_unicode, to_str
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -34,7 +34,6 @@ from ansible.plugins.connection import ConnectionBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -22,7 +22,6 @@ from ansible.plugins.lookup import LookupBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -25,7 +25,6 @@ from ansible.plugins.lookup import LookupBase
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -26,7 +26,6 @@ from ansible.utils.unicode import to_unicode
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -23,8 +23,6 @@ from ansible.compat.six.moves import queue as Queue
|
|||
from ansible.compat.six import iteritems, text_type, string_types
|
||||
|
||||
import json
|
||||
import pickle
|
||||
import sys
|
||||
import time
|
||||
import zlib
|
||||
|
||||
|
@ -35,13 +33,11 @@ from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVar
|
|||
from ansible.executor.task_result import TaskResult
|
||||
from ansible.inventory.host import Host
|
||||
from ansible.inventory.group import Group
|
||||
from ansible.playbook.handler import Handler
|
||||
from ansible.playbook.helpers import load_list_of_blocks
|
||||
from ansible.playbook.included_file import IncludedFile
|
||||
from ansible.playbook.role import hash_params
|
||||
from ansible.plugins import action_loader, connection_loader, filter_loader, lookup_loader, module_loader, test_loader
|
||||
from ansible.template import Templar
|
||||
from ansible.vars.unsafe_proxy import wrap_var, AnsibleJSONUnsafeEncoder
|
||||
from ansible.vars.unsafe_proxy import wrap_var
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
|
@ -51,6 +47,7 @@ except ImportError:
|
|||
|
||||
__all__ = ['StrategyBase']
|
||||
|
||||
|
||||
# TODO: this should probably be in the plugins/__init__.py, with
|
||||
# a smarter mechanism to set all of the attributes based on
|
||||
# the loaders created there
|
||||
|
@ -67,6 +64,7 @@ class SharedPluginLoaderObj:
|
|||
self.lookup_loader = lookup_loader
|
||||
self.module_loader = module_loader
|
||||
|
||||
|
||||
class StrategyBase:
|
||||
|
||||
'''
|
||||
|
@ -84,6 +82,7 @@ class StrategyBase:
|
|||
self._final_q = tqm._final_q
|
||||
self._step = getattr(tqm._options, 'step', False)
|
||||
self._diff = getattr(tqm._options, 'diff', False)
|
||||
# Backwards compat: self._display isn't really needed, just import the global display and use that.
|
||||
self._display = display
|
||||
|
||||
# internal counters
|
||||
|
@ -100,7 +99,7 @@ class StrategyBase:
|
|||
failed_hosts = self._tqm._failed_hosts.keys()
|
||||
unreachable_hosts = self._tqm._unreachable_hosts.keys()
|
||||
|
||||
self._display.debug("running handlers")
|
||||
display.debug("running handlers")
|
||||
result &= self.run_handlers(iterator, play_context)
|
||||
|
||||
# now update with the hosts (if any) that failed or were
|
||||
|
@ -121,7 +120,8 @@ class StrategyBase:
|
|||
return 0
|
||||
|
||||
def get_hosts_remaining(self, play):
|
||||
return [host for host in self._inventory.get_hosts(play.hosts) if host.name not in self._tqm._failed_hosts and host.name not in self._tqm._unreachable_hosts]
|
||||
return [host for host in self._inventory.get_hosts(play.hosts)
|
||||
if host.name not in self._tqm._failed_hosts and host.name not in self._tqm._unreachable_hosts]
|
||||
|
||||
def get_failed_hosts(self, play):
|
||||
return [host for host in self._inventory.get_hosts(play.hosts) if host.name in self._tqm._failed_hosts]
|
||||
|
@ -137,12 +137,12 @@ class StrategyBase:
|
|||
def _queue_task(self, host, task, task_vars, play_context):
|
||||
''' handles queueing the task up to be sent to a worker '''
|
||||
|
||||
self._display.debug("entering _queue_task() for %s/%s" % (host, task))
|
||||
display.debug("entering _queue_task() for %s/%s" % (host, task))
|
||||
|
||||
# and then queue the new task
|
||||
self._display.debug("%s - putting task (%s) in queue" % (host, task))
|
||||
display.debug("%s - putting task (%s) in queue" % (host, task))
|
||||
try:
|
||||
self._display.debug("worker is %d (out of %d available)" % (self._cur_worker+1, len(self._workers)))
|
||||
display.debug("worker is %d (out of %d available)" % (self._cur_worker+1, len(self._workers)))
|
||||
|
||||
(worker_prc, main_q, rslt_q) = self._workers[self._cur_worker]
|
||||
self._cur_worker += 1
|
||||
|
@ -167,7 +167,7 @@ class StrategyBase:
|
|||
# data contained in the dict is very large
|
||||
del task_vars
|
||||
else:
|
||||
zip_vars = task_vars
|
||||
zip_vars = task_vars # noqa (pyflakes false positive because task_vars is deleted in the conditional above)
|
||||
|
||||
# and queue the task
|
||||
main_q.put((host, task, self._loader.get_basedir(), zip_vars, hostvars, compressed_vars, play_context, shared_loader_obj), block=False)
|
||||
|
@ -178,9 +178,9 @@ class StrategyBase:
|
|||
self._pending_results += 1
|
||||
except (EOFError, IOError, AssertionError) as e:
|
||||
# most likely an abort
|
||||
self._display.debug("got an error while queuing: %s" % e)
|
||||
display.debug("got an error while queuing: %s" % e)
|
||||
return
|
||||
self._display.debug("exiting _queue_task() for %s/%s" % (host, task))
|
||||
display.debug("exiting _queue_task() for %s/%s" % (host, task))
|
||||
|
||||
def _process_pending_results(self, iterator):
|
||||
'''
|
||||
|
@ -193,7 +193,7 @@ class StrategyBase:
|
|||
while not self._final_q.empty() and not self._tqm._terminated:
|
||||
try:
|
||||
result = self._final_q.get(block=False)
|
||||
self._display.debug("got result from result worker: %s" % ([text_type(x) for x in result],))
|
||||
display.debug("got result from result worker: %s" % ([text_type(x) for x in result],))
|
||||
|
||||
# all host status messages contain 2 entries: (msg, task_result)
|
||||
if result[0] in ('host_task_ok', 'host_task_failed', 'host_task_skipped', 'host_unreachable'):
|
||||
|
@ -202,7 +202,7 @@ class StrategyBase:
|
|||
task = task_result._task
|
||||
if result[0] == 'host_task_failed' or task_result.is_failed():
|
||||
if not task.ignore_errors:
|
||||
self._display.debug("marking %s as failed" % host.name)
|
||||
display.debug("marking %s as failed" % host.name)
|
||||
if task.run_once:
|
||||
# if we're using run_once, we have to fail every host here
|
||||
[iterator.mark_host_failed(h) for h in self._inventory.get_hosts(iterator._play.hosts) if h.name not in self._tqm._unreachable_hosts]
|
||||
|
@ -266,7 +266,7 @@ class StrategyBase:
|
|||
|
||||
if task_result._host not in self._notified_handlers[handler_name]:
|
||||
self._notified_handlers[handler_name].append(task_result._host)
|
||||
self._display.vv("NOTIFIED HANDLER %s" % (handler_name,))
|
||||
display.vv("NOTIFIED HANDLER %s" % (handler_name,))
|
||||
|
||||
elif result[0] == 'register_host_var':
|
||||
# essentially the same as 'set_host_var' below, however we
|
||||
|
@ -323,12 +323,12 @@ class StrategyBase:
|
|||
|
||||
ret_results = []
|
||||
|
||||
self._display.debug("waiting for pending results...")
|
||||
display.debug("waiting for pending results...")
|
||||
while self._pending_results > 0 and not self._tqm._terminated:
|
||||
results = self._process_pending_results(iterator)
|
||||
ret_results.extend(results)
|
||||
time.sleep(0.01)
|
||||
self._display.debug("no more pending results, returning what we have")
|
||||
display.debug("no more pending results, returning what we have")
|
||||
|
||||
return ret_results
|
||||
|
||||
|
@ -468,8 +468,9 @@ class StrategyBase:
|
|||
tags = [ tags ]
|
||||
if len(tags) > 0:
|
||||
if len(b._task_include.tags) > 0:
|
||||
raise AnsibleParserError("Include tasks should not specify tags in more than one way (both via args and directly on the task)", obj=included_file._task._ds)
|
||||
self._display.deprecated("You should not specify tags in the include parameters. All tags should be specified using the task-level option")
|
||||
raise AnsibleParserError("Include tasks should not specify tags in more than one way (both via args and directly on the task)",
|
||||
obj=included_file._task._ds)
|
||||
display.deprecated("You should not specify tags in the include parameters. All tags should be specified using the task-level option")
|
||||
b._task_include.tags = tags
|
||||
b._task_include.vars = temp_vars
|
||||
|
||||
|
@ -579,12 +580,12 @@ class StrategyBase:
|
|||
for host in included_file._hosts:
|
||||
iterator.mark_host_failed(host)
|
||||
self._tqm._failed_hosts[host.name] = True
|
||||
self._display.warning(str(e))
|
||||
display.warning(str(e))
|
||||
continue
|
||||
|
||||
# wipe the notification list
|
||||
self._notified_handlers[handler_name] = []
|
||||
self._display.debug("done running handlers, result is: %s" % result)
|
||||
display.debug("done running handlers, result is: %s" % result)
|
||||
return result
|
||||
|
||||
def _take_step(self, task, host=None):
|
||||
|
@ -594,19 +595,19 @@ class StrategyBase:
|
|||
msg = u'Perform task: %s on %s (y/n/c): ' % (task, host)
|
||||
else:
|
||||
msg = u'Perform task: %s (y/n/c): ' % task
|
||||
resp = self._display.prompt(msg)
|
||||
resp = display.prompt(msg)
|
||||
|
||||
if resp.lower() in ['y','yes']:
|
||||
self._display.debug("User ran task")
|
||||
display.debug("User ran task")
|
||||
ret = True
|
||||
elif resp.lower() in ['c', 'continue']:
|
||||
self._display.debug("User ran task and cancled step mode")
|
||||
display.debug("User ran task and cancled step mode")
|
||||
self._step = False
|
||||
ret = True
|
||||
else:
|
||||
self._display.debug("User skipped task")
|
||||
display.debug("User skipped task")
|
||||
|
||||
self._display.banner(msg)
|
||||
display.banner(msg)
|
||||
|
||||
return ret
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ except ImportError:
|
|||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
||||
|
||||
class StrategyModule(StrategyBase):
|
||||
|
||||
def run(self, iterator, play_context):
|
||||
|
@ -69,31 +70,31 @@ class StrategyModule(StrategyBase):
|
|||
host_results = []
|
||||
while True:
|
||||
host = hosts_left[last_host]
|
||||
self._display.debug("next free host: %s" % host)
|
||||
display.debug("next free host: %s" % host)
|
||||
host_name = host.get_name()
|
||||
|
||||
# peek at the next task for the host, to see if there's
|
||||
# anything to do do for this host
|
||||
(state, task) = iterator.get_next_task_for_host(host, peek=True)
|
||||
self._display.debug("free host state: %s" % state)
|
||||
self._display.debug("free host task: %s" % task)
|
||||
display.debug("free host state: %s" % state)
|
||||
display.debug("free host task: %s" % task)
|
||||
if host_name not in self._tqm._failed_hosts and host_name not in self._tqm._unreachable_hosts and task:
|
||||
|
||||
# set the flag so the outer loop knows we've still found
|
||||
# some work which needs to be done
|
||||
work_to_do = True
|
||||
|
||||
self._display.debug("this host has work to do")
|
||||
display.debug("this host has work to do")
|
||||
|
||||
# check to see if this host is blocked (still executing a previous task)
|
||||
if not host_name in self._blocked_hosts or not self._blocked_hosts[host_name]:
|
||||
if host_name not in self._blocked_hosts or not self._blocked_hosts[host_name]:
|
||||
# pop the task, mark the host blocked, and queue it
|
||||
self._blocked_hosts[host_name] = True
|
||||
(state, task) = iterator.get_next_task_for_host(host)
|
||||
|
||||
self._display.debug("getting variables")
|
||||
display.debug("getting variables")
|
||||
task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=task)
|
||||
self._display.debug("done getting variables")
|
||||
display.debug("done getting variables")
|
||||
|
||||
# check to see if this task should be skipped, due to it being a member of a
|
||||
# role which has already run (and whether that role allows duplicate execution)
|
||||
|
@ -101,7 +102,7 @@ class StrategyModule(StrategyBase):
|
|||
# If there is no metadata, the default behavior is to not allow duplicates,
|
||||
# if there is metadata, check to see if the allow_duplicates flag was set to true
|
||||
if task._role._metadata is None or task._role._metadata and not task._role._metadata.allow_duplicates:
|
||||
self._display.debug("'%s' skipped because role has already run" % task)
|
||||
display.debug("'%s' skipped because role has already run" % task)
|
||||
continue
|
||||
|
||||
if task.action == 'meta':
|
||||
|
@ -138,7 +139,8 @@ class StrategyModule(StrategyBase):
|
|||
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)
|
||||
included_files = IncludedFile.process_include_results(host_results, self._tqm, iterator=iterator,
|
||||
loader=self._loader, variable_manager=self._variable_manager)
|
||||
except AnsibleError as e:
|
||||
return False
|
||||
|
||||
|
@ -151,7 +153,7 @@ class StrategyModule(StrategyBase):
|
|||
except AnsibleError as e:
|
||||
for host in included_file._hosts:
|
||||
iterator.mark_host_failed(host)
|
||||
self._display.warning(str(e))
|
||||
display.warning(str(e))
|
||||
continue
|
||||
|
||||
for host in hosts_left:
|
||||
|
@ -174,4 +176,3 @@ class StrategyModule(StrategyBase):
|
|||
# run the base class run() method, which executes the cleanup function
|
||||
# and runs any outstanding handlers which have been triggered
|
||||
return super(StrategyModule, self).run(iterator, play_context, result)
|
||||
|
||||
|
|
|
@ -154,9 +154,9 @@ class StrategyModule(StrategyBase):
|
|||
while work_to_do and not self._tqm._terminated:
|
||||
|
||||
try:
|
||||
self._display.debug("getting the remaining hosts for this loop")
|
||||
display.debug("getting the remaining hosts for this loop")
|
||||
hosts_left = [host for host in self._inventory.get_hosts(iterator._play.hosts) if host.name not in self._tqm._unreachable_hosts]
|
||||
self._display.debug("done getting the remaining hosts for this loop")
|
||||
display.debug("done getting the remaining hosts for this loop")
|
||||
|
||||
# queue up this task for each host in the inventory
|
||||
callback_sent = False
|
||||
|
@ -198,7 +198,7 @@ class StrategyModule(StrategyBase):
|
|||
# If there is no metadata, the default behavior is to not allow duplicates,
|
||||
# if there is metadata, check to see if the allow_duplicates flag was set to true
|
||||
if task._role._metadata is None or task._role._metadata and not task._role._metadata.allow_duplicates:
|
||||
self._display.debug("'%s' skipped because role has already run" % task)
|
||||
display.debug("'%s' skipped because role has already run" % task)
|
||||
continue
|
||||
|
||||
if task.action == 'meta':
|
||||
|
@ -212,11 +212,11 @@ class StrategyModule(StrategyBase):
|
|||
skip_rest = True
|
||||
break
|
||||
|
||||
self._display.debug("getting variables")
|
||||
display.debug("getting variables")
|
||||
task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=task)
|
||||
self.add_tqm_variables(task_vars, play=iterator._play)
|
||||
templar = Templar(loader=self._loader, variables=task_vars)
|
||||
self._display.debug("done getting variables")
|
||||
display.debug("done getting variables")
|
||||
|
||||
if not callback_sent:
|
||||
display.debug("sending task start callback, copying the task so we can template it temporarily")
|
||||
|
@ -250,18 +250,19 @@ class StrategyModule(StrategyBase):
|
|||
if skip_rest:
|
||||
continue
|
||||
|
||||
self._display.debug("done queuing things up, now waiting for results queue to drain")
|
||||
display.debug("done queuing things up, now waiting for results queue to drain")
|
||||
results = self._wait_on_pending_results(iterator)
|
||||
host_results.extend(results)
|
||||
|
||||
if not work_to_do and len(iterator.get_failed_hosts()) > 0:
|
||||
self._display.debug("out of hosts to run on")
|
||||
display.debug("out of hosts to run on")
|
||||
self._tqm.send_callback('v2_playbook_on_no_hosts_remaining')
|
||||
result = False
|
||||
break
|
||||
|
||||
try:
|
||||
included_files = IncludedFile.process_include_results(host_results, self._tqm, iterator=iterator, loader=self._loader, variable_manager=self._variable_manager)
|
||||
included_files = IncludedFile.process_include_results(host_results, self._tqm,
|
||||
iterator=iterator, loader=self._loader, variable_manager=self._variable_manager)
|
||||
except AnsibleError as e:
|
||||
return False
|
||||
|
||||
|
@ -285,7 +286,8 @@ class StrategyModule(StrategyBase):
|
|||
noop_block.rescue = [noop_task for t in new_block.rescue]
|
||||
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)
|
||||
task_vars = self._variable_manager.get_vars(loader=self._loader,
|
||||
play=iterator._play, host=host, task=included_file._task)
|
||||
final_block = new_block.filter_tagged_tasks(play_context, task_vars)
|
||||
all_blocks[host].append(final_block)
|
||||
else:
|
||||
|
@ -295,7 +297,7 @@ class StrategyModule(StrategyBase):
|
|||
for host in included_file._hosts:
|
||||
self._tqm._failed_hosts[host.name] = True
|
||||
iterator.mark_host_failed(host)
|
||||
self._display.error(e, wrap_text=False)
|
||||
display.error(e, wrap_text=False)
|
||||
continue
|
||||
|
||||
# finally go through all of the hosts and append the
|
||||
|
@ -303,9 +305,9 @@ class StrategyModule(StrategyBase):
|
|||
for host in hosts_left:
|
||||
iterator.add_tasks(host, all_blocks[host])
|
||||
|
||||
self._display.debug("results queue empty")
|
||||
display.debug("results queue empty")
|
||||
except (IOError, EOFError) as e:
|
||||
self._display.debug("got IOError/EOFError in task loop: %s" % e)
|
||||
display.debug("got IOError/EOFError in task loop: %s" % e)
|
||||
# most likely an abort, return failed
|
||||
return False
|
||||
|
||||
|
@ -313,4 +315,3 @@ class StrategyModule(StrategyBase):
|
|||
# and runs any outstanding handlers which have been triggered
|
||||
|
||||
return super(StrategyModule, self).run(iterator, play_context, result)
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ except:
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
|
@ -48,7 +48,6 @@ from ansible.vars.unsafe_proxy import wrap_var
|
|||
|
||||
try:
|
||||
from __main__ import display
|
||||
display = display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
|
Loading…
Reference in a new issue