Commit ff251a0d by James Cammarata

Catch runtime errors due to recursion when calculating group depth

Fixes #7708
parent 97954ff6
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from ansible.errors import AnsibleError
from ansible.utils.debug import debug from ansible.utils.debug import debug
class Group: class Group:
...@@ -99,9 +100,12 @@ class Group: ...@@ -99,9 +100,12 @@ class Group:
def _check_children_depth(self): def _check_children_depth(self):
for group in self.child_groups: try:
group.depth = max([self.depth+1, group.depth]) for group in self.child_groups:
group._check_children_depth() 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): def add_host(self, host):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment