Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit f17a296

Browse files
committed
Add the Golden Config Plugin
1 parent 0ddf08c commit f17a296

File tree

3 files changed

+309
-0
lines changed

3 files changed

+309
-0
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ ARG NAUTOBOT_VERSION=1.4.2
22
ARG PYTHON_VERSION=3.9
33
FROM ghcr.io/nautobot/nautobot:${NAUTOBOT_VERSION}-py${PYTHON_VERSION}
44

5+
COPY requirements.txt /tmp/
6+
7+
RUN pip install -r /tmp/requirements.txt
8+
9+
COPY ./configuration/nautobot_config.py /opt/nautobot/

configuration/nautobot_config.py

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
import os
2+
import sys
3+
4+
from nautobot.core.settings import * # noqa F401,F403
5+
from nautobot.core.settings_funcs import is_truthy, parse_redis_connection
6+
7+
#########################
8+
# #
9+
# Required settings #
10+
# #
11+
#########################
12+
13+
# This is a list of valid fully-qualified domain names (FQDNs) for the Nautobot server. Nautobot will not permit write
14+
# access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name.
15+
#
16+
# Example: ALLOWED_HOSTS = ['nautobot.example.com', 'nautobot.internal.local']
17+
ALLOWED_HOSTS = os.getenv("NAUTOBOT_ALLOWED_HOSTS", "").split(" ")
18+
19+
# Database configuration. See the Django documentation for a complete list of available parameters:
20+
# https://docs.djangoproject.com/en/stable/ref/settings/#databases
21+
DATABASES = {
22+
"default": {
23+
"NAME": os.getenv("NAUTOBOT_DB_NAME", "nautobot"), # Database name
24+
"USER": os.getenv("NAUTOBOT_DB_USER", ""), # Database username
25+
"PASSWORD": os.getenv("NAUTOBOT_DB_PASSWORD", ""), # Database password
26+
"HOST": os.getenv("NAUTOBOT_DB_HOST", "localhost"), # Database server
27+
"PORT": os.getenv("NAUTOBOT_DB_PORT", ""), # Database port (leave blank for default)
28+
"CONN_MAX_AGE": int(os.getenv("NAUTOBOT_DB_TIMEOUT", "300")), # Database timeout
29+
"ENGINE": os.getenv(
30+
"NAUTOBOT_DB_ENGINE", "django.db.backends.postgresql"
31+
), # Database driver ("mysql" or "postgresql")
32+
}
33+
}
34+
35+
# Ensure proper Unicode handling for MySQL
36+
if DATABASES["default"]["ENGINE"] == "django.db.backends.mysql":
37+
DATABASES["default"]["OPTIONS"] = {"charset": "utf8mb4"}
38+
39+
# Nautobot uses RQ for task scheduling. These are the following defaults.
40+
# For detailed configuration see: https://github.com/rq/django-rq#installation
41+
# These defaults utilize the Django `CACHES` setting defined above for django-redis.
42+
# See: https://github.com/rq/django-rq#support-for-django-redis-and-django-redis-cache
43+
RQ_QUEUES = {
44+
"default": {
45+
"USE_REDIS_CACHE": "default",
46+
},
47+
"check_releases": {
48+
"USE_REDIS_CACHE": "default",
49+
},
50+
"custom_fields": {
51+
"USE_REDIS_CACHE": "default",
52+
},
53+
"webhooks": {
54+
"USE_REDIS_CACHE": "default",
55+
},
56+
}
57+
58+
# Nautobot uses Cacheops for database query caching. These are the following defaults.
59+
# For detailed configuration see: https://github.com/Suor/django-cacheops#setup
60+
CACHEOPS_REDIS = os.getenv("NAUTOBOT_CACHEOPS_REDIS", parse_redis_connection(redis_database=1))
61+
62+
# The django-redis cache is used to establish concurrent locks using Redis. The
63+
# django-rq settings will use the same instance/database by default.
64+
CACHES = {
65+
"default": {
66+
"BACKEND": "django_redis.cache.RedisCache",
67+
"LOCATION": parse_redis_connection(redis_database=0),
68+
"TIMEOUT": 300,
69+
"OPTIONS": {
70+
"CLIENT_CLASS": "django_redis.client.DefaultClient",
71+
},
72+
}
73+
}
74+
75+
# This key is used for secure generation of random numbers and strings. It must never be exposed outside of this file.
76+
# For optimal security, SECRET_KEY should be at least 50 characters in length and contain a mix of letters, numbers, and
77+
# symbols. Nautobot will not run without this defined. For more information, see
78+
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-SECRET_KEY
79+
SECRET_KEY = os.getenv("NAUTOBOT_SECRET_KEY", "hs&r^dpbo&j$zy)s&bjylvo!r54-s*=v9(3nurue6zc2r)kwmb")
80+
81+
82+
#########################
83+
# #
84+
# Optional settings #
85+
# #
86+
#########################
87+
88+
# Specify one or more name and email address tuples representing Nautobot administrators. These people will be notified of
89+
# application errors (assuming correct email settings are provided).
90+
ADMINS = [
91+
# ['John Doe', '[email protected]'],
92+
]
93+
94+
# URL schemes that are allowed within links in Nautobot
95+
ALLOWED_URL_SCHEMES = (
96+
"file",
97+
"ftp",
98+
"ftps",
99+
"http",
100+
"https",
101+
"irc",
102+
"mailto",
103+
"sftp",
104+
"ssh",
105+
"tel",
106+
"telnet",
107+
"tftp",
108+
"vnc",
109+
"xmpp",
110+
)
111+
112+
# Cache timeout in seconds. Cannot be 0. Defaults to 900 (15 minutes). To disable caching, set CACHEOPS_ENABLED to False
113+
CACHEOPS_DEFAULTS = {"timeout": int(os.getenv("NAUTOBOT_CACHEOPS_TIMEOUT", "900"))}
114+
115+
# Set to False to disable caching with cacheops. (Default: True)
116+
CACHEOPS_ENABLED = is_truthy(os.getenv("NAUTOBOT_CACHEOPS_ENABLED", "True"))
117+
118+
# If True, all origins will be allowed. Other settings restricting allowed origins will be ignored.
119+
# Defaults to False. Setting this to True can be dangerous, as it allows any website to make
120+
# cross-origin requests to yours. Generally you'll want to restrict the list of allowed origins with
121+
# CORS_ALLOWED_ORIGINS or CORS_ALLOWED_ORIGIN_REGEXES.
122+
CORS_ALLOW_ALL_ORIGINS = is_truthy(os.getenv("NAUTOBOT_CORS_ALLOW_ALL_ORIGINS", "False"))
123+
124+
# A list of origins that are authorized to make cross-site HTTP requests. Defaults to [].
125+
CORS_ALLOWED_ORIGINS = [
126+
# 'https://hostname.example.com',
127+
]
128+
129+
# A list of strings representing regexes that match Origins that are authorized to make cross-site
130+
# HTTP requests. Defaults to [].
131+
CORS_ALLOWED_ORIGIN_REGEXES = [
132+
# r'^(https?://)?(\w+\.)?example\.com$',
133+
]
134+
135+
# FQDNs that are considered trusted origins for secure, cross-domain, requests such as HTTPS POST.
136+
# If running Nautobot under a single domain, you may not need to set this variable;
137+
# if running on multiple domains, you *may* need to set this variable to more or less the same as ALLOWED_HOSTS above.
138+
# https://docs.djangoproject.com/en/stable/ref/settings/#csrf-trusted-origins
139+
CSRF_TRUSTED_ORIGINS = []
140+
141+
# Set to True to enable server debugging. WARNING: Debugging introduces a substantial performance penalty and may reveal
142+
# sensitive information about your installation. Only enable debugging while performing testing. Never enable debugging
143+
# on a production system.
144+
DEBUG = is_truthy(os.getenv("NAUTOBOT_DEBUG", "False"))
145+
146+
# Enforcement of unique IP space can be toggled on a per-VRF basis. To enforce unique IP space
147+
# within the global table (all prefixes and IP addresses not assigned to a VRF), set
148+
# ENFORCE_GLOBAL_UNIQUE to True.
149+
ENFORCE_GLOBAL_UNIQUE = is_truthy(os.getenv("NAUTOBOT_ENFORCE_GLOBAL_UNIQUE", "False"))
150+
151+
# Exempt certain models from the enforcement of view permissions. Models listed here will be viewable by all users and
152+
# by anonymous users. List models in the form `<app>.<model>`. Add '*' to this list to exempt all models.
153+
EXEMPT_VIEW_PERMISSIONS = [
154+
# 'dcim.site',
155+
# 'dcim.region',
156+
# 'ipam.prefix',
157+
]
158+
159+
# Global 3rd-party authentication settings
160+
EXTERNAL_AUTH_DEFAULT_GROUPS = []
161+
EXTERNAL_AUTH_DEFAULT_PERMISSIONS = {}
162+
163+
# If hosting Nautobot in a subdirectory, you must set this value to match the base URL prefix configured in your HTTP server (e.g. `/nautobot/`). When not set, URLs will default to being prefixed by `/`.
164+
FORCE_SCRIPT_NAME = None
165+
166+
# HTTP proxies Nautobot should use when sending outbound HTTP requests (e.g. for webhooks).
167+
# HTTP_PROXIES = {
168+
# 'http': 'http://10.10.1.10:3128',
169+
# 'https': 'http://10.10.1.10:1080',
170+
# }
171+
172+
# IP addresses recognized as internal to the system. The debugging toolbar will be available only to clients accessing
173+
# Nautobot from an internal IP.
174+
INTERNAL_IPS = ("127.0.0.1", "::1")
175+
176+
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
177+
# https://docs.djangoproject.com/en/stable/topics/logging/
178+
LOGGING = {}
179+
180+
# Setting this to True will display a "maintenance mode" banner at the top of every page.
181+
MAINTENANCE_MODE = is_truthy(os.getenv("NAUTOBOT_MAINTENANCE_MODE", "False"))
182+
183+
# The file path where uploaded media such as image attachments are stored. A trailing slash is not needed. Note that
184+
# the default value of this setting is within the invoking user's home directory
185+
# MEDIA_ROOT = os.path.expanduser('~/.nautobot/media')
186+
187+
# By default uploaded media is stored on the local filesystem. Using Django-storages is also supported. Provide the
188+
# class path of the storage driver in STORAGE_BACKEND and any configuration options in STORAGE_CONFIG. For example:
189+
# STORAGE_BACKEND = 'storages.backends.s3boto3.S3Boto3Storage'
190+
# STORAGE_CONFIG = {
191+
# 'AWS_ACCESS_KEY_ID': 'Key ID',
192+
# 'AWS_SECRET_ACCESS_KEY': 'Secret',
193+
# 'AWS_STORAGE_BUCKET_NAME': 'nautobot',
194+
# 'AWS_S3_REGION_NAME': 'eu-west-1',
195+
# }
196+
197+
# Expose Prometheus monitoring metrics at the HTTP endpoint '/metrics'
198+
METRICS_ENABLED = is_truthy(os.getenv("NAUTOBOT_METRICS_ENABLED", "False"))
199+
200+
# Credentials that Nautobot will uses to authenticate to devices when connecting via NAPALM.
201+
NAPALM_USERNAME = os.getenv("NAUTOBOT_NAPALM_USERNAME", "")
202+
NAPALM_PASSWORD = os.getenv("NAUTOBOT_NAPALM_PASSWORD", "")
203+
204+
# NAPALM timeout (in seconds). (Default: 30)
205+
NAPALM_TIMEOUT = int(os.getenv("NAUTOBOT_NAPALM_TIMEOUT", "30"))
206+
207+
# NAPALM optional arguments (see https://napalm.readthedocs.io/en/latest/support/#optional-arguments). Arguments must
208+
# be provided as a dictionary.
209+
NAPALM_ARGS = {}
210+
211+
# Enable installed plugins. Add the name of each plugin to the list.
212+
PLUGINS = ["nautobot_plugin_nornir", "nautobot_golden_config"]
213+
214+
PLUGINS_CONFIG = {
215+
"nautobot_plugin_nornir": {
216+
"nornir_settings": {
217+
"credentials": "nautobot_plugin_nornir.plugins.credentials.env_vars.CredentialsEnvVars",
218+
"runner": {
219+
"plugin": "threaded",
220+
"options": {
221+
"num_workers": 20,
222+
},
223+
},
224+
},
225+
},
226+
"nautobot_golden_config": {
227+
"per_feature_bar_width": 0.15,
228+
"per_feature_width": 13,
229+
"per_feature_height": 4,
230+
"enable_backup": True,
231+
"enable_compliance": True,
232+
"enable_intended": True,
233+
"enable_sotagg": True,
234+
"sot_agg_transposer": None,
235+
"platform_slug_map": None,
236+
# "get_custom_compliance": "my.custom_compliance.func"
237+
},
238+
}
239+
240+
# Remote auth backend settings
241+
REMOTE_AUTH_AUTO_CREATE_USER = False
242+
REMOTE_AUTH_HEADER = "HTTP_REMOTE_USER"
243+
244+
# The length of time (in seconds) for which a user will remain logged into the web UI before being prompted to
245+
# re-authenticate. (Default: 1209600 [14 days])
246+
SESSION_COOKIE_AGE = int(os.getenv("NAUTOBOT_SESSION_COOKIE_AGE", "1209600")) # 2 weeks, in seconds
247+
248+
# By default, Nautobot will store session data in the database. Alternatively, a file path can be specified here to use
249+
# local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only
250+
# database access.) Note that the user as which Nautobot runs must have read and write permissions to this path.
251+
SESSION_FILE_PATH = os.getenv("NAUTOBOT_SESSION_FILE_PATH", None)
252+
253+
# Configure SSO, for more information see docs/configuration/authentication/sso.md
254+
SOCIAL_AUTH_POSTGRES_JSONFIELD = False
255+
256+
# Reject invalid UI/API filter parameters, or discard them while logging a warning?
257+
STRICT_FILTERING = is_truthy(os.getenv("NAUTOBOT_STRICT_FILTERING", "True"))
258+
259+
# Time zone (default: UTC)
260+
TIME_ZONE = os.getenv("NAUTOBOT_TIME_ZONE", "UTC")
261+
262+
# Date/time formatting. See the following link for supported formats:
263+
# https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
264+
DATE_FORMAT = os.getenv("NAUTOBOT_DATE_FORMAT", "N j, Y")
265+
SHORT_DATE_FORMAT = os.getenv("NAUTOBOT_SHORT_DATE_FORMAT", "Y-m-d")
266+
TIME_FORMAT = os.getenv("NAUTOBOT_TIME_FORMAT", "g:i a")
267+
SHORT_TIME_FORMAT = os.getenv("NAUTOBOT_SHORT_TIME_FORMAT", "H:i:s")
268+
DATETIME_FORMAT = os.getenv("NAUTOBOT_DATETIME_FORMAT", "N j, Y g:i a")
269+
SHORT_DATETIME_FORMAT = os.getenv("NAUTOBOT_SHORT_DATETIME_FORMAT", "Y-m-d H:i")
270+
271+
# A list of strings designating all applications that are enabled in this Django installation. Each string should be a dotted Python path to an application configuration class (preferred), or a package containing an application.
272+
# https://nautobot.readthedocs.io/en/latest/configuration/optional-settings/#extra-applications
273+
EXTRA_INSTALLED_APPS = []
274+
LOG_LEVEL = "DEBUG" if DEBUG else "INFO"
275+
LOGGING = {
276+
"version": 1,
277+
"disable_existing_loggers": False,
278+
"formatters": {
279+
"normal": {
280+
"format": "%(asctime)s.%(msecs)03d %(levelname)-7s %(name)s :\n %(message)s",
281+
"datefmt": "%H:%M:%S",
282+
},
283+
"verbose": {
284+
"format": "%(asctime)s.%(msecs)03d %(levelname)-7s %(name)-20s %(filename)-15s %(funcName)30s() :\n %(message)s",
285+
"datefmt": "%H:%M:%S",
286+
},
287+
},
288+
"handlers": {
289+
"normal_console": {
290+
"level": "DEBUG",
291+
"class": "logging.StreamHandler",
292+
"formatter": "normal",
293+
},
294+
},
295+
"loggers": {
296+
"django": {"handlers": ["normal_console"], "level": LOG_LEVEL},
297+
"nautobot": {
298+
"handlers": ["normal_console"],
299+
"level": LOG_LEVEL,
300+
},
301+
},
302+
}

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nautobot_plugin_nornir==1.0.0
2+
nautobot-golden-config==1.2.0

0 commit comments

Comments
 (0)