Properly sort groups by name as well as depth when getting vars
Fixes #17243
This commit is contained in:
parent
3ce19f4c58
commit
23b5764b57
2 changed files with 2 additions and 2 deletions
|
@ -138,6 +138,6 @@ class Host:
|
||||||
def get_group_vars(self):
|
def get_group_vars(self):
|
||||||
results = {}
|
results = {}
|
||||||
groups = self.get_groups()
|
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())
|
results = combine_vars(results, group.get_vars())
|
||||||
return results
|
return results
|
||||||
|
|
|
@ -252,7 +252,7 @@ class VariableManager:
|
||||||
# we merge in vars from groups specified in the inventory (INI or script)
|
# we merge in vars from groups specified in the inventory (INI or script)
|
||||||
all_vars = combine_vars(all_vars, host.get_group_vars())
|
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':
|
if group.name in self._group_vars_files and group.name != 'all':
|
||||||
for data in self._group_vars_files[group.name]:
|
for data in self._group_vars_files[group.name]:
|
||||||
data = preprocess_vars(data)
|
data = preprocess_vars(data)
|
||||||
|
|
Loading…
Reference in a new issue