And group them into vrf_prefixes for VLAN networks and bgp_prefixes for servers plugged directly into fabric. This should reduce the number of queries to NetBox when configuring firewalls and exit switches. Not sure but I think set_fact helps to avoid queries (as opposed to setting group_vars).
		
			
				
	
	
		
			9 lines
		
	
	
	
		
			371 B
		
	
	
	
		
			Django/Jinja
		
	
	
	
	
	
			
		
		
	
	
			9 lines
		
	
	
	
		
			371 B
		
	
	
	
		
			Django/Jinja
		
	
	
	
	
	
| {% for family, family_prefixes in vrf_prefixes | groupby('family.value') %}
 | |
| {% for vlan, vlan_prefixes in family_prefixes | groupby('vlan.vid') %}
 | |
| set {{ vlan_prefixes[0].vlan.name }}{% if family == 6 %}/6{% endif %} {
 | |
|     type ipv{{ family }}_addr; flags interval
 | |
|     elements = { {{ vlan_prefixes | map(attribute='prefix') | join(',') }} }
 | |
| }
 | |
| {% endfor %}
 | |
| 
 | |
| {% endfor %}
 |