Skip to content

Commit 355f9d4

Browse files
committed
Prepare for Netbox 2.7
1 parent 40ef427 commit 355f9d4

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ RUN pip install --prefix="/install" --no-warn-script-location \
2626
# ruamel is used in startup_scripts
2727
'ruamel.yaml>=0.15,<0.16' \
2828
# django_auth_ldap is required for ldap
29-
django_auth_ldap
29+
django_auth_ldap \
30+
# django-storages was introduced in 2.7 and is optional
31+
django-storages
3032

3133
ARG NETBOX_PATH
3234
COPY ${NETBOX_PATH}/requirements.txt /

configuration/configuration.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def read_secret(secret_name):
3737
# PostgreSQL password
3838
'HOST': os.environ.get('DB_HOST', 'localhost'), # Database server
3939
'PORT': os.environ.get('DB_PORT', ''), # Database port (leave blank for default)
40-
'OPTIONS': {'sslmode': os.environ.get('DB_SSLMODE', 'prefer')},
40+
'OPTIONS': {'sslmode': os.environ.get('DB_SSLMODE', 'prefer')},
4141
# Database connection SSLMODE
42-
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')),
42+
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', '300')),
4343
# Database connection persistence
4444
}
4545

@@ -51,13 +51,22 @@ def read_secret(secret_name):
5151

5252
# Redis database settings. The Redis database is used for caching and background processing such as webhooks
5353
REDIS = {
54-
'HOST': os.environ.get('REDIS_HOST', 'localhost'),
55-
'PORT': int(os.environ.get('REDIS_PORT', 6379)),
56-
'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
57-
'DATABASE': os.environ.get('REDIS_DATABASE', '0'),
58-
'CACHE_DATABASE': os.environ.get('REDIS_CACHE_DATABASE', '1'),
59-
'DEFAULT_TIMEOUT': os.environ.get('REDIS_TIMEOUT', '300'),
60-
'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
54+
'webhooks': {
55+
'HOST': os.environ.get('REDIS_HOST', 'localhost'),
56+
'PORT': int(os.environ.get('REDIS_PORT', 6379)),
57+
'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
58+
'DATABASE': int(os.environ.get('REDIS_DATABASE', 0)),
59+
'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_TIMEOUT', 300)),
60+
'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
61+
},
62+
'caching': {
63+
'HOST': os.environ.get('REDIS_CACHE_HOST', os.environ.get('REDIS_HOST', 'localhost')),
64+
'PORT': int(os.environ.get('REDIS_CACHE_PORT', os.environ.get('REDIS_PORT', 6379))),
65+
'PASSWORD': os.environ.get('REDIS_CACHE_PASSWORD', os.environ.get('REDIS_PASSWORD', read_secret('redis_cache_password'))),
66+
'DATABASE': int(os.environ.get('REDIS_CACHE_DATABASE', 1)),
67+
'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_CACHE_TIMEOUT', os.environ.get('REDIS_TIMEOUT', 300))),
68+
'SSL': os.environ.get('REDIS_CACHE_SSL', os.environ.get('REDIS_SSL', 'False')).lower() == 'true',
69+
},
6170
}
6271

6372
#########################
@@ -172,10 +181,6 @@ def read_secret(secret_name):
172181
# Time zone (default: UTC)
173182
TIME_ZONE = os.environ.get('TIME_ZONE', 'UTC')
174183

175-
# The Webhook event backend is disabled by default. Set this to True to enable it. Note that this requires a Redis
176-
# database be configured and accessible by NetBox (see `REDIS` below).
177-
WEBHOOKS_ENABLED = os.environ.get('WEBHOOKS_ENABLED', 'False').lower() == 'true'
178-
179184
# Date/time formatting. See the following link for supported formats:
180185
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
181186
DATE_FORMAT = os.environ.get('DATE_FORMAT', 'N j, Y')

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
depends_on:
66
- postgres
77
- redis
8+
- redis-cache
89
- netbox-worker
910
env_file: env/netbox.env
1011
user: '101'
@@ -50,6 +51,13 @@ services:
5051
env_file: env/redis.env
5152
volumes:
5253
- netbox-redis-data:/data
54+
redis-cache:
55+
image: redis:5-alpine
56+
command:
57+
- sh
58+
- -c # this is to evaluate the $REDIS_PASSWORD from the env
59+
- redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
60+
env_file: env/redis.env
5361
volumes:
5462
netbox-static-files:
5563
driver: local

env/netbox.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ MAX_PAGE_SIZE=1000
1717
REDIS_HOST=redis
1818
REDIS_PASSWORD=H733Kdjndks81
1919
REDIS_DATABASE=0
20-
REDIS_CACHE_DATABASE=1
2120
REDIS_SSL=false
21+
REDIS_CACHE_HOST=redis-cache
22+
REDIS_CACHE_PASSWORD=t4Ph722qJ5QHeQ1qfu36
23+
REDIS_CACHE_DATABASE=0
24+
REDIS_CACHE_SSL=false
2225
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
2326
SKIP_STARTUP_SCRIPTS=false
2427
SKIP_SUPERUSER=false

env/redis-cache.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
REDIS_PASSWORD=t4Ph722qJ5QHeQ1qfu36

0 commit comments

Comments
 (0)