diff --git a/lib/ansible/inventory/group.py b/lib/ansible/inventory/group.py index 6f06cb07625..61ef1342bd2 100644 --- a/lib/ansible/inventory/group.py +++ b/lib/ansible/inventory/group.py @@ -35,9 +35,12 @@ class Group(object): if self == group: raise Exception("can't add group to itself") - self.child_groups.append(group) - group.depth = max([self.depth+1, group.depth]) - group.parent_groups.append(self) + + # don't add if it's already there + 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) def add_host(self, host):