SlideShare a Scribd company logo
2
Most read
6
Most read
11
Most read
Network Automation
with Ansible
Anas Tarsha
Bay Area Network Operators Group (BANOG)
Anas Tarsha
• Network/Cloud Architect, CCIE
• Areas of focus: data center, cloud, and network
automation
• BANOG founder & organizer
• Follow me on Twitter @AnasTarsha
• Blog: AnasTarsha.com
Agenda
• About Ansible
• Use Cases
• How Ansible Works?
• Install Ansible
• Run Ansible
• Live Demos
What Is Ansible?
• IT Automation and configuration management tool
• Emerged in 2012 to initially deploy Linux
applications; support for networking modules was
added in release 2.x
• Open source; code available on Github
• Often compared to Chef, Puppet, and SaltStack
Why Ansible?
• Agentless and extensible
• You don’t need to be a programmer to get started
• Saves time (maybe)
• Speed, but do you care?
• Predictable outcome; reduces human error
Ansible Use Cases
• Generating device configurations
• Saving and collecting running device
configurations
• Pushing out configurations to the network
• Upgrading devices
How Does Ansible Work?
Ansible
Control Host
Inventory File
sw1
r1
fw1
Network
Device
Playbook
play 1
hosts: all
- task 1
- task 2
SSH
Netconf
eAPI
NX-API
Python code
executed here
Install Ansible
• Easy to install using utilities like pip, yum, apt
• Runs only on Linux-based machines
• Official Install Guide:
http://docs.ansible.com/ansible/intro_installation.html
Ansible Playbooks
• Describe a policy you want to enforce or tasks you want o execute on your
devices
• Expressed in YAML
• “We use YAML because it is easier for humans to read and write than other
common data formats like XML or JSON” — ansible.com
• Each playbook can have a play or more and each play can have one task or more
• Tasks are executed sequentially
- name: example playbook
hosts: junos
tasks:
- tasks you want to automate
Ansible Modules
• They do the actual work in playbook; take arguments
• Mostly written in Python and return JSON data
• Core modules come installed with Ansible; non-core modules can be installed manually
• Run in playbook, but can run single module from command line
• Use ansible-doc module_name command for help
• Ansible Networking Modules http://docs.ansible.com/ansible/list_of_network_modules.html
• Example:
- name: collect default set of facts and configuration in XML & JSON format
junos_facts:
config: yes
config_format: xml
Run Ansible
1. Create an inventory file and define your devices:
[ios]
router1 ansible_host=192.168.0.201
switch1 ansible_host=192.168.0.203
[junos]
router2 ansible_host=192.168.0.130
2. Create a playbook:
- name: ping Google’s DNS from the device
hosts: ios
tasks:
- ios_command:
commands: ping 8.8.8.8
….. <omitted>
3. Run the playbook: ansible-playbook myPlaybook.yml
Sample inventory file:
2 groups, total of 3
network devices defined
Sample playbook:
Include plays and tasks
to execute
Live Demos
• Vagrant running on macOS Sierra to provision the
host VM
• Ansible 2.2 running on Ubuntu 14.4 LTS
• Cisco CSR 1000v and Juniper vSRX
• SSH is enabled on CSR; Netconf is enabled on
vSRX
Demo 1: Ping Module
# ansible all -m ping
vsrx | SUCCESS => {
"changed": false,
"ping": "pong"
}
csr | SUCCESS => {
"changed": false,
"ping": "pong"
}
Demo 2: show_arp.yml
---
- hosts: ios
tasks:
- ios_command:
commands: show arp
host: csr
username: cisco
password: cisco
transport: cli
ios_command module
with required parameters
Demo 3:
show_arp_result.yml
---
- hosts: ios
tasks:
- ios_command:
commands: show arp
host: csr
username: cisco
password: cisco
transport: cli
register: result
- debug: var=result
Demo 4:
change_hostname.yml
---
- name: Change hostname on a Cisco IOS router
hosts: ios
tasks:
- ios_config:
commands:
- hostname CSR1
provider: "{{ cli }}"
ios_config module with
required arguments
Demo 5:
show_arp_result_junos.yml
---
- hosts: junos
tasks:
- junos_command:
commands: show arp
provider: "{{ netconf }}"
register: result
- debug: var=result
junos module with
required arguments
Additional Resources
• Network Automation with Ansible, report by Jason Edelman (free,
login required)
https://www.oreilly.com/learning/network-automation-with-ansible
• Up and Running with Ansible (free eBook)
https://ipfs.io/ipfs/
QmTJaLdhUW6jTdXGFoqv7wZe5KguBi5F2u4ihBdrUMVPhw
• Ivan Pepeljak’s Blog http://ipspace.net
• Learn Linux: video training from safaribooksonline.com or
lynda.com or pluralsight.com
Thank You
Stay in touch
Questions?

More Related Content

PDF
Ansible
PDF
Ansible
ODP
ansible why ?
PDF
Ansible - Introduction
PPTX
Introduction to Ansible
PPTX
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
ODP
Introduction to Ansible
PDF
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
Ansible
Ansible
ansible why ?
Ansible - Introduction
Introduction to Ansible
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Introduction to Ansible
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...

What's hot (20)

PDF
Ansible - Hands on Training
PPTX
Ansible presentation
PDF
DevOps with Ansible
PDF
IT Automation with Ansible
PDF
Ansible, best practices
PPTX
Best practices for ansible
PPT
Ansible presentation
PDF
Ansible
PDF
Ansible
PDF
Automation with ansible
PPTX
Network automation (NetDevOps) with Ansible
PDF
RHEL7/CentOS7 NetworkManager徹底入門
PDF
Getting started with Ansible
PPTX
Introduction to ansible
PDF
Ansible-cours .pdf
PDF
SSH力をつけよう
PDF
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
PPTX
[OpenStack 하반기 스터디] Interoperability with ML2: LinuxBridge, OVS and SDN
PDF
Ansible
Ansible - Hands on Training
Ansible presentation
DevOps with Ansible
IT Automation with Ansible
Ansible, best practices
Best practices for ansible
Ansible presentation
Ansible
Ansible
Automation with ansible
Network automation (NetDevOps) with Ansible
RHEL7/CentOS7 NetworkManager徹底入門
Getting started with Ansible
Introduction to ansible
Ansible-cours .pdf
SSH力をつけよう
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[OpenStack 하반기 스터디] Interoperability with ML2: LinuxBridge, OVS and SDN
Ansible
Ad

Viewers also liked (20)

PPTX
Automated Deployments with Ansible
PPTX
Juniper Network Automation for KrDAG
PDF
Network Automation: Ansible 101
PDF
Network Automation: Ansible 102
PDF
Ansible Case Studies
PPTX
Routing Management with MIRA and enhancement (IMECS2010)
PDF
Better Network Management Through Network Programmability
PPTX
Ansible with-junos
PPTX
Extending ansible
PDF
Network Automation (Bay Area Juniper Networks Meetup)
ODP
Ansible & Vagrant
PDF
Flexible, simple deployments with OpenStack-Ansible
PDF
Managing sensitive data with Ansible vault
PPTX
Python (Jinja2) Templates for Network Automation
PPTX
Ansible for Enterprise
PPTX
[세미나] Vagrant 이지원
PDF
OpenStack-Ansible Security
PDF
netconf, restconf, grpc_basic
PDF
XE 모듈 개발 - 걸음마부터 날기까지 - 달리기
PDF
Ansible과 CloudFormation을 이용한 배포 자동화
Automated Deployments with Ansible
Juniper Network Automation for KrDAG
Network Automation: Ansible 101
Network Automation: Ansible 102
Ansible Case Studies
Routing Management with MIRA and enhancement (IMECS2010)
Better Network Management Through Network Programmability
Ansible with-junos
Extending ansible
Network Automation (Bay Area Juniper Networks Meetup)
Ansible & Vagrant
Flexible, simple deployments with OpenStack-Ansible
Managing sensitive data with Ansible vault
Python (Jinja2) Templates for Network Automation
Ansible for Enterprise
[세미나] Vagrant 이지원
OpenStack-Ansible Security
netconf, restconf, grpc_basic
XE 모듈 개발 - 걸음마부터 날기까지 - 달리기
Ansible과 CloudFormation을 이용한 배포 자동화
Ad

Similar to Network Automation with Ansible (20)

PDF
06 network automationwithansible
PDF
Ansible_Basics_ppt.pdf
PPTX
Ansible as configuration management tool for devops
PDF
ansible_rhel.pdf
PDF
Ansible nice-pdf-copy-for-pres
PDF
Network Automation (NetDevOps) with Ansible
PPTX
Intro to-ansible-sep7-meetup
PDF
Introduction to Ansible in RHEL- RHCE.pdf
PDF
UNM Tech Day 2018 - Ansible: 
Server and Network Device Automation
PPTX
Go Faster with Ansible (AWS meetup)
PDF
Writing Ansible Modules (DENOG11)
PPTX
Ansible: What, Why & How
PDF
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
PDF
El Paso Tech Day Sept 19 2018 - Net Automation with Ansible
PDF
Top 50 Ansible Interview Questions And Answers in 2023.pdf
PDF
Ansible Automation to Rule Them All
PPTX
Network Automation using Python and Ansible.pptx
PPTX
Ansible
PDF
Ansible & Salt - Vincent Boon
06 network automationwithansible
Ansible_Basics_ppt.pdf
Ansible as configuration management tool for devops
ansible_rhel.pdf
Ansible nice-pdf-copy-for-pres
Network Automation (NetDevOps) with Ansible
Intro to-ansible-sep7-meetup
Introduction to Ansible in RHEL- RHCE.pdf
UNM Tech Day 2018 - Ansible: 
Server and Network Device Automation
Go Faster with Ansible (AWS meetup)
Writing Ansible Modules (DENOG11)
Ansible: What, Why & How
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
El Paso Tech Day Sept 19 2018 - Net Automation with Ansible
Top 50 Ansible Interview Questions And Answers in 2023.pdf
Ansible Automation to Rule Them All
Network Automation using Python and Ansible.pptx
Ansible
Ansible & Salt - Vincent Boon

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Monthly Chronicles - July 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Empathic Computing: Creating Shared Understanding
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
MYSQL Presentation for SQL database connectivity
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Network Security Unit 5.pdf for BCA BBA.
The AUB Centre for AI in Media Proposal.docx
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Monthly Chronicles - July 2025

Network Automation with Ansible

  • 1. Network Automation with Ansible Anas Tarsha Bay Area Network Operators Group (BANOG)
  • 2. Anas Tarsha • Network/Cloud Architect, CCIE • Areas of focus: data center, cloud, and network automation • BANOG founder & organizer • Follow me on Twitter @AnasTarsha • Blog: AnasTarsha.com
  • 3. Agenda • About Ansible • Use Cases • How Ansible Works? • Install Ansible • Run Ansible • Live Demos
  • 4. What Is Ansible? • IT Automation and configuration management tool • Emerged in 2012 to initially deploy Linux applications; support for networking modules was added in release 2.x • Open source; code available on Github • Often compared to Chef, Puppet, and SaltStack
  • 5. Why Ansible? • Agentless and extensible • You don’t need to be a programmer to get started • Saves time (maybe) • Speed, but do you care? • Predictable outcome; reduces human error
  • 6. Ansible Use Cases • Generating device configurations • Saving and collecting running device configurations • Pushing out configurations to the network • Upgrading devices
  • 7. How Does Ansible Work? Ansible Control Host Inventory File sw1 r1 fw1 Network Device Playbook play 1 hosts: all - task 1 - task 2 SSH Netconf eAPI NX-API Python code executed here
  • 8. Install Ansible • Easy to install using utilities like pip, yum, apt • Runs only on Linux-based machines • Official Install Guide: http://docs.ansible.com/ansible/intro_installation.html
  • 9. Ansible Playbooks • Describe a policy you want to enforce or tasks you want o execute on your devices • Expressed in YAML • “We use YAML because it is easier for humans to read and write than other common data formats like XML or JSON” — ansible.com • Each playbook can have a play or more and each play can have one task or more • Tasks are executed sequentially - name: example playbook hosts: junos tasks: - tasks you want to automate
  • 10. Ansible Modules • They do the actual work in playbook; take arguments • Mostly written in Python and return JSON data • Core modules come installed with Ansible; non-core modules can be installed manually • Run in playbook, but can run single module from command line • Use ansible-doc module_name command for help • Ansible Networking Modules http://docs.ansible.com/ansible/list_of_network_modules.html • Example: - name: collect default set of facts and configuration in XML & JSON format junos_facts: config: yes config_format: xml
  • 11. Run Ansible 1. Create an inventory file and define your devices: [ios] router1 ansible_host=192.168.0.201 switch1 ansible_host=192.168.0.203 [junos] router2 ansible_host=192.168.0.130 2. Create a playbook: - name: ping Google’s DNS from the device hosts: ios tasks: - ios_command: commands: ping 8.8.8.8 ….. <omitted> 3. Run the playbook: ansible-playbook myPlaybook.yml Sample inventory file: 2 groups, total of 3 network devices defined Sample playbook: Include plays and tasks to execute
  • 12. Live Demos • Vagrant running on macOS Sierra to provision the host VM • Ansible 2.2 running on Ubuntu 14.4 LTS • Cisco CSR 1000v and Juniper vSRX • SSH is enabled on CSR; Netconf is enabled on vSRX
  • 13. Demo 1: Ping Module # ansible all -m ping vsrx | SUCCESS => { "changed": false, "ping": "pong" } csr | SUCCESS => { "changed": false, "ping": "pong" }
  • 14. Demo 2: show_arp.yml --- - hosts: ios tasks: - ios_command: commands: show arp host: csr username: cisco password: cisco transport: cli ios_command module with required parameters
  • 15. Demo 3: show_arp_result.yml --- - hosts: ios tasks: - ios_command: commands: show arp host: csr username: cisco password: cisco transport: cli register: result - debug: var=result
  • 16. Demo 4: change_hostname.yml --- - name: Change hostname on a Cisco IOS router hosts: ios tasks: - ios_config: commands: - hostname CSR1 provider: "{{ cli }}" ios_config module with required arguments
  • 17. Demo 5: show_arp_result_junos.yml --- - hosts: junos tasks: - junos_command: commands: show arp provider: "{{ netconf }}" register: result - debug: var=result junos module with required arguments
  • 18. Additional Resources • Network Automation with Ansible, report by Jason Edelman (free, login required) https://www.oreilly.com/learning/network-automation-with-ansible • Up and Running with Ansible (free eBook) https://ipfs.io/ipfs/ QmTJaLdhUW6jTdXGFoqv7wZe5KguBi5F2u4ihBdrUMVPhw • Ivan Pepeljak’s Blog http://ipspace.net • Learn Linux: video training from safaribooksonline.com or lynda.com or pluralsight.com
  • 19. Thank You Stay in touch Questions?