Netbox Deployment Documentation
Overview
This document details the deployment architecture and management procedures for the Netbox IPAM/DCIM system in our infrastructure.
Architecture
Components
- Application: Netbox v4.1.11 (Docker Image:
netboxcommunity/netbox:v4.1.11) - Orchestration: Docker Compose (via
netbox-dockerv3.0.2) - Database: Postgres 16
- Cache: Redis 7
- Infrastructure Management: Terraform (
e-breuninger/netboxprovider) - Configuration Management: Ansible
Network
- URL: http://192.168.1.104:8080
- Port: 8080 (Mapped from container port 8080)
Deployment Workflow
1. Infrastructure Provisioning (Terraform)
First, provision the Virtual Machine on Proxmox.
- Directory:
terraform/proxmox - Provider:
telmate/proxmox - Resource:
module.netbox(Proxmox VM) - Specs: 2 Cores, 4GB RAM, 20GB Disk, IP 192.168.1.104
Command:
2. Application Deployment (Ansible)
Once the VM is running, deploy the Netbox application stack.
- Playbook:
ansible/playbooks/deploy-netbox.yml - Role:
ansible/roles/netbox - Key Features:
- Clones
netbox-dockerrepository (v3.0.2) - Configures
docker-compose.override.ymlfor version pinning and port mapping - Sets up automatic superuser creation (
SKIP_SUPERUSER=false) - Handles long-running database migrations with async tasks
- Clones
Command:
Configuration Variables
You can override these defaults in ansible/roles/netbox/defaults/main.yml or via -e.
| Variable | Default | Description |
|---|---|---|
netbox_git_version | "3.0.2" | netbox-docker version (controls docker-compose structure) |
netbox_image | "netboxcommunity/netbox:v4.1.11" | Netbox application image version |
netbox_port | 8080 | Host port to expose Netbox on |
netbox_install_dir | "/opt/netbox-docker" | Installation directory on target |
netbox_superuser_name | "admin" | Admin username |
netbox_superuser_email | "admin@example.com" | Admin email |
netbox_superuser_password | "admin" | [Sensitive] Admin password |
netbox_superuser_api_token | "0123..." | [Sensitive] API Token for Terraform |
3. Verification & Initial Population (Terraform)
This section covers the configuration of Netbox resources (Sites, Clusters, Devices, VMs, IPs) using Terraform. This ensures that Netbox is populated with the correct data representing your infrastructure.
1. Initialize Terraform
Navigate to the terraform/netbox-integration directory and initialize Terraform:
- Managed Resources:
- Sites (e.g., HomeLab)
- Clusters (e.g., Proxmox)
- Virtual Machines
- IP Addresses & Interfaces
- Services
Command:
Troubleshooting
Common Issues
- Timeout during startup: The initial database migration takes time. The Ansible playbook uses
async: 600to allow up to 10 minutes for startup. - Superuser not created: Ensure
SKIP_SUPERUSER=falseis set indocker-compose.override.yml. - Terraform Tag Error: There is a known bug in the provider where creating a VM with tags fails due to race conditions. Workaround: Create VM without tags first, or use
depends_on(though Terraform handles dependencies automatically, this specific provider issue persists).
Credentials
- Admin User:
admin/admin(Default, change in production) - API Token:
0123456789abcdef0123456789abcdef01234567