Practical Network Automation
eBook - ePub

Practical Network Automation

A beginner's guide to automating and optimizing networks using Python, Ansible, and more, 2nd Edition

Abhishek Ratan

Buch teilen
  1. 226 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Practical Network Automation

A beginner's guide to automating and optimizing networks using Python, Ansible, and more, 2nd Edition

Abhishek Ratan

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Leverage the power of Python, Ansible and other network automation tools to make your network robust and more secure

Key Features

  • Get introduced to the concept of network automation with relevant use cases
  • Apply Continuous Integration and DevOps to improve your network performance
  • Implement effective automation using tools such as Python, Ansible, and more

Book Description

Network automation is the use of IT controls to supervise and carry out everyday network management functions. It plays a key role in network virtualization technologies and network functions.

The book starts by providing an introduction to network automation, and its applications, which include integrating DevOps tools to automate the network efficiently. It then guides you through different network automation tasks and covers various data digging and performing tasks such as ensuring golden state configurations using templates, interface parsing. This book also focuses on Intelligent Operations using Artificial Intelligence and troubleshooting using chatbots and voice commands. The book then moves on to the use of Python and the management of SSH keys for machine-to-machine (M2M) communication, all followed by practical use cases. The book also covers the importance of Ansible for network automation, including best practices in automation; ways to test automated networks using tools such as Puppet, SaltStack, and Chef; and other important techniques.

Through practical use-cases and examples, this book will acquaint you with the various aspects of network automation. It will give you the solid foundation you need to automate your own network without any hassle.

What you will learn

  • Get started with the fundamental concepts of network automation
  • Perform intelligent data mining and remediation based on triggers
  • Understand how AIOps works in operations
  • Trigger automation through data factors
  • Improve your data center's robustness and security through data digging
  • Get access infrastructure through API Framework for chatbot and voice interactive troubleshootings
  • Set up communication with SSH-based devices using Netmiko

Who this book is for

If you are a network engineer or a DevOps professional looking for an extensive guide to help you automate and manage your network efficiently, then this book is for you. No prior experience with network automation is required to get started, however you will need some exposure to Python programming to get the most out of this book.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Practical Network Automation als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Practical Network Automation von Abhishek Ratan im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Computer Networking. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2018
ISBN
9781789950403

Continual Integration

Now that you're comfortable interacting with devices through Python and understand the basics of Artificial Intelligence and Robotic Process Automation (RPA), let's look at some working, detailed use cases to help us to understand these concepts in detail. We'll leverage the API framework that was deployed in Chapter 5, Web Framework for Automation Triggers, to create solutions that can perform network operations in scalable environments. Additionally, we'll look at some use cases on how to leverage next-generation technologies, such as chatbot and voice simulations, to assist in network operations.
The following topics will be covered in this chapter:
  • Remediation using intelligent triggers
  • Standardizing configurations on scale
  • Chatbot interactions
  • Additional use cases

Technical requirements

Here are the technical requirements for this chapter:
  • Python
  • Slack account (for chatbot collaboration)
  • Splunk
  • API and JavaScript basics
  • GitHub URL at https://github.com/PacktPublishing/Practical-Network-Automation-Second-Edition

Remediation using intelligent triggers

In a scalable or high-availability environment, an engineer needs to ensure there is a near zero possibility of human error. For a service based organization, even a small downtime can cost millions of dollars in revenue or even deterioration of a brand's image. There are high chances of outages while performing certain tasks, either due to manual executions or to certain hardware failures.
A solution to this typical real-life problem is to quickly identify the problem and perform self-remediation. Let's convert this problem into a particular use case.
In this use case, we need to ensure that all of the routers in our environment always have the Loopback45 interface up and running. This could be a critical interface, where accidentally shutting off this interface might stop traffic flow to a router or a router may stop responding to sending Syslogs or traps to a particular destination. This can also adversely affect the routing in the environment if this interface is tightly coupled with the routing traffic patterns in the organization.
We would be using Python to collect the stats of each of the interfaces on each router and send it to a data collector and analysis tool (Splunk). For a recurring check on the available data, we would use intelligent queries and auto-trigger remediation if we see any Loopback45 interface being down due to any reason. The auto-remediation will enable the interface to ensure we have near-zero downtime.
As a prerequisite, we need to perform the following steps.

Step 1 – ensuring Splunk is configured to receive the data

In this step, we configure Splunk to monitor a specific folder in the local machine for any new data. Data would typically be in a comma-separated format generated from a Python script written in this particular folder.
Listed are the steps to configure Splunk for monitoring the folder:
  1. Select Data inputs from the Settings drop-down menu:
  1. Configure data input to monitor a particular folder (C:\splunklogs in our example):
  1. Ensure the data selection type is Automatic (Splunk has the built-in intelligence to parse the data in a database format based upon certain specific types of input, which is a command-separated file in our case). Also, the index or the main header can be modified for this new data in Splunk:

Step 2 – validating the data (sample data)

Once we are done with the configuration, we can provide some sample data in a text file to determine whether the data is available in Splunk; this can be any data in a comma-separated format but residing in the folder that is being monitored:
  • On the main search page, we see Data Summary showing some events. A click on it will show the details, and sources will show that from which file, how many records (or events in Splunk) are being learned:
  • Here is a sample set of data in Splunk's auto-discovered format (a query will be performed on this data in Splunk using Search Processing Language (SPL) that is specific to Splunk, to identify potential problems):

Step 3 – writing script

This is where we write a script to ensure we capture the specific status of every interface on a given set of routers and write it back to a file. This would also be ingested by Splunk.
In our case, we would fetch the stats from all of the routers (192.168.20.1-192.168.20.4) every five minutes and update the file in C:\splunklogs. In other words, Splunk would have the refreshed the data that we can use for validation every five minutes. Another benefit of this approach is for historic data collection. Using this approach, we can always determine the Root Cause Analysis (RCA) or even identify any flaps or an interface utilization over a period of time, we can leverage Splunk for data analysis.
Let's split the code into sections to understand each part:
  1. Initialize the environment by importing libraries required for the execution of the script:
# concurrent threads executed at a time - 25
# each thread connect to the router . fetch show interfaces output
# invoke fetch_interface_summary and get the interface names in a list format
# network device ips are input in allips variable
# this takes around 30 secs to execute
# data is written on c:\splunklogs\network_device_stats_details.txt

import re
import netmiko
import time
import datetime
import math
from threading import Thread
import logging
import threading
from random import randrange
import itertools
import itertools
import sys
import base64
  1. Parse the given raw configuration, split the configuration into separate groupings (for example, a s...

Inhaltsverzeichnis