Skip to main content

Manage Docker with Netbox & style.

Project description

Netbox Docker Plugin

Testing Report

Manage Docker with Netbox & style. Made to work with netbox-docker-agent.

UI Container view with dependencies

How does it work?

sequenceDiagram
    Netbox->>Agent: Change (Webhook)
    Agent->>Docker API: Request (HTTP)
    Docker API->>Agent: Response (HTTP)
    Agent->>Netbox: Feedback (Callback)

Once the plugin and webhooks are installed, you can:

  1. Create hosts that point to agents you had installed
  2. Retrieve informations from Docker API with the help of the agent
  3. Create containers on host with an image, expose ports, add env variables and labels, mount volumes, set networks.
  4. Manage the container status, start, stop, restart.

Installation

You can follow the official plugins installation instructions.

If needed, source your Netbox's virtual environment and install the plugin like a package. We assume you have already installed Netbox and its source code are in /opt/netbox:

cd /opt/netbox
python3 -m venv venv # if virtual env was not created before
source /opt/netbox/venv/bin/activate
pip install netbox-docker-plugin

Enable the plugin in the /opt/netbox/netbox/netbox/configuration.py file:

PLUGINS = [
    'netbox_docker_plugin',
]

Then, run migrations:

cd /opt/netbox
python3 netbox/manage.py migrate

[!IMPORTANT] In order to the communication between your Netbox instance and the Agent works, the plugin will check if webhooks to agents are presents on each migration phase. If not, then the plugin will automatically install webhooks configuration in your Netbox instance.

Alternative

Another way to install Netbox is to use the Official netbox-docker project.

With this alternate way, you can customize your Netbox image and migrations will be automatically execute each time you restart the container.

Contribute

Install our development environment

Requirements:

  • Python 3.11
  • PostgreSQL 15 Official Netbox doc
    • user: netbox (with database creation right)
    • password: secret
    • database: netbox
    • port: 5432
  • Redis 7.2
    • port: 6379

Set a PROJECT variable :

PROJECT="/project/netbox"

Create a project directory $PROJECT:

mkdir $PROJECT

Go inside your project directory, clone this repository and the Netbox repository:

cd $PROJECT
git clone git@github.com:SaaShup/netbox-docker-plugin.git
git clone git@github.com:netbox-community/netbox.git

Create your venv and activate it:

python -m venv venv
source venv/bin/activate

Install netbox-docker-plugin dependencies:

cd $PROJECT/netbox-docker-plugin
pip install -e .

Configure Netbox and install Netbox dependencies:

cd $PROJECT/netbox
cp $PROJECT/netbox-docker-plugin/netbox_configuration/configuration_dev.py $PROJECT/netbox/netbox/netbox/configuration.py
pip install -r requirements.txt

Run database migrations:

cd $PROJECT/netbox
python3 netbox/manage.py migrate

Create a Netbox super user:

cd $PROJECT/netbox
python3 netbox/manage.py createsuperuser

Start Netbox instance:

cd $PROJECT/netbox
python3 netbox/manage.py runserver 0.0.0.0:8000 --insecure

Visit http://localhost:8000/

Run tests

After installing you development environment, you can run the tests plugin (you don't need to start the Netbox instance):

cd $PROJECT/netbox
python3 netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2

With code coverage, install coverage.py and use it:

cd $PROJECT/netbox
python3 -m pip install coverage

The run the test with coverage.py and print the report:

cd $PROJECT/netbox
coverage run --include='*/netbox_docker_plugin/*' netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2
coverage report -m

Hosting

Check https://saashup.com for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netbox-docker-plugin-1.3.0.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

netbox_docker_plugin-1.3.0-py3-none-any.whl (71.1 kB view details)

Uploaded Python 3

File details

Details for the file netbox-docker-plugin-1.3.0.tar.gz.

File metadata

  • Download URL: netbox-docker-plugin-1.3.0.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for netbox-docker-plugin-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f42c559a8b90842cf66398efb321f6efd4d628aca06ef46c21663989ca89b282
MD5 c585d97d82bbab4551c26a5cdef06e91
BLAKE2b-256 f9c043006c67d1efcd6fd770e6ca6333867c20eeb8535aab2c8e47a685124daf

See more details on using hashes here.

File details

Details for the file netbox_docker_plugin-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for netbox_docker_plugin-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef27c5e3f0bcd5e6a6c22096dd4044deb84d24f18973b3c83fdd46241667c700
MD5 c443a717b50cbe5a5c07c591efd3afcd
BLAKE2b-256 0b4efdfb6371e17b3f9f85639d5656289ff99cb053394515ca835b67ac829d99

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page