add support for callback_plugins/ relative to playbook

This commit is contained in:
Serge van Ginderachter 2013-06-05 23:25:24 +02:00
parent 1fd863cf5d
commit 2a7f9df109
3 changed files with 9 additions and 2 deletions

View file

@ -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:

View file

@ -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()
# *****************************************************

View file

@ -28,6 +28,7 @@ PLUGIN_PATH_CACHE = {}
_basedirs = []
def push_basedir(basedir):
if basedir not in _basedirs:
_basedirs.insert(0, basedir)
class PluginLoader(object):