Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module path library/ if it exists in role directory #2794

Merged
merged 1 commit into from
Apr 27, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/ansible/playbook/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def _load_roles(self, roles, ds):
# <rolename>/tasks/main.yml
# <rolename>/handlers/main.yml
# <rolename>/vars/main.yml
# and it auto-extends tasks/handlers/vars_files as appropriate if found
# <rolename>/library
# and it auto-extends tasks/handlers/vars_files/module paths as appropriate if found

if roles is None:
roles = []
Expand Down Expand Up @@ -172,8 +173,9 @@ def _load_roles(self, roles, ds):
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:
Expand All @@ -190,6 +192,8 @@ def _load_roles(self, roles, ds):
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)
Expand Down