|
|
@ -324,6 +324,8 @@ class InventoryCLI(CLI):
|
|
|
|
|
|
|
|
|
|
|
|
def json_inventory(self, top):
|
|
|
|
def json_inventory(self, top):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
seen = set()
|
|
|
|
|
|
|
|
|
|
|
|
def format_group(group):
|
|
|
|
def format_group(group):
|
|
|
|
results = {}
|
|
|
|
results = {}
|
|
|
|
results[group.name] = {}
|
|
|
|
results[group.name] = {}
|
|
|
@ -332,7 +334,9 @@ class InventoryCLI(CLI):
|
|
|
|
results[group.name]['children'] = []
|
|
|
|
results[group.name]['children'] = []
|
|
|
|
for subgroup in sorted(group.child_groups, key=attrgetter('name')):
|
|
|
|
for subgroup in sorted(group.child_groups, key=attrgetter('name')):
|
|
|
|
results[group.name]['children'].append(subgroup.name)
|
|
|
|
results[group.name]['children'].append(subgroup.name)
|
|
|
|
|
|
|
|
if subgroup.name not in seen:
|
|
|
|
results.update(format_group(subgroup))
|
|
|
|
results.update(format_group(subgroup))
|
|
|
|
|
|
|
|
seen.add(subgroup.name)
|
|
|
|
if self.options.export:
|
|
|
|
if self.options.export:
|
|
|
|
results[group.name]['vars'] = self._get_group_variables(group)
|
|
|
|
results[group.name]['vars'] = self._get_group_variables(group)
|
|
|
|
|
|
|
|
|
|
|
|