def set_used_ips(user_defined_config, inventory):
 used_ips = user_defined_config.get('used_ips')
 if isinstance(used_ips, list):
  for ip in used_ips:
   split_ip = ip.split(',')
   if (len(split_ip) >= 2):
    ip_range = list(netaddr.iter_iprange(split_ip[0], split_ip[(-1)]))
    USED_IPS.update([str(i) for i in ip_range])
   else:
    logger.debug('IP %s set as used', split_ip[0])
    USED_IPS.add(split_ip[0])
 for host_entry in inventory['_meta']['hostvars'].values():
  networks = host_entry.get('container_networks', dict())
  for network_entry in networks.values():
   address = network_entry.get('address')
   if address:
    logger.debug('IP %s set as used', address)
    USED_IPS.add(address)

def set_used_ips ( user_defined_config , inventory ) : used_ips = user_defined_config . get ( 'used_ips' ) if isinstance ( used_ips , list ) : for ip in used_ips : split_ip = ip . split ( ',' ) if ( len ( split_ip ) >= 2 ) : ip_range = list ( netaddr . iter_iprange ( split_ip [ 0 ] , split_ip [ ( - 1 ) ] ) ) USED_IPS . update ( [ str ( i ) for i in ip_range ] ) else : logger . debug ( 'IP %s set as used' , split_ip [ 0 ] ) USED_IPS . add ( split_ip [ 0 ] ) for host_entry in inventory [ '_meta' ] [ 'hostvars' ] . values ( ) : networks = host_entry . get ( 'container_networks' , dict ( ) ) for network_entry in networks . values ( ) : address = network_entry . get ( 'address' ) if address : logger . debug ( 'IP %s set as used' , address ) USED_IPS . add ( address )
set all of the used ips into a global list .