netbox adapter

Inmanta module to manage netbox inventory

Features

The module supports all existing netbox resources used for networking documentation. Netbox-Secret is also supported.

Environment variables

Env variable name

Description

NETBOX_USER

Netbox username, only required if you use netbox-secrets.

NETBOX_PASSWORD

Netbox password, only required if you use netbox-secrets.

NETBOX_API_TOKEN

Netbox api token, used as main credentials to interact with netbox.
Only required if you use netbox::Credentials with api_token_env_var.

Netbox-Secret

All information relative to Netbox-Secret can be found in the secret.md file

Usage example

This simple example shows how to document a Device (server-1) with its cluster, rack, site and tenant:

import netbox
import netbox::resources
import restbase

credentials = netbox::Credentials(
    url="http://1.2.3.4:8000",
    api_token="abcdefg",
    agent_autostart=false
)

tenant_group=netbox::resources::TenantGroup(
    credentials=credentials,
    name="tenant_group_1",
    slug="tenant_group_1",
    purged=false,
)

tenant=netbox::resources::Tenant(
    credentials=credentials,
    name="tenant1",
    slug="tenant1",
    group=tenant_group,
    purged=false,
)

site = netbox::resources::Site(
    credentials=credentials,
    name="SITE",
    slug="site",
    tenant=tenant,
    purged=false,
)

rack1 = netbox::resources::Rack(
    credentials=credentials,
    name="rack-1",
    site=site,
    tenant=tenant,
    purged=false,
)

lenovo = netbox::resources::Manufacturer(
    credentials=credentials,
    name="Lenovo",
    slug="lenovo",
    purged=false
)

se450 = netbox::resources::DeviceType(
    credentials=credentials,
    model="SE450",
    slug="se450",
    manufacturer=lenovo,
    purged=false,
)

server_role = netbox::resources::DeviceRole(
    credentials=credentials,
    name="server",
    slug="server",
    purged=false,
)

cluster_type = netbox::resources::ClusterType(
    credentials=credentials,
    name="esxi",
    slug="esxi",
    purged=false
)

cluster1 = netbox::resources::Cluster(
    credentials=credentials,
    type=cluster_type,
    name="server-1",
    site=site,
    tenant=tenant,
    purged=false,
)

device_server = netbox::resources::Device(
    credentials=credentials,
    name="server-1",
    site=site,
    rack=rack1,
    tenant=tenant,
    device_type = se450,
    role = server_role,
    cluster=cluster1,
    purged=false
)