Debian 11 – Installation IPAM NetBox

Auteur : Vince NADUS
Date de publication : Sept. 27, 2021
netbox django python

Installation PostgreSQL

apt-get update
apt-get install -y postgresql libpq-dev

Création base de données

su postgres
psql
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'netbox';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;

Tester la connexion à Postgres

su postgres
psql -U netbox -W -h localhost netbox

Importer ancienne base de données

psql netbox < netbox.sql

Installation Netbox

Pré-requis

apt-get install -y python3 python3-pip python3-dev build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev redis-server zlib1g-dev

Récuperer la derniere version de Netbox

https://github.com/netbox-community/netbox/releases

wget https://github.com/netbox-community/netbox/archive/v2.6.4.zip
apt-get install unzip
unzip v2.6.4.zip
mv netbox-2.6.4/ netbox
mv netbox/ /opt/

Installer les pré-requis Python pour Netbox

cd /opt/netbox
pip3 install -r requirements.txt
pip3 install napalm

Configuration Netbox

cd netbox/netbox/
cp configuration.example.py configuration.pycd /opt/netbox/netbox/
generate_secret_key.pynano configuration.pyALLOWED_HOSTS = ['netbox.example.com', '192.0.2.123']
DATABASE = {
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'netbox',
'HOST': 'localhost',
'PORT': '',
}
generate_secret_key.py SECRET_KEYcd /opt/netbox/netbox/
python3 manage.py migrate

Create a Super User

python3 manage.py createsuperuser

Collect Static Files

python3 manage.py collectstatic --no-input

Load Initial Data (Optional)

python3 manage.py loaddata initial_data

Test the Application

python3 manage.py runserver 0.0.0.0:8000 --insecure

Pour aller plus loin

Sauvegarder Base de données PostGreSQL

Le mot de passe de l’utilisateur netbox (-U) est demandé.

pg_dump -U netbox -W -h localhost netbox > netbox-20-07-2020.sql