Add parent prefixes information to ansible nb_inventory plugin #4752

Closed
opened 2025-12-29 19:20:07 +01:00 by adam · 1 comment
Owner

Originally created by @kemeris2000 on GitHub (Apr 12, 2021).

NetBox version

v2.10.8

Feature type

Change to existing functionality

Proposed functionality

Add parent prefixes information to host vars in ansible nb_inventory plugin.

Use case

We use netbox prefix roles to define purpose of subnet, for example LAN, KVM, Docker. Once installing daemons (for example sshd) using ansible on linux machines, we define prefix role for address on which sshd should listen and querying netbox to find corresponding IP. This involve two steps: get prefixes with certain name, and get all hots IP's which are in these prefixes.

It would be great to include parent prefix for all host IP's in nb_inventory plugin:

{
  "interfaces": [
    {
      "cable": {
        "id": 1,
        "label": "",
        "url": "http://xxx.yyy.com/api/dcim/cables/1/",
        "ip_addresses": [
          {
            "address": "10.0.0.2/24",
            "created": "2021-03-25",
            "prefixes": [
              {
                "id": 1,
                "url": "http://xxx.yyy.com/api/ipam/prefixes/1/",
                "family": {
                  "value": 4,
                  "label": "IPv4"
                },
                "prefix": "10.0.0.0/24"
              }
            ]
          }
        ]
      }
    }
  ]
}

Database changes

none

External dependencies

none

Originally created by @kemeris2000 on GitHub (Apr 12, 2021). ### NetBox version v2.10.8 ### Feature type Change to existing functionality ### Proposed functionality Add parent prefixes information to host vars in ansible nb_inventory plugin. ### Use case We use netbox prefix roles to define purpose of subnet, for example LAN, KVM, Docker. Once installing daemons (for example sshd) using ansible on linux machines, we define prefix role for address on which sshd should listen and querying netbox to find corresponding IP. This involve two steps: get prefixes with certain name, and get all hots IP's which are in these prefixes. It would be great to include parent prefix for all host IP's in nb_inventory plugin: ``` { "interfaces": [ { "cable": { "id": 1, "label": "", "url": "http://xxx.yyy.com/api/dcim/cables/1/", "ip_addresses": [ { "address": "10.0.0.2/24", "created": "2021-03-25", "prefixes": [ { "id": 1, "url": "http://xxx.yyy.com/api/ipam/prefixes/1/", "family": { "value": 4, "label": "IPv4" }, "prefix": "10.0.0.0/24" } ] } ] } } ] } ``` ### Database changes none ### External dependencies none
adam added the type: feature label 2025-12-29 19:20:07 +01:00
adam closed this issue 2025-12-29 19:20:07 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 12, 2021):

This repository is for NetBox itself. You'll need to submit any feature requests for the Ansible inventory plugin to that project.

@jeremystretch commented on GitHub (Apr 12, 2021): This repository is for NetBox itself. You'll need to submit any feature requests for the Ansible inventory plugin to that project.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4752