From ff251a0dcc69249b4da1f0770bb1356b9f8391c2 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 22 Jun 2015 02:06:07 -0400 Subject: [PATCH] Catch runtime errors due to recursion when calculating group depth Fixes #7708 --- lib/ansible/inventory/group.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/inventory/group.py b/lib/ansible/inventory/group.py index 17f3ff744f..8dbda63156 100644 --- a/lib/ansible/inventory/group.py +++ b/lib/ansible/inventory/group.py @@ -17,6 +17,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +from ansible.errors import AnsibleError from ansible.utils.debug import debug class Group: @@ -99,9 +100,12 @@ class Group: def _check_children_depth(self): - for group in self.child_groups: - group.depth = max([self.depth+1, group.depth]) - group._check_children_depth() + try: + for group in self.child_groups: + group.depth = max([self.depth+1, group.depth]) + group._check_children_depth() + except RuntimeError: + raise AnsibleError("The group named '%s' has a recursive dependency loop." % self.name) def add_host(self, host):