Added variable data field and resource on inventory. Updated inventory script to output inventory variables for the 'all' group.

This commit is contained in:
Chris Church
2013-06-14 20:09:55 -04:00
parent d47ea40d60
commit abd81b7492
10 changed files with 326 additions and 13 deletions

View File

@@ -32,15 +32,17 @@ class Command(NoArgsCommand):
group_info = {
'hosts': list(hosts.values_list('name', flat=True)),
'children': list(children.values_list('name', flat=True)),
'vars': group.variables_dict,
}
if group.variables:
group_info['vars'] = group.variables_dict
group_info = dict(filter(lambda x: bool(x[1]), group_info.items()))
if group_info.keys() in ([], ['hosts']):
groups[group.name] = group_info.get('hosts', [])
else:
groups[group.name] = group_info
if inventory.variables_dict:
groups['all'] = {
'vars': inventory.variables_dict,
}
self.stdout.write(json.dumps(groups, indent=indent))
def get_host(self, inventory, hostname, indent=None):