Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Understanding the Ansible for Junos OS Modules

 

Ansible for Junos OS Modules Overview

Ansible is an IT automation framework that is used for infrastructure configuration management. An Ansible module models a specific resource on a managed node and ensures that the resource is in a specific state. You can execute individual modules on remote hosts to perform ad-hoc tasks, or you can execute modules through playbooks.

Ansible and Juniper Networks provide collections of Ansible modules that you can use to perform operational and configuration tasks on devices running Junos OS. Starting in Ansible Release 2.1, Ansible natively includes a number of core modules that can be used to manage devices running Junos OS. In addition, Juniper Networks provides a collection of modules in the Juniper.junos role, which is hosted on the Ansible Galaxy website . Both the Ansible core modules and Ansible Galaxy modules for Junos OS can coexist on the same platform. For brevity, references to Ansible for Junos OS modules include both the Ansible core and Ansible Galaxy modules for Junos OS.

Typically, the control machine sends a module to a managed node, where it is executed and then removed. In this scenario, the managed nodes must have the ability to execute the Ansible modules. Generally, Python is required on the managed nodes, because most Ansible modules are written in Python.

Ansible for Junos OS modules do not require Python on the managed nodes. In contrast to the typical operation, you execute Ansible for Junos OS modules locally on the Ansible server, and the modules use NETCONF and the Junos XML API to interface with managed nodes. This method of execution enables you to use Ansible to manage any supported device running Junos OS. Figure 1 illustrates the communication between the Ansible control machine and a managed device running Junos OS.

Figure 1: Ansible Communication with Devices Running Junos OS
Ansible
Communication with Devices Running Junos OS

To run Ansible modules locally on the control machine, include --connection=local when executing individual modules, or include connection: local in your Ansible playbook. If a playbook uses the Juniper.junos modules, the playbook must also include the Juniper.junos role.

For example, the following command executes the junos_facts Ansible core module to retrieve device facts from hosts in inventory group dc1.

user@host$ ansible --connection=local -i hosts.ini dc1 -m junos_facts

The following sample playbook executes the juniper_junos_facts module, which is part of the Juniper.junos role, to retrieve the device facts and save them to a file.

You can execute Ansible for Junos OS modules using any user account that has access to the managed device running Junos OS. When you execute Ansible modules, Junos OS user account access privileges are enforced, and the class configured for the Junos OS user account determines the permissions. Thus, if a user executes a module that loads configuration changes onto a device, the user must have permissions to change the relevant portions of the configuration.

Ansible Core Modules for Junos OS

Starting in Ansible Release 2.1, the Ansible core modules for Junos OS are available as part of the Ansible software. Table 1 summarizes the core modules. For the most current list, documentation, and usage examples for the Ansible core modules for Junos OS, see https://docs.ansible.com/ansible/latest/list_of_network_modules.html#junos.

Table 1: Ansible Core Modules for Junos OS

Module

Description

junos_banner

Manage multiline banners on devices running Junos OS.

junos_command

Execute commands on devices running Junos OS.

junos_config

Manage configurations on devices running Junos OS.

junos_facts

Retrieve device-specific information from the remote host.

junos_interface

Configure physical interface properties on devices running Junos OS.

junos_l3_interface

Configure logical interfaces on devices running Junos OS.

junos_linkagg

Manage link aggregation groups (LAGs) on devices running Junos OS.

junos_lldp

Configure Link Layer Discovery Protocol (LLDP) settings.

junos_lldp_interface

Enable or disable the Link Layer Discovery Protocol (LLDP) on interfaces.

junos_logging

Configure system logging on devices running Junos OS.

junos_netconf

Configure the NETCONF service on devices running Junos OS.

junos_package

Install a Junos OS software package on a device.

junos_rpc

Execute Junos OS RPCs.

junos_static_route

Manage static routes on devices running Junos OS.

junos_system

Manage system attributes such as hostname, domain name, and DNS name servers on devices running Junos OS.

junos_user

Manage Junos OS user accounts.

junos_vlan

Manage VLANs on devices running Junos OS.

junos_vrf

Manage virtual routing and forwarding (VRF) instances, also known as a Layer 3 VPN routing instances, on devices running Junos OS.

Ansible Galaxy Modules for Junos OS

Juniper Networks provides the Juniper.junos Ansible role, which is hosted on the Ansible Galaxy website and includes Ansible modules that enable you to manage devices running Junos OS. To use the Ansible Galaxy modules in the Juniper.junos role, you must install the role on the Ansible control machine. For example:

[user@ansible-cm]$ sudo ansible-galaxy install Juniper.junos

Starting in Ansible for Junos OS Release 2.0.0, the Juniper.junos role includes an enhanced set of modules. Each new module replaces the functionality of one or more existing modules. The enhanced modules support a common set of connection and authentication parameters, aliases that enable you to specify the same connection and authentication-related options as the core modules, and the ability to specify the parameters inside a provider dictionary.

Table 2 summarizes the Ansible Galaxy modules in the Juniper.junos role, and notes which modules replace existing modules in Release 2.0.0. For the most current list, documentation, and usage examples for the Ansible Galaxy modules for Junos OS, see https://junos-ansible-modules.readthedocs.io/en/latest/.

Note

The Juniper.junos modules introduced in Release 2.0.0 of Ansible for Junos OS require Junos PyEZ Release 2.1.7 or later on the Ansible control machine.

Table 2: Ansible Galaxy Modules in the Juniper.junos Role

Module Name

Description

Deprecated Modules as of Release 2.0.0

juniper_junos_command

Execute CLI commands on the device running Junos OS and save the output locally.

junos_cli

juniper_junos_config

Manage the configuration of devices running Junos OS.

junos_commit

junos_get_config

junos_install_config

junos_rollback

juniper_junos_facts

Retrieve device-specific information from the remote host, including the Junos OS version, serial number, and hardware model number.

junos_get_facts

juniper_junos_jsnapy

Execute Junos Snapshot Administrator in Python (JSNAPy) tests from Ansible.

junos_jsnapy

juniper_junos_ping

Execute the ping command on devices running Junos OS.

junos_ping

juniper_junos_pmtud

Perform path MTU discovery on devices running Junos OS.

junos_pmtud

juniper_junos_rpc

Execute Junos OS RPCs.

junos_rpc

juniper_junos_software

Install a Junos OS software package and reboot a device running Junos OS.

junos_install_os

juniper_junos_system

Perform system operations on devices running Junos OS, including resetting, rebooting, or shutting down the device.

junos_shutdown

junos_zeroize

juniper_junos_srx_cluster

Create an SRX Series chassis cluster for cluster-capable SRX Series Services Gateways running Junos OS.

junos_srx_cluster

juniper_junos_table

Use Junos PyEZ operational Tables and Views to retrieve operational information from devices running Junos OS.

junos_get_table

Release History Table
Release
Description
Starting in Ansible for Junos OS Release 2.0.0, the Juniper.junos role includes an enhanced set of modules.