Commit f1b8323b by Brian Coca

fixed host/group var loading when inventory is a directory

parent af06a97f
...@@ -566,12 +566,16 @@ class Inventory(object): ...@@ -566,12 +566,16 @@ class Inventory(object):
def basedir(self): def basedir(self):
""" if inventory came from a file, what's the directory? """ """ if inventory came from a file, what's the directory? """
dname = self.host_list
if not self.is_file(): if not self.is_file():
return None dname = None
elif os.path.isdir(self.host_list):
dname = self.host_list
else:
dname = os.path.dirname(self.host_list) dname = os.path.dirname(self.host_list)
if dname is None or dname == '' or dname == '.': if dname is None or dname == '' or dname == '.':
cwd = os.getcwd() cwd = os.getcwd()
return os.path.abspath(cwd) dname = cwd
return os.path.abspath(dname) return os.path.abspath(dname)
def src(self): def src(self):
...@@ -636,6 +640,7 @@ class Inventory(object): ...@@ -636,6 +640,7 @@ class Inventory(object):
basedirs = [self._playbook_basedir] basedirs = [self._playbook_basedir]
for basedir in basedirs: for basedir in basedirs:
display.debug('getting vars from %s' % basedir)
# this can happen from particular API usages, particularly if not run # this can happen from particular API usages, particularly if not run
# from /usr/bin/ansible-playbook # from /usr/bin/ansible-playbook
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment