Ansible for Junos OS Server Requirements
Juniper Networks supports using Ansible to manage Junos devices and provides Ansible modules that you can use to perform operational and configuration tasks on the devices. Ansible supports Ansible Content Collections, or collections, starting in Ansible 2.10. The Juniper Networks modules are distributed through the following Ansible collection, which is hosted on the Ansible Galaxy website:
-
juniper.device
collection
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
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 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:
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.
-
Python 3.8 or later
-
Ansible 2.10 or later
-
Junos PyEZ (
junos-eznc
) Release 2.6.0 or later.For installation instructions and current information about Junos PyEZ, see:
-
The
jxmlease
Python module -
The
xmltodict
Python module -
Junos Snapshot Administrator in Python (JSNAPy) Release 1.3.6 or later (required to use the
jsnapy
module).For installation instructions and current information about JSNAPy, see:
Install the juniper.device Collection
On Ansible control nodes running Ansible 2.10 or later, you can install the
juniper.device
collection from the Ansible Galaxy
website. Install the collection in the same environment where you installed
Ansible and the other prerequisite software.
To install the juniper.device
collection:
ansible-galaxy collection install
command and
specify the juniper.device
collection.
user@ansible-cn:~$ ansible-galaxy collection install juniper.device Starting galaxy collection install process Process install dependency map Starting collection install process Installing 'juniper.device:1.0.6' to '/home/user/.ansible/collections/ansible_collections/juniper/device' Downloading https://galaxy.ansible.com/download/juniper-device-1.0.6.tar.gz to /home/user/.ansible/tmp/ansible-local-23916uzdfbjsk/tmp4nhxnw3v juniper.device (1.0.6) was installed successfully
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, which are automatically built for every new release of the
Juniper Networks modules. The Docker image includes Python 3, Ansible, Junos
PyEZ, the juniper.device
collection, and Junos Snapshot
Administrator in Python 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: