2024-04-28 08:59:32 +00:00
|
|
|
# Make expensive lookups to NetBox once for later reference by any host.
|
|
|
|
- name: Lookup networks and prefixes
|
|
|
|
set_fact:
|
|
|
|
vlans: '{{ query("netbox.netbox.nb_lookup", "vlans", api_filter="group=new-net", raw_data=true)
|
|
|
|
| sort(attribute="vid") }}'
|
2024-07-15 09:28:33 +00:00
|
|
|
vrfs: '{{ query("netbox.netbox.nb_lookup", "vrfs", raw_data=true) | list2dict("name") }}'
|
2024-04-28 08:59:32 +00:00
|
|
|
prefixes: '{{ query("netbox.netbox.nb_lookup", "prefixes", raw_data=true)
|
|
|
|
| sort(attribute="prefix") | sort(attribute="family.value") }}'
|
|
|
|
|
|
|
|
- name: Select VLAN and BGP prefixes
|
|
|
|
set_fact:
|
|
|
|
vrf_prefixes: '{{ prefixes | selectattr("vrf")
|
|
|
|
| selectattr("vlan") | selectattr("vlan.id", "in", vlans|map(attribute="id"))
|
|
|
|
| sort(attribute="vlan.vid") }}'
|
|
|
|
bgp_prefixes: '{{ prefixes | selectattr("tenant")
|
|
|
|
| selectattr("role") | selectattr("role.slug", "==", "bgp")
|
|
|
|
| sort(attribute="tenant.slug") }}'
|