Updated Using Netbox Plugins (markdown)

Tobias Genannt 2023-07-11 13:55:37 +02:00
parent 8a62790e11
commit 2dd1536ffd

@ -1,6 +1,6 @@
To utilize plugins that have been created by users within the [NetBox Community](https://github.com/netbox-community/netbox/wiki/Plugins) a custom Docker image must be created. To utilize plugins that have been created by users within the [NetBox Community](https://github.com/netbox-community/netbox/wiki/Plugins) a custom Docker image must be created.
# Step 1 - Fresh Install ## Step 1 - Fresh Install
Lets start with a fresh install of netbox-docker. Lets start with a fresh install of netbox-docker.
@ -8,35 +8,33 @@ Lets start with a fresh install of netbox-docker.
2. If required, **change** the `/env/netbox.env` file to your required settings. 2. If required, **change** the `/env/netbox.env` file to your required settings.
3. In the **root of the new folder**, **create** the following files (leave them blank): `plugin_requirements.txt` `Dockerfile-Plugins` `docker-compose.override.yml` 3. In the **root of the new folder**, **create** the following files (leave them blank): `plugin_requirements.txt` `Dockerfile-Plugins` `docker-compose.override.yml`
# Step 2 - Modify New Files ## Step 2 - Modify New Files
## `plugin_requirements.txt` ### `plugin_requirements.txt`
This file contains a list of the NetBox Plugins (as **PyPi Python Packages**) to be installed during the building of the Docker image. This file contains a list of the NetBox Plugins (as **PyPi Python Packages**) to be installed during the building of the Docker image.
For Example: For Example:
``` ```
netbox-topology-views==3.6.0b2 netbox-secretstore
netbox-validity
netbox-acls
``` ```
## `Dockerfile-Plugins` ### `Dockerfile-Plugins`
This is the Dockerfile used to build the custom Image. This is the Dockerfile used to build the custom Image.
Put the following contents into that file. Put the following contents into that file.
```Dockerfile ```Dockerfile
FROM netboxcommunity/netbox:latest FROM netboxcommunity/netbox:latest
COPY ./plugin_requirements.txt / COPY ./plugin_requirements.txt /opt/netbox/
RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /plugin_requirements.txt RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /opt/netbox/plugin_requirements.txt
# These lines are only required if your plugin has its own static files. # These lines are only required if your plugin has its own static files.
COPY configuration/configuration.py /etc/netbox/config/configuration.py COPY configuration/configuration.py /etc/netbox/config/configuration.py
COPY configuration/plugins.py /etc/netbox/config/plugins.py COPY configuration/plugins.py /etc/netbox/config/plugins.py
RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
``` ```
The `SECRET_KEY` does not need to be changed. > NOTE: This `SECRET_KEY` is only used during the installation. There's no need to change it.
## `docker-compose.override.yml` ### `docker-compose.override.yml`
As its name implies, this file can contain configuration overrides for `docker-compose.yml` As its name implies, this file can contain configuration overrides for `docker-compose.yml`
The absolute most basic configuration that you need is as follows. This tells our NetBox Worker and NetBox Housekeeping services to use our new custom image, `Dockerfile-Plugins` The absolute most basic configuration that you need is as follows. This tells our NetBox Worker and NetBox Housekeeping services to use our new custom image, `Dockerfile-Plugins`
@ -61,8 +59,22 @@ services:
context: . context: .
dockerfile: Dockerfile-Plugins dockerfile: Dockerfile-Plugins
``` ```
## Step 3 - Enable plugins in the configuration
# Step 3 - Build and Deploy! To get plugins to work within NetBox you need to add some configuration to `configuration/plugins.py`.
```python
PLUGINS = ["netbox_secretstore"]
# PLUGINS_CONFIG = {
# "netbox_secretstore": {
# ADD YOUR SETTINGS HERE
# }
# }
```
> NOTE: This can differ for every plugin. To learn more about this see the [NetBox documentation](https://netbox.readthedocs.io/en/stable/plugins/#enable-the-plugin).
## Step 4 - Build and Deploy!
Once you've prepared the new Docker Image, now it's time to build it. Once you've prepared the new Docker Image, now it's time to build it.
Execute the following commands: Execute the following commands:
@ -71,7 +83,7 @@ docker-compose build --no-cache
docker-compose up -d docker-compose up -d
``` ```
With any luck, your new custom NetBox-Docker Image has been created and is now running, with the required plugins installed! Your new custom NetBox Docker image has been created and is now running, with the required plugins installed.
# Troubleshooting # Troubleshooting