def apply_provider_facts(facts, provider_facts):
 if (not provider_facts):
  return facts
 common_vars = [('hostname', 'ip'), ('public_hostname', 'public_ip')]
 for (h_var, ip_var) in common_vars:
  ip_value = provider_facts['network'].get(ip_var)
  if ip_value:
   facts['common'][ip_var] = ip_value
  facts['common'][h_var] = choose_hostname([provider_facts['network'].get(h_var)], facts['common'][h_var])
 facts['provider'] = provider_facts
 return facts

def apply_provider_facts ( facts , provider_facts ) : if ( not provider_facts ) : return facts common_vars = [ ( 'hostname' , 'ip' ) , ( 'public_hostname' , 'public_ip' ) ] for ( h_var , ip_var ) in common_vars : ip_value = provider_facts [ 'network' ] . get ( ip_var ) if ip_value : facts [ 'common' ] [ ip_var ] = ip_value facts [ 'common' ] [ h_var ] = choose_hostname ( [ provider_facts [ 'network' ] . get ( h_var ) ] , facts [ 'common' ] [ h_var ] ) facts [ 'provider' ] = provider_facts return facts
apply provider facts to supplied facts dict args: facts : facts dict to update provider_facts : provider facts to apply roles: host roles returns: dict: the merged facts .