When working with many customers over the past 6 years with automation, I have seen the same questions asked in workshop after workshop. Are there practical examples of templates that we can use as a starting point to begin deploying with automation.
After working with well over 30 customers, I have come up with templates which fit for the majority of typical access switch situations.
Within this section we will only deal with the non Fabric environment and deployment.
Either one or multiple Templates may be used to deploy Intent in combination with the Design Settings and Policies deployed within the UI. One or Multiple templates may be used in Onboarding (PnP) or Day N methods. Day N methods are designed for making ongoing changes and may require 'no' statements depending on the configuration construct being modified.
Additionally:
- Intent can be defined as the set of configuration constructs deployed via a template.
- Variables can be used to modify or choose between constructs deployed via decision (‘IF’) statements
- Repetition of any construct may be introduced through the use of Looping structures on any device.
- Variables may be used when the device is being onboarded or provisioned
To help get started with and better understand the PnP process we have provided this material. It is designed to help you understand the Plug and Play process, templates and deployment of these within a lab setting. Once you are comfortable with the concepts you can work on a deployment and implementation plan for your network.
To help get started with the PnP process and to better understand the process, please review the following information:
Click for Details and Sub Tasks
- PnP Workflow - This section explains the overall Plug and Play Methodology
- Onboarding - This section will explain Onboarding Templates in Cisco Catalyst Center and their use
- Building Templates - This section will explain how to build a template on DNAC
To let you practice and get experience with the PnP process to better understand it. The labs referenced here use templates and projects within those labs, but you may substitute the example below. Please review the following lab information:
Click for Details and Sub Tasks
This material is designed to help you understand the Plug and Play process, templates and deployment of these within a lab setting.
Within the following location is an example template written in Jinja2 in JSON format which can be imported into the Onboarding Configuration section in the Template Editor/Hub:
⬇︎Full Cisco Catalyst Center PnP Onboarding Template⬇︎
This template includes a number of built in features, which allow for the majority of use cases. We will explore those here in this section.
Click for Details and Sub Tasks
Within the form you can see many fields which can be populated with a csv file. These are the typical responses necessary that are different from switch to switch which allow us to template the configuration for repeated use.
- The hostname.
- System MTU is a default setting which if entered changes the configuration. You can have the switch reload to set that setting if you want using an additional EEM script.
- The typical management VLAN and IP address information for management purposes.
- The interfaces can be entered comma delimited which allows us to create or not create Etherchannels as necessary.
Once you have imported the template you can look at the logic.
- System MTU set by default, but modifiable via the form
- VTP Domain set to Hostname, you can change to variable by removing
{% set VtpDomain = Hostname %}
- Shuts downn Vlan 1 if not in use
- Automatically builds Etherchannel if required
{# <------Onboarding-Template-------> #}
{# To be used for onboarding when using Day N Templates #}
{# Define Variables provision with vlan and port channel #}
!
{# Set MTU if required #}
{% if SystemMTU != 1500 %}
system mtu {{ SystemMTU }}
{% endif %}
!
{# Set hostname #}
hostname {{ Hostname }}
!
{% set VtpDomain = Hostname %}
!
{# Set VTP and VLAN for onboarding #}
vtp domain {{ VtpDomain }}
vtp mode transparent
!
{# Set Management VLAN #}
vlan {{ MgmtVlan }}
!
{% if MgmtVlan > 1 %}
name MgmtVlan
{# Disable Vlan 1 (optional) #}
interface Vlan 1
shutdown
{% endif %}
!
{# Set Interfaces and Build Port Channel #}
!{{ Portchannel }}
interface range {{ Interfaces }}
shut
switchport mode trunk
switchport trunk allowed vlan {{ MgmtVlan }}
{% if "," in Interfaces %}
channel-protocol lacp
channel-group {{ Portchannel }} mode active
{% endif %}
no shut
!
{% if "," in Interfaces %}
interface Port-channel {{ Portchannel }}
switchport trunk native vlan {{ MgmtVlan }}
switchport trunk allowed vlan {{ MgmtVlan }}
switchport mode trunk
no port-channel standalone-disable
{% endif %}
!
{# Set Up Managment Vlan {{ MgmtVlan }} #}
interface Vlan {{ MgmtVlan }}
description MgmtVlan
ip address {{ SwitchIP }} {{ SubnetMask }}
no ip redirects
no ip proxy-arp
no shut
!
ip default-gateway {{ Gateway }}
!
{# Set Source of Management Traffic #}
ip domain lookup source-interface Vlan {{ MgmtVlan }}
ip http client source-interface Vlan {{ MgmtVlan }}
ip ftp source-interface Vlan {{ MgmtVlan }}
ip tftp source-interface Vlan {{ MgmtVlan }}
ip ssh source-interface Vlan {{ MgmtVlan }}
ip radius source-interface Vlan {{ MgmtVlan }}
logging source-interface Vlan {{ MgmtVlan }}
snmp-server trap-source Vlan {{ MgmtVlan }}
ntp source Vlan {{ MgmtVlan }}
!
To help get started with and better understand the DayN process we have provided this material. It is designed to help you understand regular and composite templates and deployment of these within a lab setting. Once you are comfortable with the concepts you can work on a deployment and implementation plan for your network.
To help get started with the PnP process and to better understand the process, please review the following information:
Click for Details and Sub Tasks
- DayN Templates - This section will explain how to use templates for ongoing changes to the network
- Building Templates - This section will explain how to build a template on DNAC
Here we concentrate on building Jinja2 templates, and work with logical concepts.
Click for Details and Sub Tasks
- Jinja2 Variables - This section explains Variables in depth and how and where to use them
- Jinja2 Scripting - This section will dive into Velocity Scripting constructs and use cases
- Advanced Jinja2 Scripting - This section will dive into Advanced Velocity examples
Here we concentrate on advanced uses of templating, and work system variables.
- Embedded Event Manager - This section will dive into EEM Scripting and various use cases
- System Variables - This section explains Cisco Catalyst Centers System Variables
- Troubleshooting - This section will dive into Troubleshooting in general terms
To let you practice and get experience with the DayN process to better understand it. The labs referenced here use templates and projects within those labs, but you may substitute the example below. Please review the following lab information:
Click for Details and Sub Tasks
This material is designed to help you understand the use and processes of utilizing templates and deployment of these within a lab setting.
- Day N Templates - The lab covers Day N template constructs and use cases (allow 0.5 hrs)
- Composite Templates - This lab covers building a composite template on Cisco Catalyst Center (allow 0.5 hrs)
- Advanced Automation - This lab will explore Advanced Automation examples (allow 1.5 hrs)
- Dynamic Automation - This lab uses Advanced Automation techniques (allow 2.0 hrs)
This is an example which you may want to test with in the lab in combination with the PnP Template offered here. Within the following location is an example project written in Jinja2 in JSON format which can be imported into the Template Editor/Hub:
⬇︎Full Cisco Catalyst Center Sample Project⬇︎
This project includes templates with a number of built in features, which allow for the majority of use cases. We will explore those here in this section.
Click for Details and Sub Tasks
The package or project includes Jinja2 templates which are rolled into Composite templates to allow for quick deployment of:
- Simple Access Point and Workstation Deployments.
- The use or incorporation of AutoConf to Autoconfigure ports based off Device Classification
- The use of IBNS 2.0 policy to enforce and deploy configuration.
The last of the two above, allow for Dynamic Configuration of networks to allow for networks where devices consistently move but where user and application experience needs to be consistent.
Once you have imported the template you can look at the logic within each modularized regular template. Each of these templates is part of the composites above, and some are referenced using includes where necessary to avoid repeating code.
- AAA Configuration for nonPxGrid - Deployments
- ACLs
- Autoconf Configuration Options
- AutoNaming EEM Scripting - for Interfaces
- DynamicPort EEM Scripting - for use in changing Auth profiles
- IBNS2.0 Configuration
- Interface Assign Configuration - for standard interface configurations
- Interface Autoconf Configuration - for dynamic configuration through device classification
- Interface IBNS2.0 Configuration - for policy based interface configuration
- Interface Macros - set of multi-purpose interface macros
- Security AAA Modifications - various security configurations
- Sensitive Info - for securing sensitive information from general configs
- Stacking Configuration - for powerstack and stackwise configuration
- System Management - for global configurations
- Vlans Info - includes examples of how to deploy Vlans using objects
I hope you find these samples highly useful, and please provide feedback.
These examples are ready for testing in your lab. These are aides to help you get up to speed with what is possible when automating with Cisco Catalyst Center. The intent of this part of the repository is to aide in learning and not provide production ready templates. All templates here are for LAB Purposes ONLY and by downloading any content you acknowledge that this is not production ready code.
Feedback: If you found this repository please fill in comments and give feedback on how it could be improved.
Special mention to: https://jinja.palletsprojects.com/en/3.0.x/templates as examples and extrapolations were made using this documentation.