def skel_setup(environment, inventory):
 for (key, value) in environment.iteritems():
  if (key == 'version'):
   continue
  for (_key, _value) in value.iteritems():
   if (_key not in inventory):
    logger.debug('Key %s added to inventory', _key)
    inventory[_key] = {}
    if _key.endswith('container'):
     if ('hosts' not in inventory[_key]):
      inventory[_key]['hosts'] = []
    else:
     if ('children' not in inventory[_key]):
      inventory[_key]['children'] = []
     if ('hosts' not in inventory[_key]):
      inventory[_key]['hosts'] = []
   if ('belongs_to' in _value):
    for assignment in _value['belongs_to']:
     if (assignment not in inventory):
      logger.debug('Created group %s', assignment)
      inventory[assignment] = {}
      if ('children' not in inventory[assignment]):
       inventory[assignment]['children'] = []
      if ('hosts' not in inventory[assignment]):
       inventory[assignment]['hosts'] = []

def skel_setup ( environment , inventory ) : for ( key , value ) in environment . iteritems ( ) : if ( key == 'version' ) : continue for ( _key , _value ) in value . iteritems ( ) : if ( _key not in inventory ) : logger . debug ( 'Key %s added to inventory' , _key ) inventory [ _key ] = { } if _key . endswith ( 'container' ) : if ( 'hosts' not in inventory [ _key ] ) : inventory [ _key ] [ 'hosts' ] = [ ] else : if ( 'children' not in inventory [ _key ] ) : inventory [ _key ] [ 'children' ] = [ ] if ( 'hosts' not in inventory [ _key ] ) : inventory [ _key ] [ 'hosts' ] = [ ] if ( 'belongs_to' in _value ) : for assignment in _value [ 'belongs_to' ] : if ( assignment not in inventory ) : logger . debug ( 'Created group %s' , assignment ) inventory [ assignment ] = { } if ( 'children' not in inventory [ assignment ] ) : inventory [ assignment ] [ 'children' ] = [ ] if ( 'hosts' not in inventory [ assignment ] ) : inventory [ assignment ] [ 'hosts' ] = [ ]
build out the main inventory skeleton as needed .