summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2014-09-26 17:25:56 +0200
committerMichael DeHaan <michael.dehaan@gmail.com>2014-09-26 17:25:56 +0200
commite5116d2f9bd851949ae50e0c9c112750e7cec761 (patch)
tree197cfddc7f64bc5f3228c344f56b81f548c15a1a /lib
parentUpdate module test code to avoid pycs (that are not used) (diff)
downloadansible-e5116d2f9bd851949ae50e0c9c112750e7cec761.tar.xz
ansible-e5116d2f9bd851949ae50e0c9c112750e7cec761.zip
changes for package loading of modules
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/constants.py18
m---------lib/ansible/modules/core0
m---------lib/ansible/modules/extras0
-rw-r--r--lib/ansible/runner/__init__.py2
-rw-r--r--lib/ansible/utils/plugins.py18
5 files changed, 17 insertions, 21 deletions
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
index 8c342497c1..861dd5325c 100644
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -90,22 +90,6 @@ p = load_config_file()
active_user = pwd.getpwuid(os.geteuid())[0]
-# Needed so the RPM can call setup.py and have modules land in the
-# correct location. See #1277 for discussion
-if getattr(sys, "real_prefix", None):
- # in a virtualenv
- DIST_MODULE_PATH = os.path.join(sys.prefix, 'share/ansible/')
-else:
- DIST_MODULE_PATH = '/usr/share/ansible/'
-
-# Look for modules relative to this file path
-# This is so that we can find the modules when running from a local checkout
-# installed as editable with `pip install -e ...` or `python setup.py develop`
-local_module_path = os.path.abspath(
- os.path.join(os.path.dirname(__file__), '..', '..', 'library')
-)
-DIST_MODULE_PATH = os.pathsep.join([DIST_MODULE_PATH, local_module_path])
-
# check all of these extensions when looking for yaml files for things like
# group variables -- really anything we can load
YAML_FILENAME_EXTENSIONS = [ "", ".yml", ".yaml", ".json" ]
@@ -115,7 +99,7 @@ DEFAULTS='defaults'
# configurable things
DEFAULT_HOST_LIST = shell_expand_path(get_config(p, DEFAULTS, 'hostfile', 'ANSIBLE_HOSTS', '/etc/ansible/hosts'))
-DEFAULT_MODULE_PATH = get_config(p, DEFAULTS, 'library', 'ANSIBLE_LIBRARY', DIST_MODULE_PATH)
+DEFAULT_MODULE_PATH = get_config(p, DEFAULTS, 'library', 'ANSIBLE_LIBRARY', None)
DEFAULT_ROLES_PATH = shell_expand_path(get_config(p, DEFAULTS, 'roles_path', 'ANSIBLE_ROLES_PATH', '/etc/ansible/roles'))
DEFAULT_REMOTE_TMP = get_config(p, DEFAULTS, 'remote_tmp', 'ANSIBLE_REMOTE_TEMP', '$HOME/.ansible/tmp')
DEFAULT_MODULE_NAME = get_config(p, DEFAULTS, 'module_name', None, 'command')
diff --git a/lib/ansible/modules/core b/lib/ansible/modules/core
-Subproject 417309a626e39396196a4abc6208c9f6db158f9
+Subproject 385a037cd6bc42fc64e387973c0e7ef539b04df
diff --git a/lib/ansible/modules/extras b/lib/ansible/modules/extras
-Subproject 50f105578a07361e60f95a63da6acb566076587
+Subproject 110250d344be156387d08ea837f4bcb2c42034b
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py
index 7e093f3537..f727bc6e4e 100644
--- a/lib/ansible/runner/__init__.py
+++ b/lib/ansible/runner/__init__.py
@@ -1215,7 +1215,7 @@ class Runner(object):
module_suffixes = getattr(conn, 'default_suffixes', None)
module_path = utils.plugins.module_finder.find_plugin(module_name, module_suffixes)
if module_path is None:
- raise errors.AnsibleFileNotFound("module %s not found in %s" % (module_name, utils.plugins.module_finder.print_paths()))
+ raise errors.AnsibleFileNotFound("module %s not found in configured module paths" % (module_name))
# insert shared code and arguments into the module
diff --git a/lib/ansible/utils/plugins.py b/lib/ansible/utils/plugins.py
index f83155412f..9349f133c4 100644
--- a/lib/ansible/utils/plugins.py
+++ b/lib/ansible/utils/plugins.py
@@ -75,6 +75,15 @@ class PluginLoader(object):
ret.append(i)
return os.pathsep.join(ret)
+ def _all_directories(self, dir):
+ results = []
+ results.append(dir)
+ for root, subdirs, files in os.walk(dir):
+ if '__init__.py' in files:
+ for x in subdirs:
+ results.append(os.path.join(root,x))
+ return results
+
def _get_package_paths(self):
''' Gets the path of a Python package '''
@@ -85,7 +94,7 @@ class PluginLoader(object):
m = __import__(self.package)
parts = self.package.split('.')[1:]
self.package_path = os.path.join(os.path.dirname(m.__file__), *parts)
- paths.append(self.package_path)
+ paths.extend(self._all_directories(self.package_path))
return paths
else:
return [ self.package_path ]
@@ -107,7 +116,8 @@ class PluginLoader(object):
# allow directories to be two levels deep
files2 = glob.glob("%s/*/*" % fullpath)
- files = files.extend(files2)
+ if files2 is not None:
+ files.extend(files2)
for file in files:
if os.path.isdir(file) and file not in ret:
@@ -128,6 +138,8 @@ class PluginLoader(object):
# look for any plugins installed in the package subtree
ret.extend(self._get_package_paths())
+ package_dirs = self._get_package_paths()
+
self._paths = ret
@@ -153,7 +165,7 @@ class PluginLoader(object):
if self.class_name:
suffixes = ['.py']
else:
- suffixes = ['', '.ps1']
+ suffixes = ['', '.ps1', '.py']
for suffix in suffixes:
full_name = '%s%s' % (name, suffix)