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:
Daniel Hokka Zakrisson 2012-11-23 00:20:07 +01:00
parent d5dd89a8f7
commit bd7e02d629

View file

@ -54,12 +54,12 @@ class Host(object):
def get_variables(self):
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(self.vars)
results['inventory_hostname'] = self.name
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'])
return results