diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index b1d905be7ad..169b08c3ece 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -60,6 +60,7 @@ class TaskQueueManager: self._options = options self._stats = AggregateStats() self.passwords = passwords + self._stdout_callback = stdout_callback # a special flag to help us exit cleanly self._terminated = False @@ -73,9 +74,6 @@ class TaskQueueManager: self._final_q = multiprocessing.Queue() - # load callback plugins - self._callback_plugins = self._load_callbacks(stdout_callback) - # create the pool of worker threads, based on the number of forks specified try: fileno = sys.stdin.fileno() @@ -206,6 +204,9 @@ class TaskQueueManager: are done with the current task). ''' + # load callback plugins + self._callback_plugins = self._load_callbacks(self._stdout_callback) + if play.vars_prompt: for var in play.vars_prompt: if 'name' not in var: diff --git a/lib/ansible/playbook/role/__init__.py b/lib/ansible/playbook/role/__init__.py index c24e6499d7f..c84f0f86775 100644 --- a/lib/ansible/playbook/role/__init__.py +++ b/lib/ansible/playbook/role/__init__.py @@ -37,7 +37,7 @@ from ansible.playbook.helpers import load_list_of_blocks from ansible.playbook.role.include import RoleInclude from ansible.playbook.role.metadata import RoleMetadata from ansible.playbook.taggable import Taggable -from ansible.plugins import get_all_plugin_loaders +from ansible.plugins import get_all_plugin_loaders, push_basedir from ansible.utils.vars import combine_vars @@ -136,6 +136,8 @@ class Role(Base, Become, Conditional, Taggable): self._variable_manager = role_include.get_variable_manager() self._loader = role_include.get_loader() + push_basedir(self._role_path) + if parent_role: self.add_parent(parent_role) diff --git a/lib/ansible/plugins/strategies/__init__.py b/lib/ansible/plugins/strategies/__init__.py index 180cf3245d1..6eae8216829 100644 --- a/lib/ansible/plugins/strategies/__init__.py +++ b/lib/ansible/plugins/strategies/__init__.py @@ -29,7 +29,7 @@ from ansible.inventory.group import Group from ansible.playbook.handler import Handler from ansible.playbook.helpers import load_list_of_blocks from ansible.playbook.role import ROLE_CACHE, hash_params -from ansible.plugins import filter_loader, lookup_loader, module_loader +from ansible.plugins import _basedirs, filter_loader, lookup_loader, module_loader from ansible.utils.debug import debug @@ -44,6 +44,7 @@ class SharedPluginLoaderObj: the forked processes over the queue easier ''' def __init__(self): + self.basdirs = _basedirs[:] self.filter_loader = filter_loader self.lookup_loader = lookup_loader self.module_loader = module_loader diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index 1841560abba..8ce243f55f2 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -29,7 +29,7 @@ from jinja2.runtime import StrictUndefined from ansible import constants as C from ansible.errors import AnsibleError, AnsibleFilterError, AnsibleUndefinedVariable -from ansible.plugins import filter_loader, lookup_loader +from ansible.plugins import _basedirs, filter_loader, lookup_loader from ansible.template.safe_eval import safe_eval from ansible.template.template import AnsibleJ2Template from ansible.template.vars import AnsibleJ2Vars @@ -60,6 +60,8 @@ class Templar: self._available_variables = variables if shared_loader_obj: + global _basedirs + _basedirs = shared_loader_obj.basedirs[:] self._filter_loader = getattr(shared_loader_obj, 'filter_loader') self._lookup_loader = getattr(shared_loader_obj, 'lookup_loader') else: