From 1c8690987566a62e43638831db7ce69f7580896d Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Wed, 5 Mar 2014 16:37:33 +0100 Subject: [PATCH] inventory group: add groups to parent_groups only once --- lib/ansible/inventory/group.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/inventory/group.py b/lib/ansible/inventory/group.py index c5270ad554..94ee8eceba 100644 --- a/lib/ansible/inventory/group.py +++ b/lib/ansible/inventory/group.py @@ -41,7 +41,12 @@ class Group(object): if not group in self.child_groups: self.child_groups.append(group) group.depth = max([self.depth+1, group.depth]) - group.parent_groups.append(self) + + # now add self to child's parent_groups list, but only if there + # isn't already a group with the same name + if not self.name in [g.name for g in group.parent_groups]: + group.parent_groups.append(self) + self.clear_hosts_cache() def add_host(self, host):