How it works...

The Ansible inventory files define the hosts that will be managed by Ansible (in the preceding example, this is csr1-2 and mx1-2 ) and how to group these devices into custom-defined groups based on different criteria. The groups are defined with []. This grouping helps us to define the variables and simplify the segregation between the devices and how Ansible interacts with them. How we group the devices is based on our use case, so we can group them as per the vendor (Juniper and IOS) or function (core and edge).

We can also build hierarchies for the groups using the children, which is outlined in the inventory file. The following diagram shows how the hosts are grouped and how the group hierarchy is built: