Network Automation with Python and Ansible (Ansible 201)

Continue your studies of Ansible, with a focus on automating common elements within the network. In addition to Ansible, students will study enough Python to understand Ansible’s plugin architecture. Lessons and labs focus on using both Python and Ansible to interact with and configure your network devices. At the conclusion of this course, you will return to work empowered with the skills necessary to automate network management. This class is a combination of live demonstrations and hands‐on labs with virtual network devices and endpoints as targets for your configuration.

Students looking for server applications should see: Ansible 202 ‐ Server Automation with Python and Ansible

Course Information

Price: $2,395.00
Duration: 5 days
Learning Credits:
Course Delivery Options

Check out our full list of training locations and learning formats. Please note that the location you choose may be an Established HD-ILT location with a virtual live instructor.

Train face-to-face with the live instructor.

Access to on-demand training content anytime, anywhere.

Attend the live class from the comfort of your home or office.

Interact with a live, remote instructor from a specialized, HD-equipped classroom near you. An SLI sales rep will confirm location availability prior to registration confirmation.

All Sunset Learning dates are guaranteed to run!





Target Audience:

  • Network Administrators
  • Ansible Developers
  • Python Developers
  • Administrators interested in Automation
  • Individuals interested in DevOps, specifically for networking


Course Objectives:

  • Version controlling code with Git
  • Open SSH sessions and pass commands to remote servers
  • Remotely open CLI to network devices
  • Move files via SFTP
  • Overview of Ansible modules
  • Ansible collections for network automation
  • Custom Ansible modules with Python
  • Best practices for automating the management and configuration of network devices


Course Outline:

Ansible and Python Review

  • Ansible definition
  • Exploring modules
  • Overview of Python and Ansible
  • Python whitespace rules & best practices
  • Conditional expressions
  • Relational and Boolean operators
  • Lists, Tuples, Dictionaries
  • Indexing and slicing
  • Built‐in functions
  • Writing custom functions
  • Getting at methods
  • Iterating with Loops (for and while)
  • Working with files
  • Software Control Management (SCM) (Git, Github, GitLab, Bitbucket, Cloudshare, etc.)
  • Getting at RESTful interfaces with Python
  • Working with JSON
  • Python, Ansible and Paramiko
  • Using Paramiko to SSH with keys and passwords

Network Automation

  • RESTful API review
  • API keys
  • Paramiko Review
  • Using Paramiko to SFTP with keys and passwords
  • Introduction to Netmiko (automating routers and switches)
  • Using Netmiko to send commands to/from network devices
  • Working with YAML
  • Converting JSON to YAML with Python

Critical Ansible Catchup & Review

  • Ansible keywords
  • YAML and JSON for data exchange
  • Ansible and YAML
  • Ansible Playbook components
  • Tying together Python and Ansible – Using Python within Ansible
  • Ansible Network Modules
  • What is new in Ansible (most current updates/release notes)
  • Network Agnostic modules
  • Writing network playbooks
  • Reviewing the construction of network playbooks
  • Writing Ansible playbooks that respond to network failures

Blending Python and Ansible Skillsets

  • Review how to use Python within Ansible
  • Calling Python scripts with Ansible
  • Jinja2 Templating Engine for Python (and Ansible)
  • Using Templates in Ansible playbooks
  • Jinja2 filters, looping, and other useful tricks for automating with Ansible
  • Playbook tagging for selective runs
  • When to use Python and when to use Ansible
  • Writing a custom collection
  • Writing custom roles
  • Extending Ansible to support Palo Alto (Optional ‐ Case Study)
  • Extending Ansible to support Juniper vendor modules (Optional ‐ Case Study)
  • Extending Ansible to support NAPALM (Optional ‐ Case Study)

Customizing Ansible with Python

  • Review – Running Scripts with Ansible
  • Prompting for Ansible user input
  • Ansible Galaxy & Getting at Roles
  • Writing a custom Ansible Module with Python
  • Ansible ’Engine’ vs Ansible ’Tower’ – marketing hype, capabilities, costs, etc.
  • Case Study: Automate your Enterprise Network
  • Writing your own Ansible modules in Python
  • Overview ‐ NETCONF / YANG and what they mean for Python and Ansible
  • Molecule – Testing your roles

Hands-On Labs

  • Welcome to Alta3 Research Labs
  • Using vim
  • Introduction to VScode
  • Tmux Basics
  • SCM with GitLab
  • Network Automation with Python and Ansible – Certification Project
  • Lecture – Introducing Python
  • Getting dir(obj) help() and pydoc
  • Lecture – Data Types
  • Lists
  • Dictionaries
  • Lecture – Ansible Playbook Components
  • Running a Playbook
  • Debug Module
  • Debug, Loops, and YAML Lists
  • Lecture – REST APIs and JSON
  • Open APIs with Python and Ansible
  • Ansible Keywords register and when
  • API Tokens with Python and Ansible
  • Lecture – SSH Operations
  • Paramiko – SSH with RSA Keys
  • Paramiko – SFTP with UN and PW
  • Lecture – Ansible Playbooks for SSH operations
  • Ansible ’raw’ Module
  • Jinja Filters
  • Ansible, Python Methods, and Jinja Filters
  • Lecture – Netmiko
  • Running Netmiko
  • Network Playbooks, Set Fact, and Fail
  • Ansible Get Switch Config and Archive
  • Ansible Agnostic Network Modules
  • Ansible and TextFSM
  • Network Playbook Error Handling
  • Network Playbook Precheck
  • Network Playbooks with Roles and Rollbacks
  • Ansible Collections
  • Lecture – Ansible Workflow
  • ansible-runner
  • Securing Playbooks with Vault
  • Playbook Prompts
  • Ansible and Jinja Templates
  • Ansible Tags and RESTful APIs
  • Running a script with Ansible
  • Dynamic Inventories with Python
  • Writing an Ansible Module with Python
  • When to Use Python or Ansible
  • Molecule
  • Ansible for Palo Alto PanOS and Panorama
  • Glossary