Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Ansible for Junos OS Developer Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Understanding the Ansible Inventory File When Managing Junos Devices

date_range 29-Jul-24

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:

content_copy zoom_out_map
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/inventory_guide/intro_inventory.html.

footer-navigation