def export_host_info(inventory):
 export_info = {'hosts': {}}
 host_info = export_info['hosts']
 export_info['all'] = inventory['all']['vars']
 for (host, hostvars) in inventory['_meta']['hostvars'].items():
  host_info[host] = {}
  host_info[host]['hostvars'] = hostvars
 for (group_name, group_info) in inventory.items():
  if (group_name in ('_meta', 'all')):
   continue
  for host in group_info['hosts']:
   if ('groups' not in host_info[host]):
    host_info[host]['groups'] = []
   host_info[host]['groups'].append(group_name)
 return export_info

def export_host_info ( inventory ) : export_info = { 'hosts' : { } } host_info = export_info [ 'hosts' ] export_info [ 'all' ] = inventory [ 'all' ] [ 'vars' ] for ( host , hostvars ) in inventory [ '_meta' ] [ 'hostvars' ] . items ( ) : host_info [ host ] = { } host_info [ host ] [ 'hostvars' ] = hostvars for ( group_name , group_info ) in inventory . items ( ) : if ( group_name in ( '_meta' , 'all' ) ) : continue for host in group_info [ 'hosts' ] : if ( 'groups' not in host_info [ host ] ) : host_info [ host ] [ 'groups' ] = [ ] host_info [ host ] [ 'groups' ] . append ( group_name ) return export_info
pivot variable information to be a per-host dict this command is meant for exporting an existing inventorys information .