Avoid duplicated recursive calls in inventory CLI (#48598)

pull/44428/head
Alan Rominger 6 years ago committed by John R Barker
parent b4ce4e1571
commit d536be6530

@ -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)
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…
Cancel
Save