mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix directory loading of host/group vars in v2
This commit is contained in:
parent
4d9bf37afa
commit
b07ab41994
1 changed files with 21 additions and 1 deletions
|
@ -236,7 +236,27 @@ class VariableManager:
|
||||||
basename of the file without the extension
|
basename of the file without the extension
|
||||||
'''
|
'''
|
||||||
|
|
||||||
data = loader.load_from_file(path)
|
if os.path.isdir(path):
|
||||||
|
data = dict()
|
||||||
|
|
||||||
|
try:
|
||||||
|
names = os.listdir(path)
|
||||||
|
except os.error, err:
|
||||||
|
raise AnsibleError("This folder cannot be listed: %s: %s." % (path, err.strerror))
|
||||||
|
|
||||||
|
# evaluate files in a stable order rather than whatever
|
||||||
|
# order the filesystem lists them.
|
||||||
|
names.sort()
|
||||||
|
|
||||||
|
# do not parse hidden files or dirs, e.g. .svn/
|
||||||
|
paths = [os.path.join(path, name) for name in names if not name.startswith('.')]
|
||||||
|
for p in paths:
|
||||||
|
_found, results = self._load_inventory_file(path=p, loader=loader)
|
||||||
|
data = self._combine_vars(data, results)
|
||||||
|
|
||||||
|
else:
|
||||||
|
data = loader.load_from_file(path)
|
||||||
|
|
||||||
name = self._get_inventory_basename(path)
|
name = self._get_inventory_basename(path)
|
||||||
return (name, data)
|
return (name, data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue