Avoid duplicated recursive calls in inventory CLI (#48598)
This commit is contained in:
parent
b4ce4e1571
commit
d536be6530
1 changed files with 5 additions and 1 deletions
|
@ -324,6 +324,8 @@ class InventoryCLI(CLI):
|
|||
|
||||
def json_inventory(self, top):
|
||||
|
||||
seen = set()
|
||||
|
||||
def format_group(group):
|
||||
results = {}
|
||||
results[group.name] = {}
|
||||
|
@ -332,7 +334,9 @@ class InventoryCLI(CLI):
|
|||
results[group.name]['children'] = []
|
||||
for subgroup in sorted(group.child_groups, key=attrgetter('name')):
|
||||
results[group.name]['children'].append(subgroup.name)
|
||||
results.update(format_group(subgroup))
|
||||
if subgroup.name not in seen:
|
||||
results.update(format_group(subgroup))
|
||||
seen.add(subgroup.name)
|
||||
if self.options.export:
|
||||
results[group.name]['vars'] = self._get_group_variables(group)
|
||||
|
||||
|
|
Loading…
Reference in a new issue