mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Look for plugins in the playbook's basedir
This commit is contained in:
parent
036f853d42
commit
1aaf86069a
4 changed files with 17 additions and 1 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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')))
|
||||
|
||||
# *****************************************************
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue