In the world of network engineering, automation has completely transformed the way things work. But, before automation, setting up and managing networks was a tedious job filled with challenges. Engineers had to manually type out configurations, often doing the same tasks repeatedly on different devices. This led to mistakes and wasted time.
Then came automation tools like Ansible, Chef, and Puppet, which changed everything. They made network management much easier and allowed for scalability. But there was still a problem: creating automation scripts required a lot of technical know-how and was prone to errors because it relied on human input.
And that's why we built Bubbln. It's a game-changer in network engineering, integrating AI into Ansible to take automation to the next level. With Bubbln, we can automatically generate and execute playbooks with incredible accuracy, thereby improving automation efficiency and increasing network engineer’s productivity. It was developed using Python programming language and acts as a bridge between ChatGPT and network systems, making interactions seamless and deployments effortless.
AI-Driven Playbook Generation for OSPF and EIGRP based networks: Bubbln has been rigorously tested to leverage ChatGPT for generation of playbooks for networks based on OSPF and EIGRP networks, with a very high accuracy rate.
Auto-creation of Inventory files: Users do not need to prepare the hosts file. Bubbln will auto-generate this file from input provided by the user.
Customizable Configurations: Users can input specific router protocols (OSPF or EIGRP), interface configurations, and other network details to tailor the generated playbooks.
Documentation: Bubbln automatically creates a report that contains the network configurations, prompts, and generated playbooks for easy reference in future.
No expertise required: By auto-generation of the playbooks and inventory file, Bubbln has been able to eliminate a major hurdle to network automation – need for users to learn the automation tools e.g Ansible, Chef.
Improved Efficiency: With AI automation, Bubbln speeds up the deployment of network configurations, reducing the time required for manual playbook creation, thereby increasing the productivity of network engineers.
There are two main approaches to installing Bubbln on your local machine.
Bubbln has been packaged using docker containers for easy distribution and usage. The following steps can be followed to deploy the Bubbln container on your local machine.
Ensure docker is installed on your local machine by entering the below command. This command works for windows and linux OS:
docker --version
The version of docker would be displayed if it is installed. Otherwise, please follow the link below to install docker on your machine:
Download the docker image: Create a directory for the project and download Bubbln image using the below command:
docker pull olasupoo/bubbln:latest
Run the docker container using the below command:
docker run -it --network host --name bubbln-container olasupoo/bubbln
Install nano
apt update apt install nano
nano ssh_ip_addresses.txt
https://platform.openai.com/docs/quickstart?context=python
Initialize Bubbln by entering the below command:
python3 bubbln.py
You can clone Bubbln’s GitHub repository by following the below steps:
python -V
sudo apt update sudo apt install python3.10
git --version
If git is installed, the version number would be displayed, otherwise, you can issue the following commands to have git installed on your machine:
sudo apt update sudo apt install git
git clone https://github.com/olasupo/bubbln_network-automation.git
pip show virtualenv
If the output shows something similar to the below, then go to the next step to install virtualenv
WARNING: Package(s) not found: env, virtual
Issue the below command to install virtualenv:
pip install virtualenv
python3 -m venv chosen_name_of_your_virtual_env
source venv/bin/activate
sudo apt install python3-dev && sudo apt install gcc && sudo apt install libssh-dev
You can then run the below command to install the necessary packages for the app.
pip install -r requirements.txt
Update the ssh_ip_addresses.txt file: Update the ssh_addresses.txt file with the SSH IP addresses of the routers you want to configure. Bubbln will utilize this information along with the login credentials (inputted at runtime) to automatically generate a hosts.yml file required by ansible for network configuration.
Obtain an OpenAPI API Key: You may follow this guide to sign up and obtain an API key
Utilizing a Virtualization machine of choice, setup a network with the following basic configurations:
python3 bubbln.py
Bubbln serves as an intermediary between ChatGPT and a network infrastructure, providing logic, control functions, and facilitating network automation. Its operation can be summarized as follows:
Figure 1Bubbln architecture and interaction with a network of four routers.
When Bubbln is initialized, it checks the “user_config.pkl” file to see if Bubbln has ever been initiated. This is indicated by the presence of a welcome message status in the file. If it exists, Bubbln jumps straight to request the user to input the OpenAI key. Otherwise, it displays a welcome message, and updates the user_config.pkl file accordingly. Upon successful input of the API key, the user is prompted for the SSH credentials of the routers. These parameters are then encrypted and saved in the user_config.pkl file. The SSH credential is later decrypted and parsed as input to dynamically generate a hosts.yml file at runtime.
Responsible Code Section: bubbln.py: welcome_message_feature()
Figure 2 Bubbln's welcome message.
In the parameter input stage, Bubbln first checks for the existence of a file called “router_configuration.pkl”. If it exists, the user is prompted to decide whether to load an existing configuration or input a new set of configurations. If the file is empty or non-existent, then users are prompted to input the configuration parameters for each router on the network. These parameters serve as variables that are combined with hardcoded instructions written in natural language to form the prompt sent to ChatGPT. Key parameters include:
Router Configurations:
- OSPF Area
- OSPF Process ID
- Number of networks to advertise (OSPF/EIGRP)
- AS Number (EIGRP)
- Interface names
- IP Addresses (in CIDR format)
This module also ensures that parameters are keyed in using the correct data type and format e.g. IP addresses are expected in CIDR format and OSPF Area should be of type integer. Upon completion of parameter input, all parameters are saved into a file called “router_configuration.pkl” upon validation of accuracy by the user.
Responsible Code Section: parameter_input.py
Figure 3 Bubbln receiving Network Parameters.
Before generating the prompt, a summary of the inputted parameters is displayed for user validation. This step ensures accuracy and minimizes errors. Users are given the option to make corrections if any discrepancies are found.
Responsible Code Section: parameter_input.py: validate_inputs()
Figure 4 Bubbln Awaiting Validation of Inputted Network Parameters.
After validation of inputted parameters, Bubbln composes the prompt by combining the inputted parameters with a set of well-engineered hardcoded instructions written in natural language.
Responsible Code Section: prompt_generator.py
The auto-composed prompt is then sent to ChatGPT utilizing gpt-4 chatCompletions model with a temperature parameter of 0.2 and maximum tokens of 1500. The following functions were designed into this process stage
Responsible Code Section: chatGPT_prompting.py
Figure 5 ChatGPT prompting in progress
After ChatGPT processes the prompt from Bubbln, it provides a response which usually contains the generated playbook and explanatory notes. Bubbln then extracts the playbook from the explanatory notes by searching for “---” which usually connotes the start of playbooks and saves each generated playbook uniquely using the nomenclature Router_i_Playbook.yml.
Responsible Code Section: playbook_extractor.py
Figure 6 ChatGPT-generated playbook.
Bubbln loads the saved “Router_i_Playbook.yml” playbook and dynamically generates the hosts.yml file and parses them to the python library ansible_runner for further execution on the configured network. Bubbln generates the hosts.yml file at run time by using the pre-inputted SSH credentials in user_config.pkl file - and decrypts them, as well as IP addresses from the ssh_ip_addresses.txt file, as inputs
Responsible Code Section: playbook_execution.py
Figure 7 Playbook execution in progress
Upon successful execution of all playbooks, a query of the routing table on router 4 indicates that router 4 could reach all the prefixes on the network.
Figure 8 Output of 'sh ip route' executed on R1
Throughout the execution process, Bubbln manages the creation, saving, and loading of various files to streamline the network automation process.
Figure 9 File structure after successful deployment of a four-router network
We are glad to hear your thoughts and suggestions. Kindly do this through the discussion section of our GitHub - #1 (comment)
We can also be reached on:
Olasupo Okunaiya – olasupo.o@gmail.com
Owner
Contributors
Categories
NetworkingEnterprise NetworkingProducts
IOS XRProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community