diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2015-08-23 13:31:21 -0400 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2015-08-23 17:51:47 -0400 |
commit | f1b8323b6236e9164e7cd9991578a6a54e6ff013 (patch) | |
tree | 80d08efdd10ba58a5dfacb336d7a2a8e2e73b275 | |
parent | af06a97f17a94808d90fff0e9adc4d9a1b5781eb (diff) | |
download | ansible-f1b8323b6236e9164e7cd9991578a6a54e6ff013.tar.gz |
fixed host/group var loading when inventory is a directory
-rw-r--r-- | lib/ansible/inventory/__init__.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 5c44b010d6..e4ff5132d8 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -557,7 +557,7 @@ class Inventory(object): def remove_restriction(self): """ Do not restrict list operations """ self._restriction = None - + def is_file(self): """ did inventory come from a file? """ if not isinstance(self.host_list, basestring): @@ -566,12 +566,16 @@ class Inventory(object): def basedir(self): """ if inventory came from a file, what's the directory? """ + dname = self.host_list if not self.is_file(): - return None - dname = os.path.dirname(self.host_list) - if dname is None or dname == '' or dname == '.': - cwd = os.getcwd() - return os.path.abspath(cwd) + dname = None + elif os.path.isdir(self.host_list): + dname = self.host_list + else: + dname = os.path.dirname(self.host_list) + if dname is None or dname == '' or dname == '.': + cwd = os.getcwd() + dname = cwd return os.path.abspath(dname) def src(self): @@ -636,6 +640,7 @@ class Inventory(object): basedirs = [self._playbook_basedir] for basedir in basedirs: + display.debug('getting vars from %s' % basedir) # this can happen from particular API usages, particularly if not run # from /usr/bin/ansible-playbook |