Chapter 8 Data Models and Dynamic Templates

For diagrams, tables, or exact code formatting, .

JOHN W. CAPOBIANCOPRINTED PAGE 141

 Software development is a continuous cycle of improvement.

Scope We have created approximately 35 templates to cover all the configurations of the core, distribution, and access devices in our enterprise network. As more features arise this list is certain to grow. Pick and choose which templates apply to the network and add more, for example an EIGRP template. For more on templating please visit:

https://docs.ansible.com/ansible/2.7/user_guide/playbooks_templating.html

More Examples of Configuration Templates

Here are more examples of templates that can be refactored to fit or used directly in a network for configuration management coverage by function. The matching data model dictionaries will be posted for reference to make it easier to connect the two, however focus on the templates at this point.

VLAN 
 
vlan {{ global_campus_defaults.native_vlan }} 
 name NativeVLAN 
 
{%  if host_vlans is defined %} 
{%      for host_vlan in host_vlans %} 
vlan {{ host_vlan }} 
 name {{ host_vlans[host_vlan].name }} 
{%     endfor %}  
{%  endif %} 
 
Data model – group_vars CAMPUS.yml 
 
global_campus_defaults: 
  native_vlan: 99 
 
Data model – host_vars DIST01.yml 
 
host_vlans: 
   2: 
    name: "In-BandManagement" 
 
   3: 
    name: WirelessAccessPoints 
 
   100: 
    name: Spanned_Legacy_VLAN01 
 
   200: 
    name: Spanned_Legacy_VLAN02 
 
   10: 
    name: BLUE_Zone_First_Floor