mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #2794 from stoned/role-library
Add module path library/ if it exists in role directory
This commit is contained in:
commit
9abd31b15f
1 changed files with 7 additions and 3 deletions
|
@ -125,7 +125,8 @@ class Play(object):
|
||||||
# <rolename>/tasks/main.yml
|
# <rolename>/tasks/main.yml
|
||||||
# <rolename>/handlers/main.yml
|
# <rolename>/handlers/main.yml
|
||||||
# <rolename>/vars/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:
|
if roles is None:
|
||||||
roles = []
|
roles = []
|
||||||
|
@ -172,8 +173,9 @@ class Play(object):
|
||||||
task = utils.path_dwim(self.basedir, os.path.join(path, 'tasks', 'main.yml'))
|
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'))
|
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'))
|
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):
|
library = utils.path_dwim(self.basedir, os.path.join(path, 'library'))
|
||||||
raise errors.AnsibleError("found role at %s, but cannot find %s or %s or %s" % (path, task, handler, vars_file))
|
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):
|
if os.path.isfile(task):
|
||||||
nt = dict(include=task, vars=has_dict)
|
nt = dict(include=task, vars=has_dict)
|
||||||
if when:
|
if when:
|
||||||
|
@ -190,6 +192,8 @@ class Play(object):
|
||||||
new_handlers.append(nt)
|
new_handlers.append(nt)
|
||||||
if os.path.isfile(vars_file):
|
if os.path.isfile(vars_file):
|
||||||
new_vars_files.append(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)
|
tasks = ds.get('tasks', None)
|
||||||
post_tasks = ds.get('post_tasks', None)
|
post_tasks = ds.get('post_tasks', None)
|
||||||
|
|
Loading…
Reference in a new issue