Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

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.junos namespace in your playbooks, or you can use the juniper.device namespace. We recommend migrating to the new namespace.

  • You must define the Ansible network OS as juniper.device.junos instead of junipernetworks.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 the juniper.device collection.

  • To use playbooks that continue to reference the original namespace as junipernetworks.junos.module-name, you must install both the juniper.device collection and the junipernetworks.junos collection.

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.

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.

Table 1: Supported Ansible Connections for the junipernetworks.junos Modules
Property CLI NETCONF

Connection Setting

ansible.netcommon.network_cli

ansible.netcommon.netconf

Protocol

SSH

NETCONF over SSH

Authentication

  • SSH keys / SSH agent

  • Username/password

  • SSH keys / SSH agent

  • Username/password

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 use ansible.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:

  1. Define the Ansible network OS for your hosts in the location appropriate for your environment and in the syntax required for the file's format.

    The following sample INI-formatted inventory file defines the Ansible network OS as juniper.device.junos for the junos group:

  2. Define the Ansible connection for your modules. Check the module documentation to verify the connections that each module supports.
    • To define the connection in your inventory file, set ansible_connection to the required value. For example:

    • To define the connection in your playbook, set connection to the required value.

  3. To access managed devices through a bastion or jump host, include the appropriate variable in your inventory file, host or group variable file, or SSH configuration file. The user must use SSH keys to authenticate with the bastion or jump host.
    • For ansible.netcommon.netconf connections, include the ansible_netconf_proxy_command variable.

    • For ansible.netcommon.network_cli connections, include the ansible_paramiko_proxy_command variable.

      Alternatively, for ansible.netcommon.network_cli connections, you can include the ProxyCommand option in your SSH configuration file in supported releases.

  4. In your playbook, specify the fully qualified module name.
    • If you installed the juniper.device collection only, use the juniper.device namespace.

    • If you installed the juniper.device collection and the junipernetworks.junos collection, you can use either the juniper.device namespace or the junipernetworks.junos namespace in your playbooks.