Network Automation Basics
- Network Automation Basics
- Complete Beginner
- How do I get started with Linux?
- How to install Ansible
- What do I automate?
- I know a bit!
- Network Programmability & Automation
- I have been writing code for a while
- Python Network Automation for Beginners
- Frequently asked questions
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 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.
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
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
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.
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.
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
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!
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: