2. Introduction
Topic Brief:
Ansible is an automation and configuration management technology used to provision, deploy, and manage
compute infrastructure across cloud, virtual, and physical environments. This talk demonstrates how to use
Ansible to automate the configuration of Nexus 9000 series switches in either NX-OS using the NX-API or through
the Application Centric Infrastructure (ACI) controller (APIC).
Speaker Bio:
Joel W. King is a network architect at World Wide Technology (WWT) focused on engineering innovation in
enterprise SDN and network programmability.
Participated on Networking Panel at AnsibleFest NYC 2015
joel.king@wwt.com
@joel_w_king
www.slideshare.net/joelwking
github.com/joelwking/
3. Agenda
What is Ansible?
Using Ansible for Cisco Nexus 9000 series fabric deployments
NX-OS using the NX-API (MP-BGP EVPN VXLAN Fabric Design)
Application Centric Infrastructure
4. Cisco Data Center Switching
• If you are looking to Cisco for a Data Center switch, it will be a Nexus 9000.
• Nexus 9000 runs in either of two modes:
• NX-OS
• Application Centric Infrastructure – ACI
• Networks need Automation & Programmability.
• NX-API enables a northbound REST interface on individual NX-OS switches
• Nexus 3000 NX-API supported NX-OS 6.0(2)U4(1).
• NX-OS release 7.x enables NX-API on Cisco Nexus 5000 and 6000
• APIC is the Software Defined Networking controller for ACI
5. Introduction to Ansible
SIMPLE AGENTLESS POWERFUL
• Ansible uses
SSH instead of
agents.
• Python
modules run
locally or on
target systems
• Deploy
applications
• Configuration
management
• Network
provisioning
• Playbooks are
both human
and machine
readable.
• Large library of
modules.
6. Ansible and Cisco Data Center Networking
SSH – TCP/22
Users, API
NTP – UDP / 123
HTTP(s) TCP/80:443:22
HTTP(s) TCP/80:443
SSH – TCP/22
GitHub
HTTPS TCP/443
LDAP – TCP / 389
ESX
Server
Windows
Systems
Linux
DockerAmazon
Web Services
Agentless
Ansible / Tower
REST API
connection: local
feature nx-api
Nexus 3000 | 9000
Nexus 9000
ACI
github.com/joelwking/
PARAMIKO
APIC-EM
Cisco IOS
7. Push Based
• Chef and Puppet are “pull-based”
• The agent on the server periodically checks with the central server for configuration
information. (Chef agent by default checks with Chef server every 30 minutes)
• Chef uses a “convergent” model of configuration. As changes propagate through the
nodes, the network as a whole converges to the desired configuration state.
• Ansible is “push-based”
• You run the playbook,
• Ansible modules connect to the target servers and executes the modules
• Push based approach - you control when the changes are made on the server!
• No need to wait for a timer to fire.
Source: Ansible Up & Running & www.chef.io/solutions/configuration-management/
8. Lexicon
• Inventory A file grouping host names and (optionally) variables.
• Playbooks A design plan of tasks to act on one or more hosts.
• YAML Markup language, more human readable than XML / JSON.
• Facts Variables describing the target system.
• Tasks An activity to be carried out, e.g. install package, configure interface.
• Modules Python code to implement tasks.
• Idempotent Producing the same results if executed once or multiple times.
• Jinja2 Templating language converting templates to configuration files.
• Vault Encrypts sensitive data, passwords, use --ask-vault to prompt.
• Roles Directory structure to provide abstraction, think include files.
9. Why Learn Ansible?
• Simple, powerful automation tool
• Agentless
• Automation without programming
• Exposes you to Markup Languages
• Forces you to think like a programmer
• Low barrier to entry – Open Source, runs in a VM on your laptop
• Ansible Tower
• centralize and control your infrastructure
• visual dashboard,
• role-based access control,
• job scheduling,
• graphical inventory management.
10. What are Markup Languages?
• Markup Languages are implementations of
Data Serialization formats | standards | languages
• Cisco IOS configuration files are a proprietary form of
Markup Language
• Examples
• CSV Comma Separated Values
• XML Extensible Markup Language
• JSON JavaScript Object Notation
• YAML YAML ain’t Markup Language
11. Why Learn Markup Languages?
• Represent structured data to define a network configuration.
• Less emphasis on Command Line Interface (CLI) and IOS config files
Cisco ACI controller (APIC)
will generate and accept both
JSON and XML to save and upload
configurations
NETCONF protocol uses an XML
for configuration data and output messages.
Cisco IOS XR software has an XML
application programming interface (API).
13. NX-OS Programmabilty
• ******* [ customer name removed ] *******************
• MP-BGP EVPN VXLAN Fabric Design
• Nexus 9500 spines (4)
• Nexus 9300 leafs (40)
• NX-OS configuration is complex
775 lines of config per leaf
WWT Integration Technology Center (ITC)
Cisco Virtual Topology System (VTS)
Cisco Prime Data Center Network Manager
(DCNM)
14. Process Flow
Group Variables
(All Leafs)
Host Variables
(Individual Switch)
Jinja Template
L2 Port Configuration
CSV
L3 Port Configuration
CSV
Switch
Configuration
15. Configuring your network from Excel
kingjoe@rocket:~/ansible/roles/excel_nxos/templates$ cat leaf_uplinks.j2
#
# Template for leaf uplinks
#
{% for row in spreadsheet %}
interface {{row.SourcePort}}
description {{row.Description}}
mtu 9216
load-interval counter 1 5
ip address {{row.SourceIP}}
no ipv6 redirects
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 {{OSPF.message_digest_key}}
ip ospf network point-to-point
ip router ospf {{OSPF.processID}} area 0.0.0.0
ip pim sparse-mode
no shutdown
!
{% endfor %}
end
#
# group_vars/leaf
#
OSPF:
message_digest_key: DEADBEEF
processID: 64800
18. Render the Configuration
#
# Template for leaf uplinks
#
interface Ethernet2/1
description 13spine-rp01_E1/1
mtu 9216
load-interval counter 1 5
ip address 10.181.0.1/31
no ipv6 redirects
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 DEADBEEF
ip ospf network point-to-point
ip router ospf 64800 area 0.0.0.0
ip pim sparse-mode
no shutdown
!
! [ interfaces E2/2 E2/3 and E2/4 removed for brevity ]
!
end
Each column headers are variable names,
cell contents are assigned to these variables.
Variables are then used to render configuration.
Network engineer controls column header names
https://github.com/joelwking/ansible-nxapi/blob/master/csv_to_facts.py
23. Why do I need automation with ACI?
• Using the ACI GUI is time consuming and prone to human error.
• WWT Integration Technology Center
(ITC) is the hub of our
global deployments and
supply chain programs.
• Customers use the ITC to
stage their data center
infrastructure prior to
deployment.
24. ACI Demonstrations
• Published demos
• Find the MAC address
https://youtu.be/t03ty5Y295U
• Apply ACI policDemo: Apply ACI policy, run Docker app
https://youtu.be/t03ty5Y295U?t=1m49s
• Today’s demo
• Use Ansible Roles to configure ACI fabric
• Specify NTP servers in CSV file
• Create XML files from templates
• Configure NTP and Daily Backups
25. Process Flow
vars
Jinja Template (s)
XML
ntp_server.csv
NTP
DAILY_BACKUP
REST API
---
- name: Example of a site.yml file running two roles
hosts: aci
gather_facts: no
roles:
- NTP
- DAILY_BACKUP
27. Configuring your ACI network from Excel
http://erjosito.tumblr.com/post/129878491127/configuring-your-network-from-excel
28. Summary
• One tool, two fabrics - ACI or NX-OS.
• Next generation networks, configurations less CLI, more Markup Languages.
• Network Engineers can ‘program’ the network without writing programs.