From 75b51f79b415e21dc0cea8d76aed800c01ae1392 Mon Sep 17 00:00:00 2001 From: Stoned Elipot Date: Sat, 27 Apr 2013 13:02:38 +0200 Subject: [PATCH] Add module path library/ if it exists in role directory --- lib/ansible/playbook/play.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index a11a472c470..601fc3cd4e3 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -125,7 +125,8 @@ class Play(object): # /tasks/main.yml # /handlers/main.yml # /vars/main.yml - # and it auto-extends tasks/handlers/vars_files as appropriate if found + # /library + # and it auto-extends tasks/handlers/vars_files/module paths as appropriate if found if roles is None: roles = [] @@ -172,8 +173,9 @@ class Play(object): task = utils.path_dwim(self.basedir, os.path.join(path, 'tasks', 'main.yml')) handler = utils.path_dwim(self.basedir, os.path.join(path, 'handlers', 'main.yml')) vars_file = utils.path_dwim(self.basedir, os.path.join(path, 'vars', 'main.yml')) - if not os.path.isfile(task) and not os.path.isfile(handler) and not os.path.isfile(vars_file): - raise errors.AnsibleError("found role at %s, but cannot find %s or %s or %s" % (path, task, handler, vars_file)) + library = utils.path_dwim(self.basedir, os.path.join(path, 'library')) + if not os.path.isfile(task) and not os.path.isfile(handler) and not os.path.isfile(vars_file) and not os.path.isdir(library): + raise errors.AnsibleError("found role at %s, but cannot find %s or %s or %s or %s" % (path, task, handler, vars_file, library)) if os.path.isfile(task): nt = dict(include=task, vars=has_dict) if when: @@ -190,6 +192,8 @@ class Play(object): new_handlers.append(nt) if os.path.isfile(vars_file): new_vars_files.append(vars_file) + if os.path.isdir(library): + utils.plugins.module_finder.add_directory(library) tasks = ds.get('tasks', None) post_tasks = ds.get('post_tasks', None)