Network Automation Basics
At a basic level, network automation is tools and processes that will transition the manual configuration of network devices to software applications and processes that can complete these changes and audits reliably and consistently.
Do you want to learn network automation and network programmability but don’t know where to start?
The role of the network engineer is changing, and at a rapid pace.
Do you feel like if you are not using Ansible for Network Automation or writing Python Network Automation scripts to automate your network that you are falling behind and your job will be gone in a few years?
Don’t worry, that’s not going to happen anytime soon, but things are changing.
You do need to learn a bit of Python and you do need to start using Ansible. In the rest of this post I will show you where to start and how to learn these new skill that network engineers need to get to grips with.
I will split this post into three sections:
- Complete beginner
- I know a bit
- I have been writing code for a while now
If this is all new to you, then you might want to start here – What is Network Automation?
Complete Beginner
If you have never heard of Linux, Network Programmability, Ansible or Python and the idea of learning network automation and writing code sends a shiver down your spine don’t panic you will be in one of two camps.
- I never want to learn any network automation and am happy doing my job .
- I don’t know anything but really should start learning how to automate my network devices.
If you never ever want to learn any network automation, and the thought of using Python to configure network devices seems alien to you, nobody is going to force you and the world will always be looking for skilled network engineers who don’t know Python.
You might find your job getting harder, but depending on where you are in your career that might not be a problem at all.
Just read this for information and carry on with your life.
If you don’t know anything but really feel that you should start learning network automation then I would advise you start with these 3 things in this order.
- Linux
- Ansible
- Python
- Git
Any network engineer who does not understand basic Linux is going to struggle if you want to get into network programmability.
Then I would dip my toe in the water with Ansible.
At the same time you also need to look at Git and Python. (Cisco have adopted Python as their programming language of choice and most new network devices now come ready installed with Python.)
Take some official network automation training – there are many courses around.
Check out my Ansible Network Automation Course Here
There are several ways to learn network automation:
- Online resources: There are many online resources available for learning network automation, such as online courses, tutorials, and documentation. Some popular resources include the Ansible documentation, the Python Network Programming course on Udemy, and the Network Automation with Python course on Pluralsight.
- Books: There are also several books available on network automation, such as “Network Automation with Python” by Jason Edelman, Scott Lowe, and Matt Oswalt, and “Mastering Ansible” by Jesse Keating.
- Hands-on experience: The best way to learn network automation is through hands-on experience. You can start by setting up a lab environment and practicing automating tasks on your own.
- Network automation tools: There are several tools available for network automation, such as Ansible, Salt, and Puppet. Familiarizing yourself with these tools and learning how to use them effectively will be helpful in your journey to learn network automation.
- Join a community: There are many online communities, such as forums and mailing lists, where you can ask questions, learn from others, and get support as you learn network automation.
How do I get started with Linux?
I would recommend downloading Ubuntu and running a virtual machine on your laptop or look at running the Windows subsystem for Linux
Once you have Ubuntu installed you need to open up the terminal and start running a few commands.
I would also suggest you install Visual Studio Code as your code Editor
Once you are familiar with Linux and can install a few packages go ahead and install Ansible.
How to install Ansible
The most popular tool for network automation right now is Ansible and for good reason. It does not require heavy Python knowledge and you can get started in under and hour running your playbooks to automation your network devices.
Ansible is written in Python but does not require any Python knowledge to operate it.
To install Ansible just drop into a terminal on your Linux machine and issue the following commands.
What do I automate?
So now you have a network automation platform installed on your laptop, what next?
You are going to need some network devices to automate. This can either be home lab devices, physical or virtual.
You might have some dev or test devices at work, or you can even use the Cisco Devnet Sandbox
There are many ways to run virtual devices on your laptop or a small server in your lab using tools such as GNS3, EVE-NG or Virl
I know a bit!
At this point you should now have the following in place.
- Linux installed
- Ansible installed
- At least one network device available for you to connect to via SSH
Learning network automation and network programmability is not difficult it is just know the steps you need to take to get started, once you are up and running the options you have are unlimited!
I would suggest you start with a simple playbook like backing up a configuration file or running a simple command and then once you have that working you can then start to increase your reach with more virtual or test devices. Then when you are happy your playbooks are running as expected you can start to run this on your production network.
Start with a non-impact task!
While network automation is very powerful and can save you a lot of time, it is also a very quick way to destroy your network if you get things wrong! So be careful.
Don’t let this put you off learning network automation it is just a warning to make sure you test before you push any automated tasks to your live network.
I started by taking a backup of my entire network, starting with Cisco switches and then expanding the reach to the firewalls and other devices. Within a few weeks I soon had a playbook that I could push one button and backup all configs.
Another great bonus to network automation is simply documenting your network. A lot of network engineers have every device detailed and tracked in their monitoring and connectivity details arranged in something like SecureCRT.
Others however are still remembering IP addresses for each device and using the same password for every device
Do you know someone like that?
So just the process of building out your Ansible hosts file will start to document your network.
Remember that network automation is not a sprint, it is a marathon.
7 Simple Network Automation tasks you can do with Ansible
Ansible is considered to be the easiest point of entry into network automation and you can be up and running in under an hour automating your network. Here are 7 simple network automation tasks that you should start with.
If this is your first time using network automation it would be very wise to work on a lab environment first or limit your tasks to specific devices and only perform read only tasks!
Network Programmability & Automation
Now you have been taking backups of your network using Ansible and can run some simple show commands, what next?
At this point you should have some confidence in your network automation platform and you can start to push a config out to the devices!
Again – start simple create a simple configuration change that you need to apply to all your switches.
e.g. updating the NTP server address.
Build the configuration and then push it to a single switch first and make sure it works, then when you are happy push the button and push the change to all your switches.
Depending on how many switches you have this could be a small task or if you have 1000’s of switches, this one simple task could have just saved you hours!
The other major benefit of network automation is that this change will have been performed with 100% accuracy!
You have not had to SSH into 1000 switches and make a simple change. This is where mistakes happen.
Check out this post: What I wish I knew before I started with network automation
I have been writing code for a while
Hopefully at this point you have got some confidence in your network automation platform and are comfortable pushing simple config changes and taking system backups.
One of a few things will happen. You will say this is doing exactly what I want it to do and I am happy.
Or like me, you will want to do more automation!
This will either be more complicated changes, building out a gold template for all your device configurations or performing these changes quicker.
Python Network Automation for Beginners
I use Ansible most days in my daily job to perform the simple tasks I have detailed above, but when you really want to scale your capabilities you need to use Python.
Cisco and most of the network community have adopted Python as the programming language of choice for network automation.
The reason for this is Python is very good at performing scripting tasks, which is what network engineers are doing every day.
If you can learn some Python basics it will benefit you greatly for your future.
Check out some of my Python Scripts for Network Engineers
Nornir is a Python Automation Framework. It’s a library which you install and basically takes care of all the elements of doing network automation that can be problematic. i.e inventory management and connectivity.
It uses Netmiko to handle the connectivity so you can focus on what you want to do.
Also as you are learning Python, which is one of the most popular programming languages in use today you are building skills that you can use in many other areas.
If want to know more – check out my network automation courses
How important is Network Automation?
Network Automation is essential for the operation of an enterprise network, compliance checks can be run easily, remediation of issues are easy which produce more accurate data for analysis. Repeatable tasks can be run with 100% accuracy and you cannot run a network of any scale without automation. It is an essential part of network engineering and anyone who is not adopting network automation is going to fall behind.
Who is the leader in Network Automation?
The major vendors in network automation are Cisco, Juniper Networks, IBM, Micro Focus, and NetBrain to name a few. In terms of consulting Network to Code are the leaders in providing consultation for network automation, Roger Perkin is one of the leading network automation engineers in the UK.
Is Network Automation the Future?
As companies continue to embrace digital transformation, network automation is going to play a central role in ensuring reliable, secure, and agile network infrastructure. It is an essential part of network operations and any company who is not adopting any kind of network automaton will struggle to keep up with the pace of change required for modern networks.
What problems does network automation solve?
Network Automation can speed up time-consuming processes like manual configuration changes, software upgrades, compliance checking & configuration management, freeing up human work hours and helping to reduce errors.
Frequently asked questions
How do I automate my network?
There are many different steps to automating your network. Firstly you need to decide what platform you are going to use, then decide on a source of truth. Where are you going to pull all the details about your network devices from. Then identify which tasks can be automated, also decide who is going to manage this. Finally when you have covered that you need to consider CI/CD and look into the self healing network.
Why is network automation important?
With networks getting more and more complicated every day and the amount of devices both on site and in the cloud increasing at an exponential rate there is simply not enough man power to fully configure the networks of today without automation. You can either increase your workforce or look to increase your investment in network automation to streamline routine network changes and eliminate human error from configuration changes.
How do you automate a network in Python?
If you just want to use Python to do all your network automation I would strongly recommend you look at using Nornir as a framework to your tasks. However, there is nothing stopping you automating your entire network using pure Python scripts if you know what you are doing!
Conclusion:
So my advice for anyone looking at learning network automation is to just get started.
Try to limit or stop any interaction with your network device via the CLI, try to use Ansible or Python to make your changes.
If like me you enjoy learning new skills, you are going to love the journey. As a network engineer in 2020 you need to hear what Cisco is saying. They are using Python for everything. So start learning and getting used to performing your daily tasks using code and not the CLI.
Other related articles:
- Top 7 Open Source Network Automation Tools
- Ansible Network Automation Course
- Python Scripts for Network Engineers
- How to Build a Network Automation Lab
Sainath
Hi Roger,
Wonderful article!! WIll recommend to my team to look at.
I’ve been wanting to start learning network automation using python. Is it absolutely essential that i learn ansible first before i do python?
Thanks,
Sainath
Roger Perkin
Thanks Sainath, no they are really two different things. Most people would do a bit of Ansible just to get their head around some basic network automation concepts, i.e. having some config built from a template and pushing it to some devices, or pulling information back from the network devices. Python on the other hand is a programming language which can be used for numerous things and one of them being network automation. It makes sense to learn both. But if you were a Python guru it would not make learning Ansible any easier. What I say to anyone is your power with a tool is only as good as your skills. So try them both and see which one you like. I like Ansible for doing predictable tasks i.e upgrading software on 1500 switches – Ansible is great for that. Scripting a multi vendor network configuration template – might be better using Python / Nornir HTH