Chapter 8 Data Models and Dynamic Templates
For diagrams, tables, or exact code formatting, .
Chapter 8 Data Models and Dynamic Templates “War is ninety percent information.” - Napoleon Bonaparte
In this chapter network configurations are converted and split into variables contained inside data models and dynamic templates. First group variables are created at a platform level representing standard configurations for the distribution or access layer. Unique, host-specific information will become host variables. Data models are written in the YAML format.
Jinja2 dynamic templates are introduced at this stage. These templates are used to establish the intent- based, data-driven, golden configuration that is applied to the devices. Jinaj2 files are a mix of static text, programmatic logic, and dynamic variables. These variables are called from the group and host variables in the data models. The resulting compiled output is an intent-based golden configuration.
Data Models – Group Variables Planning data models should take some time. These models are the structures and ultimately the variables that will be called by dynamic Jinaja2 templates. The structure is important and will dictate how to use the data logically to create working Cisco configurations. Another way to think of the group and host variables is to look at them as though they are data dictionaries made up of key-pair values and lists. Templates will access the keys-pair values and iterate over lists. Remember the examples of data that should be modeled in the group variables: Standard NTP, IP helper addresses for DHCP, SNMP, or syslog servers. Access-control lists at the distribution layer. QoS policies either by platform, logical function, or both. Banners. AAA configurations such as RADIUS or TACACS+ servers. Universal secret. Standard interfaces.
o VSS configurations for core and distribution. o Standardized uplinks. For example, port-channel 1 is always used as the uplink between
distribution and core. Domain name. Native VLAN. Multicast. NetFlow. Platform type flag / identifier. Other features with common code across a platform.
Here are some examples of group_vars for the enterprise network. Remember the scope of the data model applies to all devices under the group in hosts.ini. For example, a data model that applies to all devices on the network:
