NetBox and Ansible Setup

This post follows on from the NetBox setup post, upto the API token setup.

SSL Configuration with Nginx

In that previous post, SSL was not used. The connection was made insecure and ignored. Here, I will detail the steps to use Nginx as a proxy for the NetBox docker container.

Add SAN to SSL Creation

I have used a self-signed SSL for this, and I found that SANs needed to be added to the SSL certificate creation.

Create SSL Certificate

Add Certificate to CA Certificate Store

As I will be using the same Linux host to host NetBox and run the Terraform, I will add the self-signed certificate to the CA store. If Terraform was to be run from another host, I would need to copy the certificate to that CA store.

Create Nginx Server Block (vHost)

Copy the SSL cert and key into the nginx/ssl directory

Create the server block

Setup PYTHON AND ANSIBLE

This is a basic environment. I have created my own Python Virtual env, and installed; Ansible, PyNetbox and the Ansible galaxy NetBox collection.

Previously, I have created an API token in NetBox. The NetBox domain will be netboxtest.test and in the previous step I created the SSL certificate for this domain.

bASIC pLAYBOOK

This is a basic playbook that will use a role I have created called customisations. It will create a tag only. All the modules can be found at this link. I am going to demonstrate custom field.

All Group Vars

Customisations Vars

This is simply creating a custom field for BGP timers

Customisations Task

This Ansible task is taking the list of custom_fields, and for each item it will execute whatever data is inside the list and add the custom field to NetBox with a state value of present.

BGP Timers Custom Field

Leave a Comment

Your email address will not be published. Required fields are marked *