From 4d320f34d50fe56b1cfedaa9c6407934c2f5189d Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Wed, 5 May 2021 11:31:32 +0200 Subject: [PATCH 01/14] Optimise migrations on startup The migrations are only started if there are some that have not been applied. Additionally the maintenace task needed after an update are now run after the migrations --- docker/docker-entrypoint.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index c39453d..6173db1 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -15,7 +15,7 @@ source /opt/netbox/venv/bin/activate DB_WAIT_TIMEOUT=${DB_WAIT_TIMEOUT-3} MAX_DB_WAIT_TIME=${MAX_DB_WAIT_TIME-30} CUR_DB_WAIT_TIME=0 -while ! ./manage.py migrate 2>&1 && [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do +while ! ./manage.py showmigrations >/dev/null 2>&1 && [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do echo "⏳ Waiting on DB... (${CUR_DB_WAIT_TIME}s / ${MAX_DB_WAIT_TIME}s)" sleep "${DB_WAIT_TIMEOUT}" CUR_DB_WAIT_TIME=$((CUR_DB_WAIT_TIME + DB_WAIT_TIMEOUT)) @@ -24,6 +24,19 @@ if [ "${CUR_DB_WAIT_TIME}" -ge "${MAX_DB_WAIT_TIME}" ]; then echo "❌ Waited ${MAX_DB_WAIT_TIME}s or more for the DB to become ready." exit 1 fi +# Check if update is needed +if ! ./manage.py migrate --check >/dev/null 2>&1; then + echo "⚙️ Applying database migrations" + ./manage.py migrate --no-input + echo "⚙️ Running trace_paths" + ./manage.py trace_paths --no-input + echo "⚙️ Removing stale content types" + ./manage.py remove_stale_contenttypes --no-input + echo "⚙️ Removing expired user sessions" + ./manage.py clearsessions + echo "⚙️ Clearing cache data" + ./manage.py invalidate all +fi # Create Superuser if required if [ "$SKIP_SUPERUSER" == "true" ]; then From e2cc9386fb0ee5e9cd3b3789eefae294f6ec5653 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Tue, 18 May 2021 09:32:48 +0200 Subject: [PATCH 02/14] Secrets are removed in Netbox 2.12 --- initializers/secret_roles.yml | 4 ---- startup_scripts/310_secret_roles.py | 15 --------------- 2 files changed, 19 deletions(-) delete mode 100644 initializers/secret_roles.yml delete mode 100644 startup_scripts/310_secret_roles.py diff --git a/initializers/secret_roles.yml b/initializers/secret_roles.yml deleted file mode 100644 index 239906a..0000000 --- a/initializers/secret_roles.yml +++ /dev/null @@ -1,4 +0,0 @@ -# - name: Super Secret Passwords -# slug: super-secret -# - name: SNMP Communities -# slug: snmp diff --git a/startup_scripts/310_secret_roles.py b/startup_scripts/310_secret_roles.py deleted file mode 100644 index 02dcd88..0000000 --- a/startup_scripts/310_secret_roles.py +++ /dev/null @@ -1,15 +0,0 @@ -import sys -from secrets.models import SecretRole - -from startup_script_utils import load_yaml - -secret_roles = load_yaml("/opt/netbox/initializers/secret_roles.yml") - -if secret_roles is None: - sys.exit() - -for params in secret_roles: - secret_role, created = SecretRole.objects.get_or_create(**params) - - if created: - print("🔑 Created Secret Role", secret_role.name) From 02f30f3a682b9752c0ebe4eec5701efe733af357 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Tue, 18 May 2021 09:34:44 +0200 Subject: [PATCH 03/14] 'ttf-ubuntu-font-family' was remove from Alpine --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 280a9c6..0653100 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,6 @@ RUN apk add --no-cache \ postgresql-libs \ python3 \ py3-pip \ - ttf-ubuntu-font-family \ unit \ unit-python3 From 49b7c267b9650ef44131fa87120e63fb6672162c Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 18 May 2021 08:03:10 +0000 Subject: [PATCH 04/14] Update postgres Docker tag to v13 --- docker-compose.test.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 8233bf6..df681d2 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -20,7 +20,7 @@ services: ports: - 8080 postgres: - image: postgres:12-alpine + image: postgres:13-alpine env_file: env/postgres.env redis: image: redis:6-alpine diff --git a/docker-compose.yml b/docker-compose.yml index 7bec177..5bdba37 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: # postgres postgres: - image: postgres:12-alpine + image: postgres:13-alpine env_file: env/postgres.env volumes: - netbox-postgres-data:/var/lib/postgresql/data From 240326ef37e09ed1a5b5781f1873bec5a2eea088 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 18 May 2021 13:30:10 +0000 Subject: [PATCH 05/14] Update dependency napalm to v3.3.0 --- requirements-container.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-container.txt b/requirements-container.txt index 450c322..e5a2aae 100644 --- a/requirements-container.txt +++ b/requirements-container.txt @@ -1,4 +1,4 @@ -napalm==3.2.0 +napalm==3.3.0 ruamel.yaml==0.17.4 django-auth-ldap==2.4.0 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1 From dd732d7bc20b21bad77407c2e840f84a40aabaec Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 25 May 2021 20:35:56 +0000 Subject: [PATCH 06/14] Update github/super-linter action to v4 --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3293aff..608e6e0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -19,7 +19,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-python@v2 - name: Lint Code Base - uses: github/super-linter@v3 + uses: github/super-linter@v4 env: DEFAULT_BRANCH: develop GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5b618851c08c3796f45b98a9a95a62c1c055b7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ma=CC=88der?= Date: Wed, 26 May 2021 19:05:37 +0200 Subject: [PATCH 07/14] Pin the NetBox Docker version in the docker-compose.yml file --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5bdba37..745055c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.4' services: netbox: &netbox - image: netboxcommunity/netbox:${VERSION-latest} + image: netboxcommunity/netbox:${VERSION-v2.11} depends_on: - postgres - redis From 057728b774140e37b04af3b66ab2aa03a38866b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelizaveta=20Leme=C5=A1eva?= Date: Fri, 28 May 2021 11:13:31 +0300 Subject: [PATCH 08/14] Allow sites to be initialized with tenants --- initializers/sites.yml | 1 + startup_scripts/{110_tenant_groups.py => 020_tenant_groups.py} | 0 startup_scripts/{120_tenants.py => 030_tenants.py} | 0 3 files changed, 1 insertion(+) rename startup_scripts/{110_tenant_groups.py => 020_tenant_groups.py} (100%) rename startup_scripts/{120_tenants.py => 030_tenants.py} (100%) diff --git a/initializers/sites.yml b/initializers/sites.yml index 0015f4e..bbda54e 100644 --- a/initializers/sites.yml +++ b/initializers/sites.yml @@ -28,5 +28,6 @@ # status: active # facility: Singapore 1 # asn: 09876 +# tenant: tenant1 # custom_field_data: # text_field: Description for SING1 diff --git a/startup_scripts/110_tenant_groups.py b/startup_scripts/020_tenant_groups.py similarity index 100% rename from startup_scripts/110_tenant_groups.py rename to startup_scripts/020_tenant_groups.py diff --git a/startup_scripts/120_tenants.py b/startup_scripts/030_tenants.py similarity index 100% rename from startup_scripts/120_tenants.py rename to startup_scripts/030_tenants.py From f4e9ebcfb5e4cae903918fb8014421cd3ac2360b Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 31 May 2021 08:58:27 +0000 Subject: [PATCH 09/14] Update dependency ruamel.yaml to v0.17.6 --- requirements-container.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-container.txt b/requirements-container.txt index e5a2aae..d441254 100644 --- a/requirements-container.txt +++ b/requirements-container.txt @@ -1,4 +1,4 @@ napalm==3.3.0 -ruamel.yaml==0.17.4 +ruamel.yaml==0.17.6 django-auth-ldap==2.4.0 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1 From 3aad44d68c5f3fe86767c164a1049ef77719ef0f Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 31 May 2021 15:28:52 +0000 Subject: [PATCH 10/14] Update dependency ruamel.yaml to v0.17.7 --- requirements-container.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-container.txt b/requirements-container.txt index d441254..486dca9 100644 --- a/requirements-container.txt +++ b/requirements-container.txt @@ -1,4 +1,4 @@ napalm==3.3.0 -ruamel.yaml==0.17.6 +ruamel.yaml==0.17.7 django-auth-ldap==2.4.0 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1 From 15b097bd3eb9427ddb9df6d4dc9a60f2513163aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelizaveta=20Leme=C5=A1eva?= Date: Tue, 1 Jun 2021 14:22:08 +0300 Subject: [PATCH 11/14] Add second tenant with group to site --- initializers/sites.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/initializers/sites.yml b/initializers/sites.yml index bbda54e..7ace3aa 100644 --- a/initializers/sites.yml +++ b/initializers/sites.yml @@ -20,6 +20,7 @@ # status: active # facility: Amsterdam 3 # asn: 67890 +# tenant: tenant1 # custom_field_data: # text_field: Description for AMS3 # - name: SING 1 @@ -28,6 +29,6 @@ # status: active # facility: Singapore 1 # asn: 09876 -# tenant: tenant1 +# tenant: tenant2 # custom_field_data: # text_field: Description for SING1 From 98840382b9fbfe5943ee04710f26d7781e1e9eb4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 9 Jun 2021 13:53:48 +0000 Subject: [PATCH 12/14] Update dependency ruamel.yaml to v0.17.8 --- requirements-container.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-container.txt b/requirements-container.txt index 486dca9..016bb16 100644 --- a/requirements-container.txt +++ b/requirements-container.txt @@ -1,4 +1,4 @@ napalm==3.3.0 -ruamel.yaml==0.17.7 +ruamel.yaml==0.17.8 django-auth-ldap==2.4.0 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1 From e38d646e8e40f7ee1e79ba9b9b50118cd8f06512 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 10 Jun 2021 06:57:09 +0000 Subject: [PATCH 13/14] Update dependency ruamel.yaml to v0.17.9 --- requirements-container.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-container.txt b/requirements-container.txt index 016bb16..0512848 100644 --- a/requirements-container.txt +++ b/requirements-container.txt @@ -1,4 +1,4 @@ napalm==3.3.0 -ruamel.yaml==0.17.8 +ruamel.yaml==0.17.9 django-auth-ldap==2.4.0 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1 From 6bbc7a3a8448166ffc51aaa9e3389e6deee8b617 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 18 Jun 2021 12:29:27 +0000 Subject: [PATCH 14/14] Update dependency napalm to v3.3.1 --- requirements-container.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-container.txt b/requirements-container.txt index 0512848..dd03b10 100644 --- a/requirements-container.txt +++ b/requirements-container.txt @@ -1,4 +1,4 @@ -napalm==3.3.0 +napalm==3.3.1 ruamel.yaml==0.17.9 django-auth-ldap==2.4.0 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1