Skip to content

[Feature]: nb_inventory - allowing api_endpoint to be a variable #1300

@bookshark13

Description

@bookshark13

NetBox version

v3.19.1

Feature type

Change to existing Plugin

Proposed functionality

Not a big change to code if you add:
self.api_endpoint = self.templar.template( self.get_option("api_endpoint"), fail_on_undefined=False)
to the nb_inventory plugin at
this will allow for the api_endpoint the option of being a variable all while maintaining it's ability to be a string.

Use case

In current Netbox Module the api_endpoint variable can only be a string. Ex: "https://netbox.at.your.domain.com"
If you try to inject a variable for api_endpoint like so api_endpoint: "{{ lookup('ansible.builtin.env', 'NETBOX_URL') }}"
The plugin will output that "{{ lookup('ansible.builtin.env', 'NETBOX_URL') }}"/api/status is not valid.

If you manage multiple environments with possibly different domain names this is quite useful. It allows you to define once in the code and carry it over to multiple environments while maintaining a credential with things like Ansible Controller vs changing your code.

External dependencies

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions