mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Catch runtime errors due to recursion when calculating group depth
Fixes #7708
This commit is contained in:
parent
97954ff658
commit
ff251a0dcc
1 changed files with 7 additions and 3 deletions
|
@ -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:
|
||||||
|
|
||||||
def _check_children_depth(self):
|
def _check_children_depth(self):
|
||||||
|
|
||||||
|
try:
|
||||||
for group in self.child_groups:
|
for group in self.child_groups:
|
||||||
group.depth = max([self.depth+1, group.depth])
|
group.depth = max([self.depth+1, group.depth])
|
||||||
group._check_children_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):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue