1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Properly sort groups by name as well as depth when getting vars

Fixes #17243
This commit is contained in:
James Cammarata 2016-11-18 22:56:37 -06:00
parent f36926f8d3
commit a83b00bbc0
2 changed files with 2 additions and 2 deletions

View file

@ -138,6 +138,6 @@ class Host:
def get_group_vars(self):
results = {}
groups = self.get_groups()
for group in sorted(groups, key=lambda g: g.depth):
for group in sorted(groups, key=lambda g: (g.depth, g.name)):
results = combine_vars(results, group.get_vars())
return results

View file

@ -252,7 +252,7 @@ class VariableManager:
# we merge in vars from groups specified in the inventory (INI or script)
all_vars = combine_vars(all_vars, host.get_group_vars())
for group in sorted(host.get_groups(), key=lambda g: g.depth):
for group in sorted(host.get_groups(), key=lambda g: (g.depth, g.name)):
if group.name in self._group_vars_files and group.name != 'all':
for data in self._group_vars_files[group.name]:
data = preprocess_vars(data)