Chapter 4 Where to Start with Network Automation?
For diagrams, tables, or exact code formatting, .
Excellent starting point to network automation. Non-disruptive / non-intrusive / no chance of anything going wrong. Simple and easy to get going. Basically, converting the commands normally run on a device to a simple script. Dry run processes. Start building a centralized library of customized network utilities available for engineers or operators to run on-demand or scheduled for execution daily / weekly. Start building dynamic network documentation. Understand the network:
o Layer 1 topology. o Layer 2 topology. o Layer 3 topology. o Cisco Discovery Protocol (CDP) neighbors. o Open Shortest Path First (OSPF) / Enhanced Interior Gateway Routing Protocol (EIGRP) /
Border Gateway Protocol (BGP) neighbors. o Routing tables. o VLANs. o Interface availability / usage. Improves software development skills.
Using Ansible offers many ways to gather information from the network. This book focuses on the Cisco ios_facts and ios_command modules that are natively included with Ansible installation.
Ansible Module – ios_facts Ansible has a built-in module – ios_facts – that can be used to gather facts from the Cisco IOS devices on the network. Simple to use, the ios_facts module is a great place to start. Basic information about the hardware, configuration, and interfaces is returned from ios_facts. The default setting includes all available facts about a device however it is possible to limit the scope of what ios_facts includes or excludes from the playbook. Examples of ios_facts usage are included in Chapter 6. It should be noted that other similar fact gathering modules exist such as nxos_facts.
A mix of limiting to specific subsets of facts, or every fact but specific subsets, can be used to adjust the scope. Some basic examples from the Ansible ios_facts module documentation:
# Collect all facts from the device
- ios_facts:
gather_subset: all
# Collect only the config and default facts
- ios_facts:
gather_subset:
- config
# Do not collect hardware facts
- ios_facts:
gather_subset:
- "!hardware"For more information about the ios_facts module please visit:
