Network Automation Cookbook
Proven and actionable recipes to automate and manage network devices using Ansible
Karim Okasha
- 482 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Network Automation Cookbook
Proven and actionable recipes to automate and manage network devices using Ansible
Karim Okasha
About This Book
Take your network automation skills to the next level with practical recipes on managing network devices from a variety of vendors like Cisco, Juniper, and Arista
Key Features
- Use Ansible to automate network infrastructure with the help of step-by-step instructions
- Implement network automation best practices to save cost, avoid critical errors, and reduce downtime
- Deliver a robust automation framework by integrating Ansible with NAPALM, NetBox, and Batfish
Book Description
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.
What you will learn
- Understand the various components of Ansible
- Automate network resources in AWS, GCP, and Azure cloud solutions
- Use IaC concepts to design and build network solutions
- Automate network devices such as Cisco, Juniper, Arista, and F5
- Use NetBox to build network inventory and integrate it with Ansible
- Validate networks using Ansible and Batfish
Who this book is for
This Ansible network automation book is for network and DevOps engineers interested in automating complex network tasks. Prior understanding of networking and basic Linux knowledge is required.
Frequently asked questions
Information
Automating Juniper Devices in the Service Providers Using Ansible
Device | Role | Vendor | Management (MGMT) Port | MGMT IP |
mxp01 | P Router | Juniper vMX 14.1 | fxp0 | 172.20.1.2 |
mxp02 | P Router | Juniper vMX 14.1 | fxp0 | 172.20.1.3 |
mxpe01 | PE Router | Juniper vMX 14.1 | fxp0 | 172.20.1.4 |
mxpe02 | PE Router | Juniper vMX 17.1 | fxp0 | 172.20.1.5 |
- Building the network inventory
- Connecting and authenticating to Juniper devices
- Enabling the Network Configuration Protocol (NETCONF) on Junos OS devices
- Configuring generic system options on Juniper devices
- Configuring interfaces on Juniper devices
- Configuring Open Shortest Path First (OSPF) on Juniper devices
- Configuring Multiprotocol Label Switching (MPLS) on Juniper devices
- Configuring the Border Gate Protocol (BGP) on Juniper devices
- Deploying configuration on Juniper devices
- Configuring the Layer 3 virtual private network (L3VPN) service on Juniper devices
- Gathering Juniper device facts using Ansible
- Validating network reachability on Juniper devices
- Retrieving operational data from Juniper devices
- Validating the network state using PyEZ operational tables
Technical requirements
- Ansible machine running CentOS 7
- Ansible 2.9
- Juniper Virtual MX (vMX) running Junos OS 14.1R8 and Junos OS 17.1R1 release
https://bit.ly/3ajF4Mp
Building the network inventory
Getting ready
How to do it...
- Inside the new folder, ch3_junos, we create a hosts file with the following content:
$ cat hosts
[pe]
mxpe01 Ansible_host=172.20.1.3
mxpe02 Ansible_host=172.20.1.4
[p]
mxp01 Ansible_host=172.20.1.2
mxp02 Ansible_host=172.20.1.6
[junos]
mxpe[01:02]
mxp[01:02]
[core:children]
pe
p
- Create an Ansible.cfg file, as shown in the following code:
$ cat Ansible.cfg
[defaults]
inventory=hosts
retry_files_enabled=False
gathering=explicit
host_key_checking=False
How it works...
- We create the PE group, which references all the MPLS Provider Edge (PE) nodes in our topology.
- We create the P group, which references all the MPLS Provider (P) nodes in our topology.
- We create the junos group, which references all the devices running Junos OS as the OS.
- We create the core parent group, which references both the PE and P groups.
$ Ansible-inventory --list
"all": {
"children": [
"core",
"junos",
"ungrouped"
]
},
"core": {
"children": [
"p",
"pe"
]
},
"junos": {
"hosts": [
"mxp01",
"mxp02",
"mxpe01",
"mxpe02"
]
},
"p": {
"hosts": [
"mxp01",
"mxp02"
]
},
"pe": {
"hosts": [
"mxpe01",
"mxpe02"
]
}