def build_dict():
 containers = dict([(c, (['all'] + (lxc.Container(c).get_config_item('lxc.group') or []))) for c in lxc.list_containers()])
 groups = set(sum([g for g in containers.values()], []))
 return dict([(g, {'hosts': [k for (k, v) in containers.items() if (g in v)], 'vars': {'ansible_connection': 'lxc'}}) for g in groups])

def build_dict ( ) : containers = dict ( [ ( c , ( [ 'all' ] + ( lxc . Container ( c ) . get_config_item ( 'lxc.group' ) or [ ] ) ) ) for c in lxc . list_containers ( ) ] ) groups = set ( sum ( [ g for g in containers . values ( ) ] , [ ] ) ) return dict ( [ ( g , { 'hosts' : [ k for ( k , v ) in containers . items ( ) if ( g in v ) ] , 'vars' : { 'ansible_connection' : 'lxc' } } ) for g in groups ] )
returns a dictionary keyed to the defined lxc groups .