refactor to catch edge cases, remove repeated code

- Move all the supported YAML file extensions into a constant
- Use helper functions to avoid duplicate code for group/host vars
- Catch and disallow some confusing situations, such as the presence of
  multiple group/host vars files for the same group/host, but with
  different extensions.  For example having both group_vars/all.yml and
  group_vars/all.yaml.
- Catch and report file system permission issues, symlink errors,
  unexpected file system objects
- Trivial performance improvement from making fewer stat system calls
- Restructuring that makes it easy for a following patch to support
  directory recursion
This commit is contained in:
Alan Fairless 2013-10-31 12:05:52 -05:00
commit babde9a84c
2 changed files with 99 additions and 36 deletions

View file

@ -89,6 +89,10 @@ if getattr(sys, "real_prefix", None):
else:
DIST_MODULE_PATH = '/usr/share/ansible/'
# check all of these extensions when looking for yaml files for things like
# group variables
YAML_FILENAME_EXTENSIONS = [ "", ".yml", ".yaml" ]
# sections in config file
DEFAULTS='defaults'