Network Automation Cookbook

Book description

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.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Network Automation Cookbook
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Code in Action
      4. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Get in touch
      1. Reviews
  6. Building Blocks of Ansible
    1. Technical requirements
    2. Installing Ansible
      1. Getting ready
      2. How to do it...
      3. How it works..
      4. How it works...
      5. See also...
    3. Building Ansible's inventory
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Using Ansible's variables
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Building Ansible's playbook
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Using Ansible's conditionals
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    7. Using Ansible's loops
      1. Getting ready
      2. How to do it...
      3. How it works..
      4. See also...
    8. Securing secrets with Ansible Vault
      1. How to do it...
      2. How it works..
      3. There's more...
    9. Using Jinja2 with Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    10. Using Ansible's filters
      1. How to do it...
      2. How it works...
    11. Using Ansible Tags
      1. How to do it...
      2. How it works...
      3. See also...
    12. Customizing Ansible's settings
      1. How to do it...
      2. How it works...
      3. See also...
    13. Using Ansible Roles
      1. How to do it...
      2. How it works...
      3. See also
  7. Managing Cisco IOS Devices Using Ansible
    1. Technical requirements
    2. Building an Ansible network inventory
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Connecting to Cisco IOS devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Configuring basic system information
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    5. Configuring interfaces on IOS devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    6. Configuring L2 VLANs on IOS devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Configuring trunk and access interfaces
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    8. Configuring interface IP addresses
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    9. Configuring OSPF on IOS devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Collecting IOS device facts
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    11. Validating network reachability on IOS devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    12. Retrieving operational data from IOS devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    13. Validating network states with pyATS and Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
  8. Automating Juniper Devices in the Service Providers Using Ansible
    1. Technical requirements
    2. Building the network inventory
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Connecting and authenticating to Juniper devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Enabling NETCONF on Junos OS devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Configuring generic system options on Juniper devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    6. Configuring interfaces on Juniper devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Configuring OSPF on Juniper devices
      1. How to do it...
      2. How it works...
    8. Configuring MPLS on Juniper devices
      1. How to do it...
      2. How it works...
    9. Configuring BGP on Juniper devices
      1. How to do it...
      2. How it works...
    10. Deploying configuration on Juniper devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    11. Configuring the L3VPN service on Juniper devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    12. Gathering Juniper device facts using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    13. Validating network reachability on Juniper devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    14. Retrieving operational data from Juniper devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    15. Validating the network state using PyEZ operational tables
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
  9. Building Data Center Networks with Arista and Ansible
    1. Technical requirements
    2. Building the Ansible network inventory
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Connecting to and authenticating Arista devices from Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Enabling eAPI on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    5. Configuring generic system options on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Configuring interfaces on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    7. Configuring the underlay BGP on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Configuring the overlay BGP EVPN on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Deploying the configuration on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    10. Configuring VLANs on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    11. Configuring VXLANs tunnels on Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    12. Gathering Arista device facts
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    13. Retrieving operational data from Arista devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
  10. Automating Application Delivery with F5 LTM and Ansible
    1. Technical requirements
    2. Building an Ansible network inventory
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Connecting and authenticating to BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Configuring generic system options on BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Configuring interfaces and trunks on BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    6. Configuring VLANs and self-IPs on BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    7. Configuring static routes on BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Deploying nodes on BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Configuring a load balancing pool on BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    10. Configuring virtual servers on BIG-IP devices
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    11. Retrieving operational data from BIG-IP nodes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
  11. Administering a Multi-Vendor Network with NAPALM and Ansible
    1. Technical requirements
    2. Installing NAPALM and integrating with Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Building an Ansible network inventory
      1. How to do it...
      2. How it works...
    4. Connecting and authenticating to network devices using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Building the device configuration
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Deploying configuration on network devices using NAPALM
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Collecting device facts with NAPALM
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    8. Validating network reachability using NAPALM
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Validating and auditing networks with NAPALM
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
  12. Deploying and Operating AWS Networking Resources with Ansible
    1. Technical requirements
    2. Installing the AWS SDK
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Building an Ansible inventory
      1. How to do it...
      2. How it works...
    4. Authenticating to your AWS account
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Deploying VPCs using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Deploying subnets using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    7. Deploying IGWs using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    8. Controlling routing within a VPC using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    9. Deploying network ACLs using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    10. Deployment validation using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    11. Decommissioning resources on AWS using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
  13. Deploying and Operating Azure Networking Resources with Ansible
    1. Technical requirements
    2. Installing the Azure SDK
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    3. Building an Ansible inventory
      1. How to do it...
      2. How it works...
    4. Authenticating to your Azure account
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    5. Creating a resource group
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    6. Creating virtual networks
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    7. Creating subnets
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    8. Building user-defined routes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    9. Deploying network security groups
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    10. Deployment validation using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    11. Decommissioning Azure resources using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
  14. Deploying and Operating GCP Networking Resources with Ansible
    1. Technical requirements
    2. Installing the GCP SDK
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    3. Building an Ansible inventory
      1. How to do it...
      2. How it works...
    4. Authenticating to your GCP account
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    5. Creating GCP VPC networks
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There is more...
      5. See also...
    6. Creating subnets
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    7. Deploying firewall rules in GCP
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    8. Deploying VMs in GCP
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    9. Adjusting routing within a VPC
      1. Getting ready
      2. How to do it...
      3. How it works..
      4. See also...
    10. Validating GCP deployment using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    11. Decommissioning GCP resources using Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
  15. Network Validation with Batfish and Ansible
    1. Technical requirements
    2. Installing Batfish
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    3. Integrating Batfish with Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    4. Generating the network configuration
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating a network snapshot for Batfish
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    6. Initializing the network snapshot with Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Collecting network facts from Batfish
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    8. Validating traffic forwarding with Batfish
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Validating ACLs with Batfish
      1. Getting ready
      2. How to do it...
      3. How it works...
  16. Building a Network Inventory with Ansible and NetBox
    1. Technical requirements
    2. Installing NetBox
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
      5. See also...
    3. Integrating NetBox with Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    4. Populating sites in NetBox
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    5. Populating devices in NetBox
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    6. Populating interfaces in NetBox
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    7. Populating IP addresses in NetBox
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    8. Populating IP prefixes in NetBox
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    9. Using NetBox as a dynamic inventory source for Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
      5. See also...
    10. Generating a configuration using NetBox
      1. Getting ready
      2. How to do it...
      3. How it works...
  17. Simplifying Automation with AWX and Ansible
    1. Technical requirements
    2. Installing AWX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    3. Managing users and teams on AWX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    4. Creating a network inventory on AWX
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Managing network credentials on AWX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    6. Creating projects on AWX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    7. Creating templates on AWX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    8. Creating workflow templates on AWX
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also...
    9. Running automation tasks using the AWX API
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
  18. Advanced Techniques and Best Practices for Ansible
    1. Technical requirements
    2. Installing Ansible in a virtual environment
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Validating YAML and Ansible playbooks
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also...
    4. Calculating the execution time for Ansible playbooks
      1. How to do it...
      2. How it works...
      3. See also...
    5. Validating user input using Ansible
      1. How to do it...
      2. How it works...
    6. Running Ansible in check mode
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also...
    7. Controlling parallelism and rolling updates in Ansible
      1. How to do it...
      2. How it works...
      3. See also...
    8. Configuring fact caching in Ansible
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also...
    9. Creating custom Python filters for Ansible
      1. How to do it...
      2. How it works...
      3. There's more...
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Network Automation Cookbook
  • Author(s): Karim Okasha
  • Release date: April 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781789956481