Use the juniper.device.junos_* Ansible Modules to Manage Junos
Devices
You can use the juniper.device.junos_* Ansible modules (also known
as the junipernetworks.junos modules) in the
juniper.device collection to manage devices running Junos OS and
devices running Junos OS Evolved.
Starting in juniper.device Release 2.0.0, we merged the Red Hat Ansible
junipernetworks.junos modules into the
juniper.device Ansible collection. You can identify the modules by
the junos_ prefix in the module name. This document outlines how to use
the merged junipernetworks.junos modules in the
juniper.device collection.
Module Merge Overview
The merged junipernetworks.junos modules are identical to the
original junipernetworks.junos modules. You can continue to use the
modules as before with only minor changes to your environment. When you use the
merged modules:
-
You can continue to use the
junipernetworks.junosnamespace in your playbooks, or you can use thejuniper.devicenamespace. We recommend migrating to the new namespace. -
You must define the Ansible network OS as
juniper.device.junosinstead ofjunipernetworks.junos.junos. -
There is no change to the modules' supported Ansible network connections.
The following sections provide additional details about how to use the
junipernetworks.junos modules in the
juniper.device collection.
Collection Namespace
When you use the junipernetworks.junos modules in the
juniper.device collection, you can execute the modules
under the old namespace or the new namespace.
-
To use playbooks that reference the new namespace as
juniper.device.module-name, you need to install only thejuniper.devicecollection. -
To use playbooks that continue to reference the original namespace as
junipernetworks.junos.module-name, you must install both thejuniper.devicecollection and thejunipernetworks.junoscollection.
Ansible Network OS
To use the merged junipernetworks.junos modules in the
juniper.device collection, the only required change is to
update the Ansible network OS variable. You can define the Ansible network OS
variable in various locations, including in the inventory file or in host or
group variable files. For any hosts that you manage with the modules, set the
ansible_network_os variable to
juniper.device.junos.
For example, the following sample inventory file defines the
ansible_network_os variable for the hosts in the
junos group.
[junos] router1.example.com router2.example.com router3.example.com [junos:vars] ansible_network_os=juniper.device.junos ansible_connection=ansible.netcommon.netconf
For more information about the inventory file, see Understanding the Ansible Inventory File When Managing Junos Devices.
Ansible Connections
The junipernetworks.junos modules support two Ansible
connections:
-
ansible.netcommon.network_cli (CLI) -
ansible.netcommon.netconf (NETCONF)
There is no change to the supported Ansible connections with the merge of the
modules into the juniper.device collection. Table 1 outlines the connection properties. To determine the connections that each
module supports, see junipernetworks.junos Modules.
| Property | CLI | NETCONF |
|---|---|---|
|
Connection Setting |
|
ansible.netcommon.netconf |
|
Protocol |
SSH |
NETCONF over SSH |
|
Authentication |
|
|
|
Indirect access |
Bastion (jump host) |
Bastion (jump host) |
Use the junipernetworks.junos Modules
To use the junipernetworks.junos modules, you must define
several connection parameters within your environment. The connection parameters
to define for the networking modules include:
-
ansible_connection—Specify how to connect to the device. You generally include this parameter in your inventory file or in your host or group variable files. It defines the Ansible connection to use for a host or group of hosts. -
ansible_network_os—Define the network OS of the managed device for modules that useansible.netcommon.*connections. This setting helps ensure that Ansible uses the correct connection plugins and modules for the network device. -
connection—Specify how to connect to the device. You generally include this parameter in a playbook play or task. It defines the Ansible connection for the hosts in that play or task.
Note that ansible_connection and connection
define the same connection in different contexts. You must define either
ansible_connection or connection for the
hosts in the inventory group.
To use the junipernetworks.junos modules to manage Junos
devices: