Intro to Automation Part 3 – Your New Best Friend—Git!

Blog Detail

For the third iteration of the Intro to Automation blog series, I want to discuss what I believe to be one of the more important tools a Network Engineer can learn to use early in their network automation journey. Even before writing a single script or a single piece of automation, Git can be extremely helpful.

Just like in the previous posts, I intend to focus more on the high-level benefits of Git, why it is useful, and different ways of looking at it from a Network Engineer’s perspective, or for someone new to Git in general.

What Exactly Is Git?

Before I can explain Git, I want to explain the underlying technology of what exactly Git is. See, Git is the name of a program of the type called Version Control Software, or VCS for short. VCS is essentially software used to manage configuration changes to one or more files and tracking any changes made to them. A good VCS system will let you see what changes were made to different files, who made them, and when they were made, and will allow you to roll back one or more changes at a time.

There are many different types of VCS programs available. Some are open-source, while others are proprietary with commercial support. Each has its own benefits and drawbacks and different models for how they work. This Wikipedia article explains the models well, and also lists different software available that use each model:

  • Local data model – Everyone uses the same file system
  • Client-server model – Everyone uses a shared single repository
  • Distributed model – Everyone works directly with their own local repository, and changes are shared between repositories later

Defining Terms

Before I go further, there are some terms used in Git that I want to explain, as I’ll be using them throughout the rest of the article.

  • Repository – This is a directory, like a folder on your computer, that contains all of the files in the project that are managed (tracked) by Git, as well as a full revision (change) history.
  • Revision history – A list of every change made to one or more files, with details on exactly what was changed.
  • Commit – To save the state of one or more files in your repository. All changes in the file(s) can then be viewed from any previous commits made to the same file.
  • Merge – To apply a specific set of commits (one or more changes to files) into the primary version of existing files, so that the primary version has the new changes applied.
  • Trigger – To activate a process or service in a system.
  • Deploy – To apply a set of changes to another system or network device. This term is usually used when referencing automation making the changes, but also works when referring to manual changes.
  • Webhook – Having one software or service trigger or be triggered by another service over HTTP/S. These can be manually triggered or triggered automatically when a certain condition is met (someone makes a commit, a specific file is changed, etc.).

There are many other terms associated with learning and using Git, but these are the specific ones used in this article.

Git as a VCS

Git is the most popular VCS available, and is used by many developers and engineers around the world. It follows the “Distributed model” architecture listed above. Some of the benefits that make it so popular are:

  • It is very fast.
  • It is distributed. This means that even without an internet connection, if you have Git already set up and configured on your computer, you will have a full history of all changes made to a repository available to you.
  • It is open-source. This makes it free to start using.
  • It is very popular, which makes finding additional resources for using Git, or articles about learning Git, easy to find.
  • It has great commercial products available for using it. There are popular online resources available that use Git, such as GitHub, that I’ll explain later.

Git for Network Engineers

While it’s true Git is mostly used by software developers or Network Automation Engineers, it can also be useful to a Network Engineer without using any initial automation. In fact, a lot of automation can be built around using Git, which I’ll explain later.

There are many non-automation related use cases, which I mentioned briefly in my previous post. Let’s discuss them in more detail.

Learning to Write Scripts

Before I got into more advanced automation as a Network Engineer, I was still writing small, basic scripts that accomplished various tasks I would perform throughout the day. If you recall, in part 1 of this series I gave an example of the first script I wrote. It was a Python script to generate a unique running configuration file for multiple devices using dynamic settings for each device.

This script took a few months to figure out, fully test, and fix any bugs I encountered. I also thought of new features or things I wanted to add as I progressed in writing it.

I was able to use Git locally, just on my computer, and track all changes to just this individual file. This came in handy a few times when I would commit (save) my changes to Git, then write some new part of the script, only to have it crash every time I ran it. By using Git, I was able to backtrack and see what I had changed specifically, and either revert back certain parts of my script, or if it was causing me too many issues, roll back the entire script to the last time it was working successfully (my latest commit).

Config Backups

There are many different configuration backup systems available, with many different features built in specifically for this purpose. However Git can work for this as well, and can be used later on with more advanced automation workflows.

One example is every time you make a change to a device, as part of the implementation process, you can take a backup of the config and commit it into a Git repository, which will track all changes made to the device. Later on in your automation journey, this process can be fully automated (both the implementation step as well as the config backup step).

Change Control / Auditing

Git can also assist with change control and auditing for certain changes, though there are some limitations. With Git, every time you create a new commit, you’re able to tag it with a comment that briefly describes what exactly the commit is for. For example: “Fix broken feature x” or “Update to support IOS-XE devices”.

For change control purposes, if you are using Git for network device config backups, you could put the ticket number for the change being made as the commit comment. Then if you ever need to go back and see exactly what was done for a change, you can simply search Git for the ticket number.

As for limitations, some more advanced features of Git allow you to go back and fix incorrect commits, their comments, or even delete them from the full revision history. With a basic setup, this may cause issues for certain auditing environments as the integrity of the Git history is not guaranteed.

Adding authentication and logging to Git changes will help improve revision history integrity, which brings us to our next topic.

When first hearing of Git, a lot of people first assume that Git and GitHub are the same thing. This is not the case, though GitHub has become incredibly popular with Git users. Git is the underlying version control software, whereas GitHub is an online platform used to upload, share, and collaborate on Git projects.

GitHub is available online for free, where anyone can create an account and start uploading their Git repositories, or create new ones from scratch. One of the main benefits of GitHub is it allows for collaboration between users. For repositories that are configured as public (anyone can see), people can make a copy of anything you upload, offer to make changes, or make their own changes without sharing. GitHub also offers enterprise options for companies needing to keep what they upload private.

A good analogy would be Git is to GitHub as movies are to YouTube.

This includes sharing ideas or changes with people you work with regularly, or people you’ve never seen. That’s what makes up the broader open-source community!

GitHub Alternatives

I listed GitHub because it’s the most popular service available today. There are other services similar to GitHub that work quite well, with their own strengths and weaknesses. Some of the more popular examples are Bitbucket and GitLab. They all support using Git for version control, support collaboration among other users, and will work just as well as GitHub. The nuances between these and other services are more technical and outside of the scope of this article.

Git and Automation

So how does Git fit into an overall picture of network automation? As you begin your journey into network automation, you’ll end up writing code in Python or another programming language, writing Ansible playbooks, configuration settings, etc. Git fits in well here, not just for tracking file changes, but working directly with automation.

When using a service like GitHub, you can set up certain webhooks that trigger other automation when something in a repository is modified.

For example, I can set up a workflow where, when I create a change to a network device configuration (saved in a repository), GitHub can send a webhook to another service, like Jenkins, Ansible Tower, etc. These other services can then automatically deploy the change to one or more devices, take configuration snapshots automatically, and save them to another “backup” repository.

This can be further expanded when you introduce the concept of Infrastructure as Code. At a high level, this means you don’t configure one device at a time. You save different parts of network device configurations in separate files, then only make relevant changes to the files. For example, you would have one file for SNMP configurations, one for AAA configurations, one for NTP configurations, etc.

When updating a setting in one of these files, and saving the changes in GitHub, it can then be used alongside other automation tools to deploy those changes to any number of devices.

Another great use of Git and GitHub is using their Peer Review process for any changes you intend to make. Before making a change, then committing and merging it into the primary file, you can have someone else double-check your changes and validate them. This adds and extra layer of protection for mistakes stemming from human error. This also lines up well if your company follows some kind of change control process, such as ITIL.

Granted, these ideas involve multiple tools outside of Git and GitHub, but they show some of the possible uses of Git and GitHub to a Network Automation Engineer.

Git Clients

I mentioned this briefly in my previous post, but thought it important enough to bring up again. While Git is natively used with CLI commands, there are various GUI applications that can make learning and using Git easier when getting started. A brief list of some popular ones are:

For me, the ability to visualize some of the changes, along with having important information (like commit comments) more readily available, make using some of these programs my preference. I’d encourage you to learn the CLI, then try some of the above clients and see which way works best for you.


Conclusion

I hope I was able to highlight some of the benefits of learning Git early in your network automation journey. It really is an important tool you can learn to use that will be very beneficial throughout your entire journey. While there are many resources available online for learning Git, I hope to have highlighted some of the benefits of learning Git early for Network Engineers and Network Automation Engineers alike.

 

Thanks for reading, and happy automating!

-Matt

Intro to Automation Series

Part 1 – Rethink How You Think

Part 2 – New Tools for a New Network

Part 3 – Your New Best Friend—Git



ntc img
ntc img

Contact Us to Learn More

Share details about yourself & someone from our team will reach out to you ASAP!

Intro to Automation Part 2 – New Tools for a New Network

Blog Detail

In my previous blog post, I mentioned a few tools you can get started with when beginning your journey into Network Automation. Today, I hope to dive into them further and explore them and a few others in more detail. While there are many tools available for network automation, some are more common than others and will serve as a good foundation when getting started.

If you missed Part 1 of this Intro to Automation series, you can find it here.

Tools Overview

As mentioned in Part 1 of this series, making the transition from Network Engineer to Network Automation Engineer requires a shift in how you think of your network. But with this shift comes a different set of tools you’ll start to use, which will help you as you progress into this field.

There are so many tools out there for Software Developers, but we as Network Engineers tend to think differently and use different tools. It can be overwhelming figuring out which tools to start out with. In this post, I hope to go over some of the most popular ones used by Network Automation Engineers and explain them in a way that you not only understand, but that shows their real-world value to a Network Engineer.

Before I get into tools and software themselves, I need to put in a disclaimer. Just like with all things, there is no “one-size-fits-all” tool or solution that will always work in every situation. Some of these tools will work most of the time, and some will work only in specific instances. My goal is to outline the ones that are the most popular today with a wide range of community or commercial support and explain the pros and cons to each.

Git

I put Git as the first tool in the list on purpose because I believe it is one of the most important tools a Network Engineer can learn to use. Even if you never write a single script or piece of automation, Git can still be very useful for a Network Engineer.

There are many non-automation related use cases, including:

  • Config backups
  • Script backups
  • Version controlling
  • Auditing

Note: Regarding auditing, it can be helpful internally or for external auditors, but may require some advanced setup to meet different auditing and compliance criteria.

Git can be used locally without ever needing to create an account with popular online services like GitHub or Bitbucket. As a new Network Automation Engineer, you can use it to create backups of scripts you write or device configurations. These can be used later to undo a mistake you made, or even answer the timeless question, “when was the last change made and what was it?”

Git is not GitHub, just like the Linux kernel is not Ubuntu.

Git is the most popular version control system available, and used by the majority of developers around the world. It is open-source, easy to use, and with a wide user base has a lot of community support available. While it is natively used with CLI commands, there are various GUI applications that can make learning and using Git easier when getting started. A brief list of some popular ones are:

Or if you use an IDE for writing scripts, they usually include Git support as well. I discuss IDEs more in a later section below.

PlayStation in a Git Article?

There are many features and benefits to Git, but seeing as Git is a VCS or Version Control System, the main one I use Git for is keeping track of different files and how they change over time. In other words, keeping track of all changes made to a set of files and folders.

Here’s a fun analogy for video gamers when learning about Git. When I was a kid, I was playing Tomb Raider II on the original PlayStation. I got in the habit of frequently saving and did it so often I could save the game without thinking about it. Well at one point, I fell off a cliff at the end of a level and went to reload my last save. But muscle memory kicked in and I accidentally saved the game instead of loading it! I had to restart the whole level over from the beginning! I learned a lesson that day, and it’s stuck with me the rest of my gaming life: always have multiple save files, and backup those files whenever possible.

Git can be thought of similarly but with multiple files or directories. Every time you make a “commit” in Git (save your progress), it’s like saving your game in a brand-new save file every single time. Did you spend hours working on a script, only to have it break and you have no idea why? You can easily revert back to any previous snapshot (commit) and start over or use it as a reference point. Yes, I’ve done exactly this before too many times to count!

Fun fact: Git was created by Linus Torvalds, the same person who created Linux!

Python

If there is one programming language I would recommend to a Network Engineer getting into automation, it is without a doubt Python. According to the TIOBE Index, as of September 2021, Python is the 2nd most popular programming language in the world, and about to take over the #1 spot from C. In fact, I’d be surprised if you haven’t heard of Python’s benefits by now or even started learning it. If you haven’t, the best time to start is today.

One of the driving factors behind its popularity is its ease of use and learning curve, specifically for people without programming backgrounds. The benefits of this make it very easy to get into and start writing something useful pretty fast, and yet it can still be used to write complex automation.

With such popularity comes large community support. While learning Python, when you run into a question, chances are someone else has already posted the answer online, and it’s a quick Google search away.

Some of the cons can be realized after using Python for a few years. For example, there are other languages that are inherently faster with certain tasks, though they’re more complicated to learn. Additionally, there are certain software development “best practices” that are taken care of for you under the hood of Python, but need to be learned when using other languages.

In summary, from a Network Engineer just getting into scripting and automation to seasoned senior-level engineers, Python is perfect.

Fun fact: Did you know that some network hardware vendors have native Python support built right in to their devices? For example, if it’s installed and enabled, you can run the command python from privileged exec mode on a Cisco 9k switch and load a Python prompt!

Hello World

In the world of programming languages, there’s a concept called the “Hello World” program. Essentially, it’s when someone who is learning a new programming language learns just enough to print out the phrase “Hello World!” to the screen. It’s seen as a good starting point while learning the basics and is actually really fun to do!

To demonstrate the simplicity of Python when compared to the other programming languages, here’s a “Hello World” program written in the other 2 languages at the top of the TIOBE Index I mentioned earlier, C and Java:

Python

print("Hello World!")

C

#include <stdio.h>
int main() {
   printf("Hello World!");
}

Java

class HelloWorld {
  static public void main( String args[] ) {
    System.out.println( "Hello World!" );
  }
}

Python is about as simple as you can get and makes it easy to get started! As I mentioned before, you may not need to understand what everything in the C or Java examples is right away since Python handles most of that behind the scenes, but you will eventually want to learn what they are and why they’re important.

Important: When starting with Python, make sure you’re using and learning Python 3, not Python 2.

Ansible

Ansible is an open-source automation platform used for managing multiple devices easily. It was acquired by Red Hat in 2015, and it remains one of the most popular open-source automation tools for network automation engineers. Ansible can be used for relatively simple playbooks (scripts that you run) for a single switch, all the way up to complex fleet management systems for thousands of devices!

While there are other open-source tools available that are similar, Ansible is the best and most popular choice for managing network devices for a few reasons:

  1. Agentless – Ansible connects directly to a network device, usually over SSH but can use other methods, and does not require an “agent”, or other piece of software, to already be pre-installed on the device. Installing an agent on a network device for management is not feasible, so this is where Ansible works well compared to similar tools like Chef or Puppet.
  2. Inventories – Want to configure 100 switches without manually connecting to them one at a time? This is where Ansible really shines! Just provide it with a specially formatted inventory file, which includes a list of devices and a few other parameters, and Ansible will handle connecting to them all behind the scenes.
  3. Modular – Similar to Python, with Ansible’s popularity comes a wide range of modules (plugins) you can use. Some are submitted by the open-source community, while others are officially supported third-party modules (e.g., Arista EOS).
  4. Customization – If you need Ansible to do something unique to your environment, or there is a feature not yet created by the open-source community, you can write your own using…..Python! That’s right, Ansible runs off of Python and natively supports custom Python scripts to be imported into Ansible playbooks.
  5. Commercial Support – Since Red Hat’s acquisition of Ansible in 2015, companies can now purchase commercial support for Ansible through Red Hat, or even through third-party companies like Network to Code.

IDEs and Text Editors

Earlier I mentioned a couple popular IDEs available that are free for personal use, however I want to explain them in more detail. An IDE or fancy text editor aren’t things you hear about much, but they’re SO important when working with automation.

As a network engineer, my text editor of choice was a generic notepad-style application, where I mostly used it to write out a switch config before configuring the device by copy/pasting the text into the CLI.

When you get into automation, you’ll be spending a lot more time with scripts, configs, settings files, etc. For this reason, I highly recommend you get a good IDE or text editor right away. The more you use it, the more familiar you’ll become with it. Eventually, you’ll never want to work without it!

One feature that is an absolute must have for whichever program you choose is syntax highlighting. While different programs will use different colors for syntax highlighting, they all essentially work the same. Instead of explaining what this is, look at the below images and ask yourself this question: which one is easier to read through?

Text Editors
Text Editors

IDEs

An Integrated Development Environment, or IDE for short, is an application that contains many common tools used for writing software (or even basic scripts) and is frequently used by software developers. There are many benefits to IDEs, and the popular ones have too many features to list.

Some of the downsides to them are also found with their strengths. They can be complex with many settings that make no sense when first starting out scripting. However in my opinion, their benefits strongly outweigh the negatives and I encourage you to try one out and give it some time before giving up on it right away. Don’t worry about every button or feature, and focus on the basics. As you become more familiar with them, you’ll start learning their features and other benefits more and more.

Two of the most popular ones available today used by Network Automation Engineers are VSCode by Microsoft and PyCharm by JetBrains. The syntax highlighting example above is from this free VSCode extension for Cisco IOS configs, though both support many other color variations and file formats.

Text Editors

There are many, many good text editors out there. Ask anyone who’s been in IT long enough, and they’ll not only have a favorite but a list of reasons why it’s the best. The real answer is there is no “best” text editor, only the one that works best for you. Most popular GUI-based text editors now offer some level of built-in syntax highlighting, but not all. If you’re uncomfortable with starting out with an IDE right away, or if you just want something better than Notepad to use in your day-to-day activities, I list three of the more popular ones available right now that are free to use:

APIs

While not necessarily a specific tool, APIs are more of a back-end technology. In fact, I’m sure you’ve heard before how great APIs are by now from someone you know. Before I wrote my very first script, I had IT friends telling me how great APIs were and how they used them and loved them. But when trying to explain to me what they are, I couldn’t understand why they were so good. I wrote this section in a way that hopefully explains APIs to network engineers that have a hard time grasping their usefulness, and in a way I wish they had been explained to me years ago.

An API allows one application or system to be able to interact with a completely different application or system in a structured, predefined manner with expected inputs and outputs on both sides. Simplified, it is a way for two programs to be able to talk to each other.

An analogy would be how people talk to each other using the English language. If two people can both speak English, then they are both able to understand what each word means, know how to talk to someone so they understand what was said, know what to expect as a response, and what that response means. One person’s response may even differ to the exact same request if it comes from someone they know (authenticated) vs. coming from someone they do not (unauthenticated).

Think of an API like this. Amy natively speaks Spanish (application 1) and Bob natively speaks French (application 2). They normally can’t understand each other, but if they both agree to speak to each other in their secondary language English (APIs), they can communicate in a limited but effective manner. In that analogy, an API is not a translator, but a predefined set of rules (English) for Amy and Bob to talk to each other.

To take it a step further, some types of APIs (like REST APIs) can require another application to be authenticated before it will listen to what it has to say (process the data). In the previous analogy, it is similar to how if Amy is friends with Bob (authenticated), they may respond to each other in one way. However if a complete stranger named Charley (unauthenticated) walked up to Amy and started saying the same thing Bob was saying, she may respond differently.

Note: There are multiple types of APIs, each with its own sets of rules, data formats, communication methods, etc.

Previously as a network engineer, I never really understood why I would need to use them. As a network automation engineer, I now use APIs for my automation scripts to be able to interact with network devices.

Traditionally, if I want to enable an interface on a Cisco switch, I have to connect to the CLI on the switch over SSH, and run these commands:

switch01# config t
switch01(config)# interface FastEthernet1/1
switch01(config-if)# no shutdown
switch01(config-if)# end
switch01# copy running-config startup-config

Simple right? Well, at least simple for humans to perform and understand. However when you start writing scripts to do this, you’ll find it’s a lot harder and very unreliable to do it this way. When I started writing scripts to configure switches, I would have my script connect over SSH and configure it in the exact same way as I would via CLI. While this worked, there are faster, more reliable, and easier ways of doing so.

A common scenario occurs when you try to configure a setting across multiple network devices with different OSs, or sometimes even different versions of the same OS. For example, if you look at the AAA configuration for Cisco IOS, compared to Cisco NX-OS, then compare it again to Cisco ASA, they are all different. As an engineer, I can manually adjust the commands in the CLI on the fly, but in my scripting, I have to account for each variation I might encounter.

Important: I also have to account for variations I am not aware of!

This is where APIs come in. Instead of worrying about variations in each OS or how each command is different, what if I could have my script configure it using the same method and know for certain it will get configured as expected? Or if it fails, can I have it tell me there’s an error without breaking anything? Using an API, you absolutely can!

In this example, you can use a network device or application’s built-in API to send it specific data. It will then receive the request, and since it already knows what to expect, it’s able to parse it out, perform any action requested, then return data back to your script in a pre-formatted and expected way. If you send it information in a way that it isn’t expecting, or are missing information that’s necessary, it will let you know as well!

Examples of data returned can be anything, including:

  • Was the job successful?
  • Command output
  • Configurations
  • Errors encountered
  • etc.

Conclusion

It’s absolutely amazing how many tools and applications you can use when automating your network. It’s even more amazing knowing that most of them are either open-source or offer some sort of free licensing agreement.

I encourage you to start with learning the basics of the tools I’ve mentioned. You don’t have to become an expert in any of them right away. I’ve been using Python for years, and I still learn new things about it every day from my peers here at Network to Code!

I also encourage you to give back to the open-source and network automation community as you progress in your career. Join us in Slack, and feel free to participate in discussions and ask for advice. It’s a Slack community run by Network Automation Engineers for anyone interested in automation, network automation, general networking, or even non-network-related IT systems.

Many resources are available online to learn these tools. While many of them are free and written by the community, Network to Code offers excellent training for those that learn better in a structured class environment. We cover topics such as Python, Ansible, and even general network automation concepts.

 

Thanks for reading, and happy automating!

-Matt

Intro to Automation Series

Part 1 – Rethink How You Think

Part 2 – New Tools for a New Network

Part 3 – Your New Best Friend Git



ntc img
ntc img

Contact Us to Learn More

Share details about yourself & someone from our team will reach out to you ASAP!

Intro to Automation Part 1 – Rethink How You Think!

Blog Detail

I frequently see many network engineers and other IT professionals wanting to get into automation, but having no idea where to begin. The same few questions are asked by people just getting started: What can I automate? Where do I get started? What are some good resources to learn with? When looking at existing automation others have written, it can be amazing to see, yet seem dauntingly complex.

This will be the first in a multi-part, non-technical series intended to help newcomers to the automation scene get started. In this blog post, I intend to answer all of the above questions and give those getting into automation for the first time some good resources to get started with.

Where Do I Begin?

Getting started with automation has never been easier. The amount of open-source tools available, along with the vast array of knowledge and documentation, make it a great time to get into automation. However, with the vast amount of choices available, it can become overwhelming very quickly.

I encourage those of you who want to automate something to start small. Don’t look at an overly complex problem and try to solve it all at once. Start with writing a basic script for one quick, easy and very simple task. Then move up from there, building on what you already wrote and expanding its capabilities as you learn.

What Is a Network Automation Engineer?

Network Engineer is skilled in building and operating networks, traditionally through a CLI, though UI’s are becoming more common.

Software Developer is skilled in developing solutions programmatically by writing code in various programming languages.

Network Automation Engineer is a hybrid of a traditional network engineer with a software developer. Someone in this role benefits from a fundamental networking knowledge to know how the network works, while being able to write automation in software to perform the necessary tasks.

How I Got Started

Everyone’s journey into scripting and automation starts differently. Mine started about 8 years ago with a very basic Python script. At the time, I was configuring new switches and routers multiple times a week for various remote locations. The configuration settings for each device were created based off of a text file template.

For example, when generating a config for a new site “Dallas01”, I would find/replace all instances of “$HOSTNAME” with “Dallas01” in the text file. I would do the same thing for IP addresses, usernames, SNMP strings, interfaces, etc. Because this was all done manually, typos and overlooking settings happened frequently.

You can probably see where I’m going with this.

I started by writing a small script to automatically create the running configuration file for the router based on a few settings. From there, I expanded it to apply the config, support different templates, and added some validation. What started as a 30-60 minute process was reduced down to less than a minute.

What’s more, I was able to share it with other engineers. Not only did they also save time each week, but we also knew our configuration settings would be identical without typos or missing settings.

Figuring Out What to Automate

In light of my above story, think about your current environment. Your first automation does not have to be fully redundant. It does not have to be executed automatically, cover all scenarios, or include any testing and validation.

Disclaimer: While some places use Excel for storing information about the network (as in my example), a much better approach is to use a dedicated Source of Truth tool with a database, such as Nautobot with PostgreSQL. Some previous blog posts that may be helpful can be found here and here.

  1. Identify tasks that are performed frequently.
  2. Estimate how much time it takes to perform one of those tasks one time. Time yourself doing the task.
  3. If anyone else performs this task, estimate how often they do it, and how long it takes them. Add everyone’s time together.
  4. Break down the steps to the task into the smallest chunks possible.
    • Here’s an example from my experience when configuring a device with a template:
      • Open up template text file
      • Open site information file in Excel
      • Identify location being configured
      • Based on info found in Excel spreadsheet, determine settings for device
      • For each dynamic variable found in template file, replace with determined value
      • Save file
      • Copy contents of file
      • Paste contents of file into device
      • Save config
      • Spot-check config
  5. Once a task is automated, record how long it takes to run and compare it to how long it takes to run manually and how often it’s run.

Bonus: This can be a great way to demonstrate ROI to management and your peers, highlighting the benefits of automation.

There are a lot more steps here than you would ever need to tell someone face to face! When I started configuring devices, I was taught this template process by my peers with a few simple steps.

"You find the necessary settings in this Excel file. Copy them into the template, then console into the device, paste in the template, and save the config."

When broken down, we can start to see it in smaller, more manageable chunks.

Sometimes I need to break a step down even further. For example, the step about looking up info in Excel can be broken down like this:

  • Based on info found in Excel spreadsheet, determine settings for device
    • Name of device
    • SNMP settings
    • IP address/range of device
    • BGP ASN
    • Static routes
    • etc.

Which can be broken down even further:

  • Open file in Excel
  • Read contents of file in Excel
  • For each item/row/value/etc. in file, determine if it is needed
  • If needed, figure out what to do with it
    • Name of device
    • SNMP settings
    • IP address/range of device
    • BGP ASN
    • Static routes
    • etc.
  • Do something with each determined value, such as plug into text file template
  • Close file in Excel

From here, I start thinking how I can write up each individual step in Python, then write them out one piece at a time.

  • How do I open a file?
  • How do I read what’s in the file?
  • How do I separate lines and words in the file when importing?
  • How do I save this information efficiently?
  • How can I apply these settings into my template where required?
  • etc.

Rethink How You Think!

The world of network automation is amazing! However, it requires a bit of a shift in the way a traditional Network Engineer thinks about problems and how they solve them.

Network Engineer

For example, as a Network Engineer making a vlan change on an access switch port, depending on how complex the change is and the change control process, I would normally:

  1. Review the ticket (or submit one if needed)
  2. Write up my changes in the ticket
  3. Have them peer reviewed and approved
  4. Depending on the change, submit the change for approval with change board
  5. At the approved time, log into the switch
  6. Make the change
  7. Save the config
  8. Validate the change
  9. Update and close the ticket

Network Automation Engineer

As a Network Automation Engineer, I would see this process in automation a bit differently:

  1. Review the ticket (or submit one if needed).
  2. Update the vlan in a structured data file (e.g., YAML or JSON) in a Git repository.
  3. Submit the changes for peer review as a pull request.
  4. My continuous integration (CI) pipeline automatically tests and validates the requested change. It marks the pull request with a Success or Failure accordingly.
  5. A peer approves and merges the PR.
  6. My continuous delivery (CD) pipeline automatically deploys the change at a specific time (if necessary).
  7. My CD pipeline validates the change and updates the ticket with the results, then closes the ticket.
network_automation_engineer_workflow_example

This can be automated even further, but it gives a good idea of how even a process as simple as an interface vlan change would look to a Network Engineer vs a Network Automation Engineer.

Looking further out, think about what the above automation accomplished once the foundation of your automation is established.

  • You’ve eliminated the human element of accidental mistakes (mistyping the wrong vlan, configuring the wrong interface, etc.).
  • You and your peers can leverage the automation for additional changes without much more work.
  • You and your peers can deploy the vlan change to any number of devices with almost no additional time required.
  • Tickets are always updated, keeping the customer AND compliance happy!

The foundation used in the above example can be easily built on to add additional automation tasks to the network with significantly less time to set up.

Resources to Help Get Started

The world of network automation has grown at an immensely fast pace, and there are so many tools out there to use. Here are a few technologies to get started with learning. As you grow your automation, you’ll find many more tools out there for various tasks. However, these will help build your foundation for those other tools later on.

Open-Source Tools

When getting started, I recommend beginning to learn a few common tools, then expanding from there.

  1. Python – While everyone has their programming language of choice, there’s no disputing Python’s popularity and community support. If you’ve never written any code before, I highly recommend starting with Python. It’s easy to learn, beginner friendly, and there are lots of resources out there. Once you get familiar with Python, you can expand your skill set by learning additional programming languages.
  2. Ansible – Ansible is one of the most popular open-source automation tools out there. Begin by learning how Ansible works, and use it to start automating basic tasks in your network.
  3. Git – The de facto version control system out there, it’s entirely open-source and relatively easy to learn. Start by familiarizing yourself with how Git works, how to save (commit) changes, how to reverse (revert) changes when mistakes are made, etc. Note that Git is not the same as GitHub or GitLab. You do NOT need a GitHub/GitLab/etc. account to use Git.

Network to Code Resources

Training – Network to Code also offers various training courses for getting into network automation. If your company provides a training budget, these classes are excellent and highly recommended.

Blog – In addition to this article, we have many articles written over the past few years on a wide range of topics that can help you get going.

Slack – Network to Code has a very popular public Slack workspace with over 18,000 users at the time of this writing. Join us at https://slack.networktocode.com/, and feel free to participate in discussions and ask for advice. There are many great resources there from all over the world.

Intro to Automation Series

Part 1 – Rethink How You Think

Part 2 – New Tools For A New Network

Part 3 – Your New Best Friend Git


Conclusion

Thanks for reading, and happy automating!

-Matt



ntc img
ntc img

Contact Us to Learn More

Share details about yourself & someone from our team will reach out to you ASAP!