Network Automation with Python and Ansible

Course Overview

This class is designed as an introduction to Software Defined Networking, Python programming, and Ansible. The first day is an introduction to Software Defined Networking, understanding Python’s potential places within your next-generation network, lecture concludes with learning to install Python and work within the Python interactive environment. Days two through four are heavy on learning to write Python, highly effective functions, and the basics of object-oriented programming. Day four concludes with an introduction to Ansible, which continues on day five. The course is 50% lecture and 50% hands-on labs. Students need no prior knowledge of any of these topics, although some prior exposure to networking or programming is helpful.

python course cover image

Course Outline: Network Automation with Python and Ansible Part 1

5 Days with Hands-on Labs and Full Course Video

Suggested follow on class:

Network Automation with Python and Ansible Part 2


This course is designed for networking professionals seeking to develop skills in network automation. Python serves as a general-purpose tool that can do just about anything, at the cost of writing code, which is the focus of this course. This course also introduces the basics of Software Defined Networking (SDN), and Ansible.


Ansible specifically focuses on automation of systems and networking deployment. Using Ansible to handle the bulk of network automation usually makes sense, while using Python to fill in the cracks. Ansible cannot be taught in a single day, therefore, the suggested follow-to this course, to focus on Ansible training, is Network Automation with Python and Ansible: Part 2


Day 1 – Establish just enough knowledge of SDN and Network Function Virtualization to clearly understand Python’s value in networking. Everything demonstrated in this section will be based on Python and students will deploy systems, learning how it all fits together in a test environment.


  1. Python for Software Defined Networking
    1. Mininet environment for network testing
    2. Describe a Mininet topology with Python
    3. Install Python apps to a Ryu OpenFlow controller
    4. Deploy a test SDN controller with pre-written code
  2. Learn to install Python 2 and 3
    1. Review of key differences


Day 2Learn Python essentials using networking based examples whenever possible.


  1. Python Fundamentals
    1. Conditionals
    2. Loops
    3. Functions
    4. Data Types and Variables
    5. Scopes and Namespaces
    6. Classes and Objects
    7. Methods, decorators, etc…


Day 3A continuation of Day 2 with more complex programming examples and labs. For proof of concept, students will use Python to examine Wireshark (*.pcap) captures.


  1. Exception Handling
  2. Regular Expressions
  3. Serialization of data
    1. Output to Files
    2. YAML
    3. JSON
    4. XML


Day 4Exploring more code and key support systems required to work within the Python environment. This day also begins an introduction of Ansible.


  1. Python Environments and Projects
    1. Modules and Packages
    2. Pip
    3. Virtualenv
  2. Python and APIs
    1. RESTful interfaces
    2. Python and REST
    3. etcd
  3. Introduction to Ansible
    1. Purpose / Overview
    2. Exploring Ansible Modules with Python
    3. Inventory / Hosts
    4. YAML review


Day 5 – Ansible is growing in popularity for good reason, it is both easy to understand, far simpler than Python, and extremely powerful.  While Python can be used to do just about anything, Ansible is used to bring structure and consistency to system deployments, implementations, and changes.


  1. Ansible
    1. Ad hoc commands
    2. Playbook
    3. Ansible Config Templating
    4. Ansible Networking Modules
    5. Ansible and NAPALM (optional)
    6. Labs will use Ansible to Configure an OpenStack Cloud
    7. Configuration Templating for Cloud Deployments
  2. Deploying a web server with Ansible



Labs - Labs are designed so no lab needs to be completed before moving onto the next. Students can work at their own pace, and skip labs if they already understand the material.


  1. Student Setup for Introduction to Network Automation with Python and Ansible Labs
  2. Using vim
  3. Linux Networking Basics
  4. Introduction to Mininet
  5. SDN Topology Analysis using Python
  6. Introducing the Controllers (Ryu)
  7. Using Wireshark to Capture OpenFlow v1.3 Traffic
  8. Build a Ryu GUI Topology Viewer with Python
  9. Using & Installing Python
  10. The Shebang Line
  11. Using Print() to understand Input / Output
  12. Using while, if, elif, else
  13. Troubleshooting while, if, elif, else
  14. Program a CIDR to Subnet Mask Calculator
  15. Understanding Python Lists
  16. Using for, range, format, if, elif, else
  17. Migrating 2.x programs to 3.x program
  18. Binary String to IP Address Conversion
  19. for loops and range()
  20. Defining Functions
  21. Working with from and import
  22. Writing your own script with if, elif, and else statements
  23. Using Python to Create an OpenStack Permissions File
  24. Writing a Python Application to Parse Keystone Log File for Failed Auth Attempts
  25. pip - Python Package Management System
  26. Using Python to get at your Network Interfaces
  27. JSON to YAML Converter, Wireshark, and SIP
  28. RESTful Interfaces with Python and etcd
  29. Construct a SimpleHTTPServer and HTTP Client
  30. Use RegEx to Check Your External IP Address
  31. Use RegEx to Search Text
  32. Writing a Python Application to Parse SIP Message
  33. Using Python to Search Network Config Files - ciscoconfparse
  34. Ansible 101
  35. Even more Ansible
  36. Building Web Servers with Ansible

Alta3 Research

Network Automation with Python and Ansible

Duration: 5 Days (instructor-led)

Delivery: Onsite or Instructor-led Virtual

Onsite: Contact us for group quotes

Buy Self-Paced

Buy Virtual