Network Automation Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

Perform the following steps to create the inventory file:

  1. Create a file named hosts:
$ touch hosts
  1. Using any text editor, open the file and add the following content:
$ cat hosts

[cisco]
csr1 ansible_host=172.10.1.2
csr2 ansible_host=172.10.1.3

[juniper]
mx1 ansible_host=172.20.1.2
mx2 ansible_host=172.20.1.3

[core]
mx1
mx2

[edge]
csr[1:2]

[network:children]
core
edge
The Ansible inventory file can have any name. However, as a best practice, we will use the name hosts to describe the devices in our inventory.