Book Image

Network Automation Cookbook

By : Karim Okasha
Book Image

Network Automation Cookbook

By: Karim Okasha

Overview of this book

Network Automation Cookbook is designed to help system administrators, network engineers, and infrastructure automation engineers to centrally manage switches, routers, and other devices in their organization's network. This book will help you gain hands-on experience in automating enterprise networks and take you through core network automation techniques using the latest version of Ansible and Python. With the help of practical recipes, you'll learn how to build a network infrastructure that can be easily managed and updated as it scales through a large number of devices. You'll also cover topics related to security automation and get to grips with essential techniques to maintain network robustness. As you make progress, the book will show you how to automate networks on public cloud providers such as AWS, Google Cloud Platform, and Azure. Finally, you will get up and running with Ansible 2.9 and discover troubleshooting techniques and network automation best practices. By the end of this book, you'll be able to use Ansible to automate modern network devices and integrate third-party tools such as NAPALM, NetBox, and Batfish easily to build robust network automation solutions.
Table of Contents (15 chapters)

Managing Cisco IOS Devices Using Ansible

In this chapter, we will outline how to automate Cisco IOS-based devices using Ansible. We will explore the different modules available in Ansible to automate configuration and collect network information from Cisco IOS devices. This chapter will be based on the following sample network diagram, and we will walk through how we can implement this network design using Ansible:

The following table outlines the management IP addresses on the Cisco nodes, which Ansible will use to connect to the devices:

Device

Role

Vendor

MGMT Port

MGMT IP

access01

Access switch

Cisco IOS 15.1

Ethernet0/0

172.20.1.18

access02

Access switch

Cisco IOS 15.1

Ethernet0/0

172.20.1.19

core01

Core switch

Cisco IOS 15.1

Ethernet0/0

172.20.1.20

core02

Core switch

Cisco IOS 15.1

Ethernet0/0

172.20.1.21

wan01

WAN router

Cisco IOS–XE 16.6.1

GigabitEthernet1

172.20.1.22

wan02

WAN router

Cisco IOS–XE 16.6.1

GigabitEthernet1

172.20.1.23

The main recipes covered in this chapter are as follows:

  • Building an Ansible network inventory
  • Connecting to Cisco IOS devices
  • Configuring basic system information
  • Configuring interfaces on IOS devices
  • Configuring L2 VLANS on IOS devices
  • Configuring trunk and access interfaces
  • Configuring interface IP addresses
  • Configuring OSPF on IOS devices
  • Collecting IOS device facts
  • Validating network reachability on IOS devices
  • Retrieving operational data from IOS devices
  • Validating network states with pyATS and Ansible