Merge pull request #460 from emgee/module-paths-2
Search multiple paths for modules.
This commit is contained in:
commit
e88d62634f
2 changed files with 9 additions and 4 deletions
|
@ -722,9 +722,14 @@ class Runner(object):
|
||||||
|
|
||||||
if module.startswith("/"):
|
if module.startswith("/"):
|
||||||
raise errors.AnsibleFileNotFound("%s is not a module" % module)
|
raise errors.AnsibleFileNotFound("%s is not a module" % module)
|
||||||
in_path = os.path.expanduser(os.path.join(self.module_path, module))
|
|
||||||
if not os.path.exists(in_path):
|
# Search module path(s) for named module.
|
||||||
raise errors.AnsibleFileNotFound("module not found: %s" % in_path)
|
for module_path in self.module_path.split(os.pathsep):
|
||||||
|
in_path = os.path.expanduser(os.path.join(module_path, module))
|
||||||
|
if os.path.exists(in_path):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise errors.AnsibleFileNotFound("module %s not found in %s" % (module, self.module_path))
|
||||||
|
|
||||||
out_path = tmp + module
|
out_path = tmp + module
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ def base_parser(constants=C, usage="", output_opts=False, runas_opts=False, asyn
|
||||||
parser.add_option('-K', '--ask-sudo-pass', default=False, dest='ask_sudo_pass', action='store_true',
|
parser.add_option('-K', '--ask-sudo-pass', default=False, dest='ask_sudo_pass', action='store_true',
|
||||||
help='ask for sudo password')
|
help='ask for sudo password')
|
||||||
parser.add_option('-M', '--module-path', dest='module_path',
|
parser.add_option('-M', '--module-path', dest='module_path',
|
||||||
help="specify path to module library (default=%s)" % constants.DEFAULT_MODULE_PATH,
|
help="specify path(s) to module library (default=%s)" % constants.DEFAULT_MODULE_PATH,
|
||||||
default=constants.DEFAULT_MODULE_PATH)
|
default=constants.DEFAULT_MODULE_PATH)
|
||||||
parser.add_option('-T', '--timeout', default=constants.DEFAULT_TIMEOUT, type='int',
|
parser.add_option('-T', '--timeout', default=constants.DEFAULT_TIMEOUT, type='int',
|
||||||
dest='timeout',
|
dest='timeout',
|
||||||
|
|
Loading…
Reference in a new issue