Skip to content

[Bug]: Unable to use services in netbox inventory module #1430

@StoffelCPR

Description

@StoffelCPR

Ansible NetBox Collection version

devel

Ansible version

ansible [core 2.17.11]
  config file = /home/stoffel/Projects/tenants/aac-lintert-homelab/ansible.cfg
  configured module search path = ['/home/stoffel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/stoffel/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/stoffel/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/stoffel/.local/bin/ansible
  python version = 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.6
  libyaml = True

I had setup my ansible to use the dynamic inventory with services attached to VMs and Devices alike to roll out let's encrypt certificates, this randomly stopped working. After debugging for 2 hours I noticed that I didn't actually fuck up but the ansible-inventory doesn't return any services attached to either VMs or Devices. I hoped the latest netbox_service fixes would fix this but they don't

NetBox version

v4.3.2-Docker-3.3.0

Python version

3.10

Steps to Reproduce

Create a VM and attach a service to it of any kind.

Set your inventory to include service as follows:

plugin: netbox.netbox.nb_inventory
api_endpoint: http://your-netbox
token: your_valid_token
validate_certs: false
config_context: true
services: true
flatten_config_context: true
site_data: true
group_by:
  #- device_roles
  #- services
  - tags

defaults:
  groups:
    - all

You'd expect the service to be shown in your inventory but all you will see is an empty services list

                "services": [],                                                                                                                                                               

Expected Behavior

The services list to be filled with all the attached services

Observed Behavior

List was empty. Though services are attached to the VMs; curl on the API shows that services are properly returned and have a parent object and type

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