Ansible for Junos OS Server Requirements
Learn about the requirements for setting up an Ansible control node to manage devices running Junos OS and devices running Junos OS Evolved.
Juniper Networks supports using Ansible to manage devices running Junos OS and devices running Junos OS Evolved. We provide Ansible modules that you can use to perform operational and configuration tasks on your managed devices. The Juniper Networks modules are distributed through the following collection, which is hosted on the Ansible Galaxy website:
-
juniper.devicecollection
Starting in juniper.device Release 2.0.0, we've consolidated the Juniper
Networks juniper.device collection and
the Red Hat Ansible junipernetworks.junos
collection into a single juniper.device collection. When you install
the juniper.device collection, you can use
juniper.device.module_name to execute
modules from either module set. If you want to continue to use existing playbooks that
reference junipernetworks.junos.module_name, you
must also install the junipernetworks.junos collection. To execute the
junipernetworks.junos modules using either namespace, you must
define ansible_network_os=juniper.device.junos. Otherwise, everything
else remains the same when using the merged set of modules.
You install Ansible on a control node with a Unix-like operating system. You can install Ansible and the Juniper Networks collection:
-
Directly on the configuration management server
-
Within a Python virtual environment
-
As a Docker container
To install Ansible and the juniper.device collection under the
system-installed Python or in Python virtual environment on the control node, see the
following sections:
The Juniper Networks juniper/pyez-ansible Docker image is a lightweight, self-contained system that bundles Ansible, the Juniper Networks modules, and all dependencies into a single portable container. The Docker container enables you to quickly run Ansible in interactive mode or as an executable package on any platform that supports Docker. To use the Ansible for Junos OS Docker image, see the following section:
Prerequisite Software
Before you install the Juniper Networks juniper.device
collection and begin using Ansible to manage Junos devices, you must install the
following prerequisite software in your selected environment on the Ansible
control node. You can install the software under the system-installed Python or
in a Python virtual environment. We recommend using a Python virtual
environment.
-
Python 3.12 or later
-
Ansible 10.x or later (ansible-core version 2.17 or later)
-
Junos PyEZ (
junos-eznc) Release 2.7.3 or later.For Junos PyEZ installation instructions, see:
-
The following Python packages and libraries:
-
Junos Snapshot Administrator in Python (JSNAPy) Release 1.3.7 or later (required to use the
juniper.device.jsnapymodule).For installation instructions and current information about JSNAPy, see:
Install the juniper.device Collection
On the Ansible control node, you can install the juniper.device
collection and the junipernetworks.junos collection from Ansible
Galaxy. Install the collections in the same environment where you
installed Ansible and the other prerequisite software.
Starting in juniper.device Release 2.0.0, the
juniper.device collection includes the
juniper.device modules and the
junipernetworks.junos modules. You can install just the
juniper.device collection and use
juniper.device.module-name to
execute any module in either module set. If you previously used the
junipernetworks.junos modules, and you want to continue
using existing playbooks that reference
junipernetworks.junos.module-name,
then you must also install the junipernetworks.junos
collection.
We recommend that existing junipernetworks.junos collection
users install both collections in your Ansible for Junos OS environment.
To install the juniper.device collection and the
junipernetworks.junos collection:
Use the Ansible for Junos OS Docker Image
Docker is a software container platform that is used to package and run an
application and its dependencies in an isolated container. Juniper Networks
provides Docker
images with the Juniper Networks Ansible modules. The Docker image
includes Python 3 and Ansible. It also includes the latest versions of the
juniper.device collection, Junos PyEZ, and JSNAPy along
with any required dependencies. You can run the container in interactive mode or
use the container as an executable to run your playbooks.
To use the Ansible for Junos OS Docker image on your Ansible control node:
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.
juniper.device Release 2.0.0, we've
merged the Red Hat Ansible junipernetworks.junos modules into
the juniper.device collection.