Add primary_ip_interface option to nb_inventory#1555
Conversation
Adds a new `primary_ip_interface` boolean option that exposes the interface name of the primary IP as a host var, without requiring `interfaces: true` which fetches all interfaces and is significantly slower. When only `primary_ip_interface` is set, a targeted fetch queries only the primary IP IDs already present on the fetched devices/VMs, rather than all IP addresses in NetBox. Closes netbox-community#1530
|
@sc68cal Would you be able to take a look at this one, when you have got the time? |
|
This seems like something that can already be done, via an |
|
I have to admit that I am not familiar with the nb_lookup query, where would I find the documentation for this? |
|
I think I got it now, looking into the nb_lookup plugin. Using the lookup_plugin would require me to run this task for all my hosts while having it in the inventory plugin makes primary_ip_interface available as a native host var before any play runs, just like primary_ip4 already. This is also consistent with how dns_name is already handled in the inventory plugin. |
Any thoughts on this @sc68cal? |
|
My concern is that we already have a couple of different ways that people want to connect to devices, by using different settings in the netbox inventory plugin. I don't think we should continue to add more and more different ways. If you have some preferred way to connect to your device based on netbox data that is not |
|
@sc68cal This is not used to connect to the device really, what I am mostly interested in is to retreive the primary interface name, so that I can populate this in different variables I have in my configuration. |
That's a usecase that the |
Summary
primary_ip_interfaceboolean option to thenb_inventoryplugin that exposes the interface name of the primary IP as a host var (primary_ip_interface)interfaces: true,dns_name: true, oransible_host_dns_name: true, the existing full IP fetch is reused with no duplicate requestsCloses #1530
Test plan
test_group_extractors)changelogs/fragments/1530-primary-ip-interface.yml)primary_ip_interface: truein an inventory config and verify theprimary_ip_interfacehost var is populated with the correct interface nameprimary_ip_interfacevar setprimary_ip_interface: false(default)