Netbox Ninja Plugin
A NetBox plugin for generating dynamic text files and images using Jinja2 templates.
Overview
Netbox Ninja Plugin enables dynamic content generation in NetBox through Jinja2 templates. It supports both text file generation and SVG image creation from draw.io XML templates, seamlessly integrating with NetBox's data model.
graph LR
DATA[Any data in Netbox] --> TEMPLATE[Ninja template]
TEMPLATE --> DRAWIO[Drawio file]
DRAWIO[Drawio file] --> SVG[SVG image]
TEMPLATE --> JSON[JSON file]
TEMPLATE --> TEXT[Generic text]
SVG --> NBUI[Netbox UI]
JSON --> NBUI[Netbox UI]
TEXT --> NBUI[Netbox UI]
SVG --> API[Netbox API]
JSON --> API[Netbox API]
TEXT --> API[Netbox API]
Output files can be seen via Netbox UI and accessed via API.
Example of automatically generated network diagram:
See video introduction in Youtube.
Note: This plugin is currently in beta. While it's functional, some features are still under development and the API may change in future releases.
Use cases
Netbox Ninja Plugin can be used to generate always up-to-date outputs for many use cases including (but not limited to) following:
- Network diagrams
- Any other visualization of any Netbox data
- Configuration files for others systems to fetch from Netbox
- Any other text based output for any purpose
Key Features
- Dynamic text file generation using Jinja2 templates
- Template-based SVG image generation from draw.io XML format
- Direct integration with NetBox's data model
- REST API endpoints for template management
- Support for object-specific template rendering
- Show output in Ninja tab in chosen Netbox object view (i.e. Site)
- Tempalate rendered per object (i.e for each Site)
- Per-template dropdown filters on Ninja tab templates (object type + string filters)
Requirements
- NetBox v4.0.11 - v4.7.x
- drawio-export-api Docker container. Optional, required for SVG images that need to be fetched through REST API.
Compatibility
Plugin versions listed below have been tested with its corresponding NetBox version.
| NetBox Version | Plugin Version | draw.io / diagrams.net version |
|---|---|---|
| 4.7.x | 0.4.1 | 29.5.2 |
| 4.7.x | 0.4.0 | 29.5.2 |
| 4.6.x | 0.3.2 | 29.5.2 |
| 4.6.x | 0.3.1 | 29.5.2 |
| 4.6.x | 0.3.0 | 29.5.2 |
| 4.5.x | 0.2.1 | 29.5.2 |
| 4.5.x | 0.2.0 | 29.5.2 |
| 4.4.0 - 4.4.10 | 0.1.15 | 29.5.2 |
| 4.4.0 - 4.4.10 | 0.1.14 | 29.5.2 |
| 4.4.0 - 4.4.7 | 0.1.13 | 27.1.0 |
| 4.2.3 - 4.3.7 | 0.1.12 | 27.1.0 |
| 4.2.3 - 4.3.7 | 0.1.11 | 27.1.0 |
| 4.2.3 - 4.3.6 | 0.1.10 | 27.1.0 |
| 4.0.11 - 4.3.2 | 0.1.9 | 27.1.0 |
Test Ninja in Codespaces
The quickest way to test Ninja is using GitHub Codespaces:
- Click the "Code" button on the repository and select "Create codespace on main"
- Once your Codespace is ready, run
make demo_environmentin the terminal - Access the development environment at http://localhost:8000 with credentials admin/admin
Quick Start
- Install the plugin:
pip install netbox-ninja-plugin
- Add to NetBox configuration:
PLUGINS = [
'netbox_ninja_plugin',
]
- Configure the plugin (see CONFIGURATION.md for detailed options):
PLUGINS_CONFIG = {
"netbox_ninja_plugin": {
"target_models": {
"dcim": ["device", "interface", "site", "region"],
"ipam": ["prefix"],
},
"jinja_model_querysets": {
"dcim": ["device", "interface", "site", "region"],
"ipam": ["prefix"],
},
"filter_variable_prefix": "filter_",
"drawio_export_api": {
"enabled": True,
"url": "https://drawio-export-api:443/svg",
"token": "your-token",
"pem_file_path": "/path/to/drawio_export_api.pem",
"verify_tls": True,
"timeout": 60,
},
"top_level_menu": False,
}
}
Usage
Template Creation
- Navigate to NetBox's Ninja Templates section
- Create a new template with:
- Name: Template identifier
- Output type: Text or Draw.io format
- Object types: NetBox objects to associate with the template
- Object type filters: Adds dropdown filters on the Ninja tab for templates (based on selected object types)
- String filters: Adds dropdowns on the Ninja tab for reusable string filter options
- Template code: Your Jinja2 template
Template Variables
- Access NetBox objects using object queries, e.g.
{{ sites.first() }}or{{ regions.get(slug='region1') }} - For object-specific templates, use
{{ target_object }}to reference the current object - Ninja tab dropdown filter selections are exposed to templates as Jinja variables.
- Variable names use
filter_variable_prefix(default:filter_), e.g.{{ filter_sites }}. - Object type filter variables receive a queryset of the selected objects (or
Nonewhen no selection is made). - String filter variables receive a list of the selected option values (or
Nonewhen nothing is selected).
- Variable names use
- Filter selections persist via query parameters while the page is open, and each template card has its own scoped reset.
For detailed examples and use cases, see EXAMPLES.md.
Security Note
The plugin currently doesn't enforce object-level permissions in templates. Exercise caution when exposing data through templates, as users may access data beyond their normal permissions.
Documentation
- Examples - Detailed usage examples and tutorials
- Configuration - Detailed configuration options and examples
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for netbox-ninja-plugin 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netbox_ninja_plugin-0.4.1.tar.gz | 772.2 kB | Without provenance | Details for netbox_ninja_plugin-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netbox_ninja_plugin-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for netbox_ninja_plugin-0.4.1-py3-none-any.whl |
Total release size: 1.6 MB
Release files / netbox_ninja_plugin-0.4.1.tar.gz
| Download URL | netbox_ninja_plugin-0.4.1.tar.gz |
|---|---|
| Size | 772.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56639be422159810ed168782e2e2eafc4878bd5cf6a97332342bb88ab7be144b
|
|
BLAKE2b-256 checksum How to use checksums |
fa6cd7982b6afc4dc16341e19a770bf8fd33eaac0c12f7a28d2fab2aef9726c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / netbox_ninja_plugin-0.4.1-py3-none-any.whl
| Download URL | netbox_ninja_plugin-0.4.1-py3-none-any.whl |
|---|---|
| Size | 789.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38ad812688a53f430c2297aa81f95bd3d95f2ac87da35e2148314328cfa37ce3
|
|
BLAKE2b-256 checksum How to use checksums |
e35ba1536c6bd5de6aaf92be3f0f1eaea656a45ba38a8cfbe4d36b22e640f42d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Security for netbox-ninja-plugin 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.