diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 0ac6961435c..94aa7efd603 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -46,6 +46,9 @@ def call_callback_module(method_name, *args, **kwargs): if method is not None: method(*args, **kwargs) +def load_more_callbacks(dirname): + callbacks.extend([c.CallbackModule() for c in utils.import_plugins(dirname).values()]) + def vv(msg, host=None): return verbose(msg, host=host, caplevel=1) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 7ec0cb54513..de6ff1f2a04 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -20,6 +20,7 @@ import ansible.runner import ansible.constants as C from ansible import utils from ansible import errors +import ansible.callbacks import os import collections from play import Play @@ -120,6 +121,9 @@ class PlayBook(object): self.basedir = os.path.dirname(playbook) (self.playbook, self.play_basedirs) = self._load_playbook_from_file(playbook) self.module_path = self.module_path + os.pathsep + os.path.join(self.basedir, "library") + ansible.callbacks.load_more_callbacks(os.path.join(self.basedir, "callback_plugins")) + + self.lookup_plugins_list.update(utils.import_plugins(os.path.join(self.basedir, 'lookup_plugins'))) # ***************************************************** diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 3382fe013fa..d28357ded3f 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -167,6 +167,11 @@ class Runner(object): for (k,v) in lookup_plugin_list.iteritems(): self.lookup_plugins[k] = v.LookupModule(self) + for (k,v) in utils.import_plugins(os.path.join(self.basedir, 'action_plugins')).iteritems(): + self.action_plugins[k] = v.ActionModule(self) + for (k,v) in utils.import_plugins(os.path.join(self.basedir, 'lookup_plugins')).iteritems(): + self.lookup_plugins[k] = v.LookupModule(self) + # ***************************************************** def _delete_remote_files(self, conn, files): diff --git a/lib/ansible/runner/connection.py b/lib/ansible/runner/connection.py index 1057549f1bc..cbca5f9c725 100644 --- a/lib/ansible/runner/connection.py +++ b/lib/ansible/runner/connection.py @@ -34,11 +34,15 @@ class Connection(object): def __init__(self, runner): self.runner = runner + self.modules = None def connect(self, host, port): + if self.modules is None: + self.modules = modules.copy() + self.modules.update(utils.import_plugins(os.path.join(self.runner.basedir, 'connection_plugins'))) conn = None transport = self.runner.transport - module = modules.get(transport, None) + module = self.modules.get(transport, None) if module is None: raise AnsibleError("unsupported connection type: %s" % transport) conn = module.Connection(self.runner, host, port)