Get all groups' variables in order of depth
Fixes all not being processed, as well as the order of the variable precedence
This commit is contained in:
parent
d5dd89a8f7
commit
bd7e02d629
1 changed files with 2 additions and 2 deletions
|
@ -54,12 +54,12 @@ class Host(object):
|
||||||
def get_variables(self):
|
def get_variables(self):
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
for group in self.groups:
|
groups = self.get_groups()
|
||||||
|
for group in sorted(groups, key=lambda g: g.depth):
|
||||||
results.update(group.get_variables())
|
results.update(group.get_variables())
|
||||||
results.update(self.vars)
|
results.update(self.vars)
|
||||||
results['inventory_hostname'] = self.name
|
results['inventory_hostname'] = self.name
|
||||||
results['inventory_hostname_short'] = self.name.split('.')[0]
|
results['inventory_hostname_short'] = self.name.split('.')[0]
|
||||||
groups = self.get_groups()
|
|
||||||
results['group_names'] = sorted([ g.name for g in groups if g.name != 'all'])
|
results['group_names'] = sorted([ g.name for g in groups if g.name != 'all'])
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue