ansible-infra/roles/netbox
June a71071dfcc
Some checks failed
/ Ansible Lint (push) Failing after 1m10s
/ Ansible Lint (pull_request) Successful in 1m39s
add option to NetBox role for patch. NetBox for OIDC group and role map.
Add option to NetBox role to make it patch NetBox to add custom pipeline
code for OIDC group and role mapping.

The custom pipeline code is licensed under the Creative Commons: CC
BY-SA 4.0 license.

See:
https://github.com/goauthentik/authentik/blob/main/LICENSE
https://github.com/goauthentik/authentik/blob/main/website/integrations/services/netbox/index.md
https://docs.goauthentik.io/integrations/services/netbox/
5676b1a468
2025-02-15 04:20:29 +01:00
..
defaults add option to NetBox role for patch. NetBox for OIDC group and role map. 2025-02-15 04:20:29 +01:00
files add option to NetBox role for patch. NetBox for OIDC group and role map. 2025-02-15 04:20:29 +01:00
handlers add netbox role for ensuring netbox is deployed as specified 2025-02-14 21:43:44 +01:00
meta add option to NetBox role for patch. NetBox for OIDC group and role map. 2025-02-15 04:20:29 +01:00
tasks add option to NetBox role for patch. NetBox for OIDC group and role map. 2025-02-15 04:20:29 +01:00
README.md add option to NetBox role for patch. NetBox for OIDC group and role map. 2025-02-15 04:20:29 +01:00

netbox role

A role for setting up NetBox.
It automatically pulls in all required dependencies like Redis and PostgreSQL, deploys the provided systemd services and gunicorn config and sets up a PostgreSQL database named netbox with an owner named netbox and the specified password. However providing the NetBox configuration, setting up a web server like nginx to proxy to gunicorn and tasks like creating users, etc. you have to do yourself.

Supported Distributions

Should work on Debian-based distributions.

Required Arguments

  • netbox__version: The NetBox version to deploy.
  • netbox__db_password: The password to use for connection to the database. This is required since the upgrade script runs as root and therefore peer authentication doesn't work.
  • netbox__config: The NetBox config to deploy. See NetBox Configuration for more infos.

Optional Arguments

NetBox Configuration

The NetBox configuration should include a connection to Redis as well as a connection to PostgreSQL.
Configuration for the Redis connection:

REDIS = {
    "tasks": {
      "HOST": "localhost",
      "PORT": 6379,
      "USERNAME": "",
      "PASSWORD": "",
      "DATABASE": 0,
      "SSL": False,
    },
    "caching": {
      "HOST": "localhost",
      "PORT": 6379,
      "USERNAME": "",
      "PASSWORD": "",
      "DATABASE": 1,
      "SSL": False,
    },
}

Configuration for the PostgreSQL connection:

DATABASE = {
  "HOST": "localhost",
  "NAME": "netbox",
  "USER": "netbox",
  "PASSWORD": "<same as netbox__db_password>",
}

Further configuration should take place. Some relevant resources can be found here:

Web Server Setup

As this role just sets up gunicorn, but doesn't set up a web server, you need to do that yourself.
The relevant documentation on how to do that can be found here:

Custom Pipeline Code for OIDC Group and Role Mapping

Setting the option netbox__patch_oidc_group_and_role_mapping_custom_pipeline to true makes this role patch NetBox to add custom pipeline code for OIDC group and role mapping. Note that this role uses a patch for NetBox >= 4.0.0.
The patch is available in files/0001_oidc_group_and_role_mapping_custom_pipeline.patch, licensed under the CC BY-SA 4.0 license and taken from this authentik NetBox documentation. The documentation also shows how to use the pipeline code by defining a custom SOCIAL_AUTH_PIPELINE, which you also need to do, as the configuration isn't provided by this role. See also the default settings.py for the default SOCIAL_AUTH_PIPELINE.