Open-Source Netbox Plugin – Celery
NetBox is the leading solution for modelling and documenting modern networks. By combining the traditional disciplines of IP address management (IPAM) and datacenter infrastructure management (DCIM) with powerful APIs and extensions, NetBox provides the ideal “source of truth” to power network automation. Available as open source software under the Apache 2.0 license, NetBox serves as the cornerstone for network automation in thousands of organizations.
We are excited to introduce the Netbox Celery plugin – a new offering that leverages the powerful features of Celery to automate tasks within the Netbox environment. Combining Celery and NetBox brings powerful new capabilities for Network DevOps scenarios, including:
- Task Orchestration and Automation: NetBox already supports executing certain functions as background tasks, with plugins enabling additional task queuing. However, supplementing with Celery introduces sophisticated functionalities such as orchestration of task chains, groups, and chords. Task chains ensure a sequence, where a task’s output feeds into the next. Task groups optimize efficiency with concurrent execution, while Chords, a specialized group type, permit parallel task execution with a subsequent callback.
- Scalability and Performance: Celery’s scalability features provide improved performance and scalability in Network DevOps. Celery allows for the distribution of tasks across multiple workers, enabling efficient processing of high volumes of network-related operations. This combination ensures that workflows can handle growing network infrastructures and increasing workloads effectively.
- Real-time Monitoring and Alerting: The integration of Celery and NetBox facilitates real-time monitoring and alerting. Celery’s monitoring capabilities combined with NetBox’s network data collection enable the tracking of network device status, health metrics, and configuration changes. Alerts can be triggered based on predefined thresholds or events, allowing for proactive network management and issue resolution.
- Intelligent Network Documentation: Celery integrated with NetBox enables intelligent network documentation. Celery can automatically retrieve and update network information from NetBox, ensuring that the documentation remains accurate and up-to-date. It allows for generating comprehensive network diagrams, inventory reports, and configuration backups, providing a centralized and reliable source of network documentation.
- Workflow Optimization and Collaboration: Combining Celery and NetBox enhances workflow optimization and collaboration. Celery’s task scheduling capabilities enable the automation of routine network tasks, freeing up time for network engineers to focus on more critical activities. The integration with NetBox enables seamless collaboration by providing a centralized platform for managing network assets, configurations, and tasks, leading to increased productivity and efficiency.
By combining Celery and NetBox, Network DevOps teams can leverage the power of distributed task processing, automation, scalability, real-time monitoring, intelligent documentation, and optimized workflows. This integration streamlines network operations, improves efficiency, and empowers network engineers to effectively manage and scale complex network infrastructures.
An Overview of the Netbox Celery Plugin
The plugin introduces an easy-to-navigate user interface that lists Celery tasks and their corresponding results. An illustrative view of this interface can be found in the following screenshots:
Celery Results List
The displayed screenshot above provides a snapshot of the various Celery tasks that have been executed, along with their respective outcomes. Notably, in this scenario, the tasks revolve around the onboarding process for network devices.
Celery Results Details
The screenshot above focuses on the detailed results of individual Celery tasks. The integrated logger provides an in-depth insight into each task’s execution, detailing the steps taken during the operation. It’s an invaluable tool for understanding task performance, identifying issues, and optimizing task execution in the future.
Getting Started: Installation
Initiating your journey with the Netbox Celery plugin is as easy as running a pip install command:
Once installed, you’ll need to include ‘netbox_celery’ in your list of plugins within the Netbox configuration:
This sets up the plugin, paving the way for you to leverage the power of Celery within your Netbox environment.
Delving Deeper: Configuration and Additional Processes
Once installed, you will need to initiate three additional processes to enable running jobs:
- Redis Server
- Celery Worker
- Celery Beat (optional)
Redis Server is likely already installed as part of your Netbox environment. This can be easily verified using the redis-cli ping command, which should return PONG if the server is running correctly.
The Celery Worker process can be started in your netbox directory, where the manage.py file is located. Simply use the command:
The optional Celery Beat process is responsible for task scheduling. You can initiate it with the command:
Leverage Celery Beat for Scheduled Tasks
The power of scheduling tasks with Celery Beat is at your fingertips. You can easily configure periodic jobs via the Django admin panel.
Powering Up Your Automation: Creating Tasks
Tasks are the building blocks of your automation journey with the Netbox Celery Plugin. The ‘CeleryBaseTask’ base class is provided for you to build tasks, ensuring that all necessary features for the plugin to operate are included.
Here’s a simple example of creating a task that logs “Hello World!”
The Netbox Celery Plugin opens up a world of automation possibilities within the Netbox environment. It is truly a tool that can help revolutionize how you manage and automate your network tasks.
Your experiences and insights using this plugin are invaluable to us. Check out our Github site to start your journey and don’t forget to share you stories and feedback.