Skip to content

[Bug]: nb_inventory fetches locations even when configured with racks: false (regression from rack_groups migration) #1451

@gs-adn

Description

@gs-adn

Ansible NetBox Collection version

v3.20.0

Ansible version

ansible [core 2.17.9]
  config file = repos/ansible/ansible.cfg
  configured module search path = ['repos/ansible/modules']
  ansible python module location = repos/ansible/.venv/lib/python3.12/site-packages/ansible
  ansible collection location = ~/.ansible/collections:/usr/share/ansible/collections
  executable location = repos/ansible/.venv/bin/ansible
  python version = 3.12.10 (main, Apr  9 2025, 03:49:38) [Clang 20.1.0 ] (repos/ansible/.venv/bin/python3)
  jinja version = 3.1.6
  libyaml = True

NetBox version

v4.2.7

Python version

3.11

Steps to Reproduce

netbox nb_inventory configuration:

plugin: netbox.netbox.nb_inventory
# api_endpoint: "Taken from NETBOX_API env var"
# token: "Taken from NETBOX_TOKEN ENV VAR"
cache: true
validate_certs: true
interfaces: false
fetch_all: false
plurals: false
racks: false
services: false
config_context: true
site_data: true
flatten_custom_fields: true
flatten_config_context: true
group_by:
  - role
  - site
  - region
group_names_raw: true
$ ansible-inventory --list 'all' -vv
[...]
Fetching: https://netbox/api/dcim/locations/?limit=1000&offset=1000
Fetching: https://netbox/api/dcim/locations/?limit=1000&offset=2000
Fetching: https://netbox/api/dcim/locations/?limit=1000&offset=3000
[...]

Expected Behavior

locations do not get looked up when the racks configuration parameter is set to false, since racks/rack groups won't get looked up either and locations are the replacement for rack groups

Observed Behavior

locations are always looked up regardless of the racks: configuration option, which can be very slow when there are many

Maybe if this is not considered a regression (which I think it is if we consider rack_groups to be the same thing as locations, but I guess it has grown additional features since then), this could be moved to a feature request to add a separate configuration option to disable looking up locations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions