How to Start Learning Network Automation?
If you've found your way here, it's probably because you're curious about Network Automation and want to know how to get started. This blog post is designed specifically for you - Network Professionals who have little or no prior knowledge on the subject.
In this blog post, we'll talk about 'how to get started with Network Automation' in a very simple way, without any confusing buzz words.
My Journey into Network Automation
Let me share with you how I got into network automation. A few years back, I was working at a job where I had to manage 20+ Cisco ASAs. Sometimes, I needed to apply the exact same configuration, like SNMP, NTP or syslog server settings, to all of these firewalls. Doing this manually for each device was a real struggle.
That's when I heard about Ansible, but I didn't know anything about it at the time but decided to give it a try as a test project. To my surprise, it took me just a few days to set up Ansible and get it working. And wow, it made a huge difference very quickly. I could easily push the same configuration or run the same 'show' command on multiple firewalls at once. This experience made me realize the power of Network Automation and inspired me to learn more.
Looking back, I can't imagine my workdays without Python now. Like you, I often found myself with a lots of things to do that were necessary but repetitive. If it weren't for automation, I'd probably be pulling my hair out!
But here's the thing, with Python, I've been able to automate so many of those tasks. Now, instead of spending hours on manual work, I use that time more creatively and strategically. It's a game-changer for me.
Just to give you a quick overview, here is a script that I often use to quickly take a backup from multiple devices and save it locally before I start any big migration or changes. This give me a peace of mind that I have the latest config handy if anything goes wrong.
from netmiko import ConnectHandler
import getpass
passwd = getpass.getpass('Please enter the password: ')
file_dir = '/Documents/config-backup/backups'
switch_list = ['10.10.15.10', '10.10.15.11', '10.12.15.67']
device_list = []
for ip in switch_list:
device = {
"device_type": "cisco_nxos",
"host": ip,
"username": "admin",
"password": passwd,
"secret": passwd # Enable password
}
device_list.append(device)
for device in device_list:
host_name = device['host']
connection = ConnectHandler(**device)
show_run = connection.send_command('show run')
with open(f"{file_dir}/show_run_{host_name}.txt", 'w') as f:
f.write(show_run)
connection.disconnect()
Learning Through Real-World Problem Solving
Acquiring new knowledge is often easier and more memorable when you have a real-world problem to solve, as it allows you to directly apply what you've learned and see the impact it has on the issue at hand.
This doesn't mean you should wait until you face a problem to learn a new topic. However, learning becomes more effective and faster when you're trying to solve a real-world issue, as it allows you to see the practical implications of the concepts you're learning. By applying your knowledge to actual problems, you'll not only gain a deeper understanding of the subject but also be more likely to retain the information and develop your problem-solving skills. This approach to learning can be incredibly beneficial, as it bridges the gap between theory and practice, making the learning process more engaging and meaningful.
Too Many Things to Learn
As a Network Engineer, you already have a lot on your plate. With the rise of automation tools and technologies like Python, Golang, Ansible, Terraform, APIs, Docker, and more, it's easy to feel overwhelmed. As a beginner, it's nearly impossible to learn everything at once. So, where do you start?
First, avoid the trap of spending too much time researching what to learn instead of actually learning. It's essential to strike a balance between understanding your options and taking action.
A Brief Note on Linux
As you start on your Network Automation journey, it's important to learn at least a little bit about Linux. You don't need to be an expert, but having a basic understanding of Linux operations will be immensely helpful. Familiarize yourself with tasks such as installing packages, navigating directories, and running commands. For example, knowing how to install Ansible on Linux is an essential skill for getting started with automation.
Remember, every bit of Linux knowledge you acquire will contribute to a smoother and more successful Network Automation experience.
Why Ansible is a Great Starting Point?
I believe that Ansible is the best place to start for beginners compared to other tools like Python. The reason is that Ansible is very easy to learn, and it uses YAML as its Domain-Specific Language (DSL)
By using YAML, Ansible makes it simpler for beginners to create, understand, and manage configuration files. The language is human-readable, which means you can easily understand what's going on in your automation tasks. So, if you're new to network automation, I highly recommend starting with Ansible to help you gain confidence and experience in the world of automation.
If you're eager to learn more about Ansible and how it can help you with Network Automation, I've got you covered. Check out the blog posts listed below, where I dive into the basics of Ansible. These posts are designed to help you understand the fundamentals and get you started on your journey to becoming an Ansible expert.
Ansible Use-Cases
These examples will illustrate how Ansible can make common network management tasks easier and more efficient.
- Creating the same VLANs on multiple switches - Ansible allows you to easily create and manage VLANs across multiple switches. By defining the desired VLAN configurations in a playbook, you can apply the same settings to all your switches in just one run.
- Applying the same configuration across a group of switches - With Ansible, you can quickly apply the same configuration to a group of switches. This is particularly useful when you need to enforce consistent settings for security, routing, or access control across your network.
- Running IOS upgrades - Keeping your network devices up-to-date is crucial for security and performance. Ansible simplifies this process by automating the upgrade of IOS on your network devices. You can define the desired IOS version in your playbook and Ansible will take care of the rest, ensuring all devices are updated consistently.
- Easily provisioning new devices - Setting up new devices can be time-consuming and prone to human error. Ansible streamlines device provisioning by automating the process. By creating a playbook with the desired configuration, you can easily apply it to new devices, saving time and reducing the chance of mistakes.
Sign up for Packetswitch
A collection of articles focusing on Networking, Cloud and Automation
No spam. Unsubscribe anytime.
Expanding your skills with Python
Once you become confident working with Ansible, you may encounter some limitations and wish for more flexibility. That's where Python comes in. Python is an extremely versatile programming language that allows you to achieve virtually anything in the realm of network automation.
One popular Python library, Netmiko, makes it easy to interact with network devices. It provides a simple and effective way to establish connections, automate tasks, and retrieve information from your network infrastructure.
However, before diving into Python for Network Automation, I highly recommend learning the basics of the language first. Understanding the fundamentals of Python is crucial to ensure you don't leave any knowledge gaps. By building a strong foundation in Python, you'll be better equipped to tackle advanced network automation tasks and create custom solutions for your specific needs.
To start learning Python, consider exploring resources such as online courses, books, or tutorials that focus on the language's core concepts. Once you're comfortable with the basics, you can then apply your Python skills to network automation challenges and unlock the full potential of this powerful programming language. One of the books I highly recommend is 'Automate the Boring Stuff with Python' which taught me the fundamentals.
To see how Python can be utilized in network automation, feel to check out some of the use cases covered in my blog posts. These examples will provide you with a better understanding of Python's power and flexibility in managing and automating network tasks.
Exploring Beyond Ansible and Python
While this blog post has primarily focused on Ansible and Python, they are just the tip of the iceberg when it comes to network automation. There are several other powerful tools and technologies that you might want to explore as you advance in your automation journey.
Terraform, for example, is a popular infrastructure-as-code software tool. It allows you to provision and manage your network infrastructure using a simple, declarative programming language. You can define and provide infrastructure using a declarative configuration language called HCL.
Netconf is a network management protocol that you can use to install, manipulate, and delete the configuration of network devices. It's built on an extensible Document Remote Procedure Call (D-RPC) that uses XML encoding for data exchange.
APIs, or Application Programming Interfaces, are another crucial aspect of network automation. They allow different software applications to communicate and share data with each other, making them essential for integrating different network management and automation tools.
Golang, also known as Go, is a statically typed, compiled language known for its simplicity and efficiency. While it's not as commonly used as Python for network automation, it's gaining popularity and might be worth exploring.
Remember, there's no 'one size fits all' when it comes to network automation tools. Depending on your needs and the specific tasks at hand, different tools might be more suitable. It's always beneficial to have a broad understanding of the various tools available, and then you can delve deeper into the ones that best align with your work.
So, while you might start with Ansible and Python, don't stop there. Keep exploring, learning, and expanding your toolkit. The world of network automation is vast and exciting, and there's always something new to learn.
Git
Of course, we can't overlook the importance of Git in the world of network automation. Git is a distributed version control system that's widely used in software development and increasingly in network automation as well. It allows you to track changes in your code, collaborate with others, and revert back to previous versions if something goes wrong.
In the context of network automation, Git can be used to manage and track changes in your automation scripts and configurations. For example, if you're using Ansible to manage your network configurations, you can use Git to version control your Ansible playbooks. This allows you to see who made what changes and when, and it provides an easy way to revert back to a previous state if a problem arises.
Easier Than You Think
I want to reassure you that learning network automation is not as difficult as it may seem, especially when compared to mastering network protocols like OSPF, EIGRP, STP, and BGP. In my experience, getting a grasp on network automation tools is actually easier than fully understanding complex networking concepts.
By dedicating some time and effort to learning these tools, you'll soon find that automating network tasks becomes second nature. So don't be intimidated by the idea of learning new tools. Embrace the challenge, and you'll quickly see the benefits of incorporating these powerful tools into your network management toolkit.
Beginner Projects
To help you kickstart your journey into network automation, I've put together a list of beginner-friendly projects.
1. Automate Device Configuration Backup
If you don't have a proper Network Configuration Backup solution (NCM) in place, you can create one yourself using Ansible. Rather than manually copying and saving backups, invest a few days in developing an automated solution. Ansible can help you with this process, ensuring that your network configurations are securely backed up and easily accessible.
In addition to automating the backup process, you can use Git to store your network configurations. Git allows you to track and view historical changes to your configuration files. This is one of the projects I worked on and you can check it out here.
2. Gather Device Serial Numbers and OS Version
While it might seem less exciting, there are times when you'll need to quickly list all device serial numbers or OS versions in your network. Instead of manually checking each device, you can create a simple automation script using Ansible or Python to gather this information for you.
By developing a script that connects to your network devices, retrieves their serial numbers and OS versions, and then presents the data in a readable format, you'll save time and effort while ensuring accuracy. This project will help you learn how to interact with devices, parse the required information, and present the data in a useful way.
3. Automate Firmware Upgrades
Another great project is firmware upgrades. The typical process involves downloading the image from the vendor website, copying it to an FTP/SCP/TFTP server, transferring the image to the network device, performing pre-checks, starting the upgrade, and carrying out post-checks and verification. This task can be quite manual and time-consuming, but with Ansible, you can automate most of these steps.
For a beginner project, consider creating an Ansible playbook that performs the actions mentioned above. Developing a playbook for Cisco IOS upgrades will not only help you learn the basics of Ansible but also save time and reduce errors in your future firmware upgrades.
As a starting point, you can refer to my blog post on how to upgrade IOS-XE on Catalyst 9000 switches using Ansible. This guide will provide you with a solid foundation and practical examples to help you build your playbook and enhance your network automation skills.
4. Standardizing Device Hostnames
Another practical project you can start with is changing the hostnames on multiple network devices. Imagine you have over 100 devices, and you want to standardize the hostnames to uppercase. This task, while simple, could be tedious and time-consuming if done manually.
However, with network automation tools like Python's Netmiko library or Ansible, you can automate this task and complete it more efficiently. By creating a script or playbook, you can easily update the hostnames on all devices in one go, saving you time and reducing the risk of manual errors.
This project will not only give you hands-on experience with network automation tools but also provide you with a practical solution to a common network management task. Tackling such real-world problems will help you understand the power and potential of network automation, making your learning journey more engaging and rewarding.
Sign up for Packetswitch
A collection of articles focusing on Networking, Cloud and Automation
No spam. Unsubscribe anytime.
Conclusion
In conclusion, learning Network Automation tools like Ansible and Python can greatly simplify your network management tasks. By starting with beginner-friendly projects, you'll gain hands-on experience in automating device configuration backups, gathering device information, and parsing output to organize data.
Remember, the key to success is to start small, stay focused, and build your skills incrementally.