From bd7e02d629eac2770eb7bf781ce50c9e6f1280f2 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Fri, 23 Nov 2012 00:20:07 +0100 Subject: [PATCH] Get all groups' variables in order of depth Fixes all not being processed, as well as the order of the variable precedence --- lib/ansible/inventory/host.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/host.py b/lib/ansible/inventory/host.py index b731dfcd82e..fea867382e0 100644 --- a/lib/ansible/inventory/host.py +++ b/lib/ansible/inventory/host.py @@ -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