From 2a7f9df10978f1686844b729f91b59c83fac84a9 Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Wed, 5 Jun 2013 23:25:24 +0200 Subject: [PATCH] add support for callback_plugins/ relative to playbook --- lib/ansible/callbacks.py | 6 +++++- lib/ansible/playbook/__init__.py | 2 ++ lib/ansible/utils/plugins.py | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 39e81a0886e..23e8e904811 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -41,7 +41,11 @@ if constants.DEFAULT_LOG_PATH != '': user = getpass.getuser() logger = logging.getLogger("p=%s u=%s | " % (mypid, user)) -callback_plugins = [x for x in utils.plugins.callback_loader.all()] +callback_plugins = [] + +def load_callback_plugins(): + global callback_plugins + callback_plugins = [x for x in utils.plugins.callback_loader.all()] def get_cowsay_info(): if constants.ANSIBLE_NOCOWS is not None: diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 8b69d19a0e3..f554bd3e319 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -129,11 +129,13 @@ class PlayBook(object): self.inventory = inventory self.basedir = os.path.dirname(playbook) or '.' + utils.plugins.push_basedir(self.basedir) vars = {} if self.inventory.basedir() is not None: vars['inventory_dir'] = self.inventory.basedir() self.filename = playbook (self.playbook, self.play_basedirs) = self._load_playbook_from_file(playbook, vars) + ansible.callbacks.load_callback_plugins() # ***************************************************** diff --git a/lib/ansible/utils/plugins.py b/lib/ansible/utils/plugins.py index e9d2c605bd4..88aaa792b37 100644 --- a/lib/ansible/utils/plugins.py +++ b/lib/ansible/utils/plugins.py @@ -28,7 +28,8 @@ PLUGIN_PATH_CACHE = {} _basedirs = [] def push_basedir(basedir): - _basedirs.insert(0, basedir) + if basedir not in _basedirs: + _basedirs.insert(0, basedir) class PluginLoader(object):