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

Fixes #17243
pull/17494/merge
James Cammarata 8 years ago
parent f36926f8d3
commit a83b00bbc0

@ -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

@ -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)

Loading…
Cancel
Save