Understanding the Ansible Inventory File When Managing Devices Running Junos OS
The Ansible inventory file defines the hosts and groups of hosts
upon which commands, modules, and tasks in a playbook operate. The
file can be in one of many formats depending on your Ansible environment
and plugins. Common formats include INI and YAML. The default location
for the inventory file is
/etc/ansible/hosts. You can also create project-specific inventory files in alternate
The inventory file can list individual hosts or user-defined groups of hosts. This enables you to define groups of devices running Junos OS with similar roles upon which to perform the same operational and configuration tasks. For example, if you are managing one or more data centers, you can create Ansible groups for those switches that require the same set of operations, such as upgrading Junos OS and rebooting the device.
In order to manage devices running Junos OS using Ansible, you must have a Junos OS login account with appropriate access privileges on each device where Ansible modules are executed. You must ensure that usernames and passwords or access keys exist for each host in the file.
The following INI-formatted sample inventory file defines
an individual host,
host1, and two groups
host1.example.net [routers] router1.example.net router2.example.net [switches] switch1.example.net switch2.example.net
For more information about the Ansible inventory file, see the official Ansible documentation at https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html .