An inventory file represents the devices (hosts) that will be managed. It defines the IP address(es) that will be assigned to the management interface of the switch (OOB). Using an inventory file, a single playbook can maintain and configure hundreds of network devices with a single command.
To create an inventory file, perform the following steps on the Ansible Controller Node:- To create a directory to store the files created during this PoC, type the following command:
root@AnsibleNode:~# mkdir PoC
- To create the inventory file in the PoC directory, open Vim and type the following command:
root@AnsibleNode:~/POC# vim inventory.yaml
- To enter Insert mode, type i.
'INSERT' displays at the bottom of the screen.
- To create the inventory file, copy and paste the following information:
leaf1 ansible_host=100.94.107.13
leaf2 ansible_host=100.94.107.12
leaf3 ansible_host=100.94.107.11
spine1 ansible_host=100.94.107.15
spine2 ansible_host=100.94.107.14
[spine]
spine-1
spine-2
[leaf]
leaf-1
leaf-2
leaf-3
[datacenter:children]
Leaf
spine
leaf
spine
- Save and close the file:
- To exit Insert mode, press the Esc key.
- To save the file, type the following command:
- Press the Enter key.