User Tools

Site Tools


network_stuff:netbox

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
network_stuff:netbox [2020/03/14 12:53] jotasandokunetwork_stuff:netbox [2025/07/04 16:41] (current) jotasandoku
Line 1: Line 1:
 NETBOX\\ NETBOX\\
  
-IPAM: (Document ipam system) +IPAM: (TODO: Document mycompany2 ipam system with API
- +  * DCIM: data center infrastructure management  tool
   * Source of truth / Source of record: System with authoritative status for the data. Note is **single source of truth for a data domain** (eg: we can have one sst for ipam and another one for dcim   * Source of truth / Source of record: System with authoritative status for the data. Note is **single source of truth for a data domain** (eg: we can have one sst for ipam and another one for dcim
     * data sets     * data sets
 +
 +
 +----
 +=== NETBOX DOCKER INSTALL (FOR LABS MAINLY) ===
 +  * Deploy container: [[https://www.rogerperkin.co.uk/network-automation/netbox/how-to-install-netbox/]]  ; note: start the container with ''docker compose up -d'' (detached)
 +  * Reset password: ''docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser''
 +  * Clone the demo data and run the script below to load it into the container:
 +
 +
 +  git clone https://github.com/netbox-community/netbox-demo-data.git
 +  cd netbox-demo-data
 +  
 +The script wipes the existing NetBox schema, imports netbox-demo-v4.3.sql, applies migrations, and restarts the containers. The data will persist across docker compose down / up as long as the Postgres volume is retained.
 +This is the script: 
 +  #!/usr/bin/env bash
 +  # load_netbox_demo.sh
 +  # Load NetBox demo SQL data into a docker-compose NetBox stack.
 +  
 +  set -euo pipefail
 +  
 +  # ----------------------------------------------------------------------
 +  # Adjust these if your environment differs
 +  SQL_PATH="./netbox-demo-data/sql/netbox-demo-v4.3.sql"
 +  POSTGRES_USER="${POSTGRES_USER:-netbox}"
 +  POSTGRES_DB="${POSTGRES_DB:-netbox}"
 +  # ----------------------------------------------------------------------
 +  
 +  echo "Starting NetBox stack (docker compose up -d)…"
 +  docker compose up -d
 +  
 +  # Get running container IDs
 +  PG_CONTAINER=$(docker compose ps -q postgres)
 +  NB_CONTAINER=$(docker compose ps -q netbox)
 +  
 +  # Wait until Postgres accepts connections
 +  echo "Waiting for Postgres to become ready…"
 +  until docker exec "$PG_CONTAINER" pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" >/dev/null 2>&1; do
 +      sleep 2
 +  done
 +  echo "Postgres is ready."
 +  
 +  # Copy SQL file into the Postgres container
 +  echo "Copying SQL dump into Postgres container…"
 +  docker cp "$SQL_PATH" "$PG_CONTAINER":/tmp/demo.sql
 +  
 +  # Drop and recreate the public schema
 +  echo "Dropping and recreating public schema…"
 +  docker compose exec postgres \
 +    psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" \
 +    -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'
 +  
 +  # Load the demo data
 +  echo "Loading demo data into database…"
 +  docker compose exec postgres \
 +    psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f /tmp/demo.sql
 +  
 +  # Run Django migrations to align with current code
 +  echo "Running Django migrations…"
 +  docker compose exec netbox \
 +    python /opt/netbox/netbox/manage.py migrate --noinput
 +  
 +  # Restart NetBox services so they use the new data
 +  echo "Restarting NetBox containers…"
 +  docker compose restart netbox netbox-worker netbox-housekeeping
 +  
 +  echo ""
 +  echo "Demo data loaded successfully. Visit http://localhost:8000 (admin / admin)."
 +
 +
  
network_stuff/netbox.1584190429.txt.gz · Last modified: (external edit)