Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Understanding the Ansible Inventory File When Managing Junos Devices

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 locations.

The inventory file can list individual hosts or user-defined groups of hosts. This enables you to define groups of Junos devices 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 Junos devices 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 of hosts, routers and switches:

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 .