Deploy NetBox quickly using an Ansible playbook
Background
NetBox is an infrastructure resource modelling application. It is a great tool to organize and document your infrastructure from a network and connection perspective.
This Ansible playbook is created to quickly install and getting started with a NetBox environment on a Debian based server.
Requirements
Python 3.8, PostgresSQL 10, Redis 4
I recommend to install NetBox on a Debian 11 system witch includes these requirements in their default repository’s.
Python is required to be installed on the server for Ansible to work.
The playbook can be found here:
Running the playbook
There is only a few variables that are need to be changed before running the playbook. The most important one is the database password and then which version you would like to install. The rest can be left to their defaults.
The playbook included the following steps.
- Installing all base packages and python libraries
- Configuring postgresql to start on boot
- Creating the NetBox database additional settings
- Downloading and extracting the NetBox code.
- Configuring NetBox dependencies like gunicorn and ngix
- Creates a self-signed certificate
Post install tasks
There are a couple of tasks that need to be run manually after running the playbook.
First you have to generating a new secret key that is used as a salt for hashing functions. This key is added to the configuration.py file. The changed database password or any other changed DB variable will also have to be changed in configuration.py file.
Next the NetBox virtual environment is created by running the upgrade.sh script. I have not included this step in the playbook to make it easier to troubleshoot any setup errors.
Finally a Super user account has to be created to log in to NetBox. This is done by running the manage.py in the NetBox environment.
All these steps are described in the playbook.
When these steps are done. Your NetBox environment should be ready for use.