Skip to content

Commit

Permalink
add Netbox v3.1.0 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoss authored Dec 7, 2021
1 parent 5e66fd6 commit 35323d3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/netbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ jobs:
- rockylinux8
- ubuntu2004
netbox:
- v3.1.0
- v3.0.12
- v3.0.11
- v3.0.10
- v3.0.9

services:
postgres:
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ansible Role: Netbox

[![Netbox](
https://img.shields.io/badge/Netbox-v3.0.12-blue)](https://github.com/netbox-community/netbox)
https://img.shields.io/badge/Netbox-v3.1.0-blue)](https://github.com/netbox-community/netbox)
[![CI](https://github.com/jvoss/ansible-role-netbox/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jvoss/ansible-role-netbox/actions/workflows/ci.yml)
[![Netbox](https://github.com/jvoss/ansible-role-netbox/actions/workflows/netbox.yml/badge.svg)](https://github.com/jvoss/ansible-role-netbox/actions/workflows/netbox.yml)
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-jvoss.netbox-blue.svg)](https://galaxy.ansible.com/jvoss/netbox)
Expand Down Expand Up @@ -42,6 +42,13 @@ on each playbook run.
See [defaults/main.yml](defaults/main.yml) for a complete list of defaults and
configurable options.

**Note**: Version 3.1+ introduced
[Dynamic Configuration Settings](https://netbox.readthedocs.io/en/stable/configuration/dynamic-settings/).
These configuration options may still be written to `configuration.py` preventing
modification via the UI. However, by default, this role *always* omits these
parameters unless `netbox_override_dynamic_config` is set to `True`. See
[defaults/main.yml#L82](defaults/main.yml#L82) for details.

## User accounts

The following variables can be defined to create users during initial
Expand Down
18 changes: 18 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ netbox_redis_tls_insecure: False

### Netbox Optional settings ###

# Override Netbox >= v3.1 Dynamic Configuration Settings by writing configuration
# parameters that have been moved to Netbox's admin interface:
# https://netbox.readthedocs.io/en/stable/configuration/dynamic-settings/
netbox_override_dynamic_config: False

# Specify one or more name and email address tuples representing NetBox
# administrators. These people will be notified of application errors (assuming
# correct email settings are provided).
Expand All @@ -87,6 +92,7 @@ netbox_admins: []
# - ['John Doe', 'jdoe@example.com']

# URL schemes that are allowed within links in Netbox
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_allowed_url_schemes:
- file
- ftp
Expand All @@ -106,11 +112,13 @@ netbox_allowed_url_schemes:
# Optionally display a persistent banner at the top and/or bottom of every page.
# HTML is allowed. To display the same content in both banners, define
# BANNER_TOP and set BANNER_BOTTOM = BANNER_TOP.
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_banner:
top:
bottom:

# Text to include on the login page above the login form. HTML is allowed.
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_banner_login:

# Base URL path if accessing NetBox within a directory. For example, if
Expand All @@ -120,6 +128,7 @@ netbox_base_path:

# Maximum number of days to retain logged changes. Set to 0 to retain changes
# indefinitely. (Default: 90)
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_changelog_retention: 90

# API Cross-Origin Resource Sharing (CORS) settings. If CORS_ORIGIN_ALLOW_ALL is set to
Expand Down Expand Up @@ -158,6 +167,7 @@ netbox_email:
# Enforcement of unique IP space can be toggled on a per-VRF basis. To enforce unique IP
# space within the global table (all prefixes and IP addresses not assigned to a VRF),
# set ENFORCE_GLOBAL_UNIQUE to True.
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_enforce_global_unique: False

# Exempt certain models from the enforcement of view permissions. Models listed here
Expand All @@ -166,6 +176,7 @@ netbox_enforce_global_unique: False
netbox_exempt_view_permissions: []

# Enable the GraphQL API
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_graphql_enabled: True

# HTTP proxies Nautobot should use when sending outbound HTTP requests
Expand Down Expand Up @@ -195,15 +206,18 @@ netbox_login_required: False
netbox_login_timeout: None

# Setting this to True will display a "maintenance mode" banner at the top of every page.
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_maintenance_mode: False

# The URL to use when mapping physical addresses or GPS coordinates
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_maps_url: https://maps.google.com/?q=

# An API consumer can request an arbitrary number of objects =by appending the "limit"
# parameter to the URL (e.g. "?limit=1000"). This setting defines the maximum limit.
# Setting it to 0 or None will allow an API consumer to request all objects by
# specifying "?limit=0".
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_max_page_size: 1000

# The file path where uploaded media such as image attachments are stored. A trailing
Expand All @@ -229,6 +243,7 @@ netbox_metrics_enabled: False

# Credentials that Netbox will uses to authenticate to devices when connecting
# via NAPALM.
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_napalm:
username: ''
password: ''
Expand All @@ -240,17 +255,20 @@ netbox_napalm:
args: {}

# Determine how many objects to display per page within a list. (Default: 50)
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_paginate_count: 50

# Netbox plugins. See README.md for plugin configuration details.
netbox_plugins: []

# When determining the primary IP address for a device, IPv6 is preferred over
# IPv4 by default. Set this to True to prefer IPv4 instead.
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_prefer_ipv4: False

# Rack elevation size defaults, in pixels. For best results, the ratio of width
# to height should be roughly 10:1.
# Note: Moved to Dynamic Configuration (see netbox_override_dynamic_config)
netbox_rack_elevation_default_unit_height: 22
netbox_rack_elevation_default_unit_width: 220

Expand Down
5 changes: 5 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
register: netbox_auth_ldap_requirements
when: netbox_auth_ldap is defined

- name: configure | set netbox_override_dynamic_config True for Netbox < 3.1.0
ansible.builtin.set_fact:
netbox_override_dynamic_config: True
when: netbox_version_tag < 'v3.1.0'

- name: configure | write configuration.py
ansible.builtin.template:
src: configuration.py.j2
Expand Down
26 changes: 26 additions & 0 deletions templates/configuration.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,23 @@ ADMINS = {{ netbox_admins|to_json }}
ADMINS = []
{% endif %}

{% if netbox_override_dynamic_config %}
ALLOWED_URL_SCHEMES = (
'{{ netbox_allowed_url_schemes | join("', '") }}',
)
{% endif %}

{% if netbox_override_dynamic_config %}
BANNER_TOP = '{{ netbox_banner.top }}'
BANNER_BOTTOM = '{{ netbox_banner.bottom }}'
BANNER_LOGIN = '{{ netbox_banner_login }}'
{% endif %}

BASE_PATH = '{{ netbox_base_path }}'

{% if netbox_override_dynamic_config %}
CHANGELOG_RETENTION = {{ netbox_changelog_retention }}
{% endif %}

CORS_ORIGIN_ALLOW_ALL = {{ netbox_origin_allow_all }}

Expand All @@ -87,6 +93,7 @@ CORS_ORIGIN_REGEX_WHITELIST = {{ netbox_cors_origin_regex_whitelist|to_json }}
CORS_ORIGIN_REGEX_WHITELIST = []
{% endif %}

{% if netbox_override_dynamic_config %}
# Specify any custom validators here, as a mapping of model to a list of validators classes. Validators should be
# instances of or inherit from CustomValidator.
# from extras.validators import CustomValidator
Expand All @@ -100,6 +107,7 @@ CUSTOM_VALIDATORS = {
# })
# ],
}
{% endif %}

DEBUG = {{ netbox_debug }}

Expand All @@ -114,15 +122,19 @@ EMAIL = {
'FROM_EMAIL': '{{ netbox_email.from_email }}',
}

{% if netbox_override_dynamic_config %}
ENFORCE_GLOBAL_UNIQUE = {{ netbox_enforce_global_unique }}
{% endif %}

{% if netbox_exempt_view_permissions|length > 0 %}
EXEMPT_VIEW_PERMISSIONS = {{ netbox_exempt_view_permissions|to_json }}
{% else %}
EXEMPT_VIEW_PERMISSIONS = []
{% endif %}

{% if netbox_override_dynamic_config %}
GRAPHQL_ENABLED = {{ netbox_graphql_enabled }}
{% endif %}

{% if netbox_http_proxies|length > 0 %}
HTTP_PROXIES = {{ netbox_http_proxies|to_json }}
Expand All @@ -140,11 +152,17 @@ LOGIN_REQUIRED = {{ netbox_login_required }}

LOGIN_TIMEOUT = {{ netbox_login_timeout }}

{% if netbox_override_dynamic_config %}
MAINTENANCE_MODE = {{ netbox_maintenance_mode }}
{% endif %}

{% if netbox_override_dynamic_config %}
MAPS_URL = '{{ netbox_maps_url }}'
{% endif %}

{% if netbox_override_dynamic_config %}
MAX_PAGE_SIZE = {{ netbox_max_page_size }}
{% endif %}

{% if netbox_media_root is defined %}
MEDIA_ROOT = '{{ netbox_media_root }}'
Expand All @@ -157,12 +175,16 @@ STORAGE_CONFIG = {{ netbox_storage.config|to_json }}

METRICS_ENABLED = {{ netbox_metrics_enabled }}

{% if netbox_override_dynamic_config %}
NAPALM_USERNAME = '{{ netbox_napalm.username }}'
NAPALM_PASSWORD = '{{ netbox_napalm.password }}'
NAPALM_TIMEOUT = {{ netbox_napalm.timeout }}
NAPALM_ARGS = {{ netbox_napalm.args|to_json }}
{% endif %}

{% if netbox_override_dynamic_config %}
PAGINATE_COUNT = {{ netbox_paginate_count }}
{% endif %}

PLUGINS = {{ netbox_plugins | map(attribute='name') | to_json }}

Expand All @@ -172,10 +194,14 @@ PLUGINS = {{ netbox_plugins | map(attribute='name') | to_json }}
{% endfor %}
PLUGINS_CONFIG = {{ plugins_config | to_json }}

{% if netbox_override_dynamic_config %}
PREFER_IPV4 = {{ netbox_prefer_ipv4 }}
{% endif %}

{% if netbox_override_dynamic_config %}
RACK_ELEVATION_DEFAULT_UNIT_HEIGHT = {{ netbox_rack_elevation_default_unit_height }}
RACK_ELEVATION_DEFAULT_UNIT_WIDTH = {{ netbox_rack_elevation_default_unit_width }}
{% endif %}

# Remote authentication support
REMOTE_AUTH_ENABLED = {{ netbox_remote_auth.enabled }}
Expand Down

0 comments on commit 35323d3

Please sign in to comment.