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 }} 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 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 ba0cec3..8d43318 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 @@ -28,7 +28,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 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 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/initializers/sites.yml b/initializers/sites.yml index 0015f4e..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,5 +29,6 @@ # status: active # facility: Singapore 1 # asn: 09876 +# tenant: tenant2 # custom_field_data: # text_field: Description for SING1 diff --git a/requirements-container.txt b/requirements-container.txt index 450c322..dd03b10 100644 --- a/requirements-container.txt +++ b/requirements-container.txt @@ -1,4 +1,4 @@ -napalm==3.2.0 -ruamel.yaml==0.17.4 +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 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 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)