Chapter 4 Where to Start with Network Automation?

For diagrams, tables, or exact code formatting, .

JOHN W. CAPOBIANCOPRINTED PAGE 72

The data belonging in group_vars or host_vars should be considered carefully. There are advantages and disadvantages to either approach. Generally, group_vars should contain as many platform or logical function standards as possible and can be used to reflect a solid network design adhering to best practices. Sometimes using group_vars does not make sense such as the case of a hostname or management IP address which naturally fits as host_vars. Include host information inside the group_vars where it makes sense. For example, as a standard, all distribution layer switches should have port-channel 1 configured as the uplink port to the core. Port-channels are usually included as a host variable but in this case port- channel 1 will be listed under the CAMPUS-DISTRIBUTION.yml group variable. Some examples of group_vars candidates:

 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.  Domain name.  Native VLAN.  Multicast.  Netflow.  Platform type identifier.  Other features with common code across a platform. host_vars Similar to group_vars, there is a folder in the repository called host_vars. In this folder there is a YAML file per device. DIST01.YML is the host_vars file for that specific network host. Store information that is specific and unique to the device on the network in the host_vars YAML files. Depending on the size of the fleet, it may take time to build complete coverage of the devices or configurations. Over time it becomes a matter of cloning an existing host_vars YAML file and replacing the data unique to the device.

It is recommended to prepend host_vars variables with hosts_ for ease of readability and reference point as to where the variable is in the repository (in a host_vars file). Some examples of host_vars variables include:

 Hostname.  Management SVI IP address.  VLANs.  VRFs.  Routing instances.  Switch Virtual Interfaces (SVI).  Physical interfaces.  Spanning-tree priorities.  Unique secrets or passwords.