Intro to Automation Part 1 – Rethink How You Think!

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!

Author