Ansible for Junos OS Server Requirements
Juniper Networks supports using Ansible to manage devices running Junos OS and provides Ansible modules that you can use to perform operational and configuration tasks on the devices. The Juniper Networks modules are distributed through the following Ansible collections and roles that are hosted on the Ansible Galaxy website:
Ansible supports Ansible Content Collections, or collections,
starting in Ansible 2.10. With the introduction of the
juniper.device collection, the modules in the
Juniper.junos role were duplicated under new names
in the collection and thus retain the same functionality and parameters
as the original modules, with the exception of the
provider parameter. Although the
Juniper.junos role can coexist with the
juniper.device collection and will work in later releases, new features are only
being added to the
You install Ansible on a control node with a Unix-like operating system. You can install Ansible and the Juniper Networks collection or role directly on the control node or you can use 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 manually install Ansible, the
juniper.device collection or
Juniper.junos role, and
any prerequisite software on the Ansible control node, see the following
To use the Ansible for Junos OS Docker image, see the following section:
Before you install the Juniper Networks
juniper.device collection or
Juniper.junos role and begin using Ansible to manage devices running Junos OS,
ensure that the Ansible control node has the following software installed:
Python 3.7 or later (Recommended version is Python 3.8)
Ansible 2.5 or later (Ansible 2.10 or later is required to use Ansible collections)
Junos PyEZ (
junos-eznc) Release 2.6.0 or later.
For installation instructions and current information about Junos PyEZ, see:
xmltodictPython module (required for the
Junos Snapshot Administrator in Python (JSNAPy) Release 1.3.6 or later (required to use the
For installation instructions and current information about JSNAPy, see:
Installing the juniper.device Collection and the Juniper.junos Role
Ansible control nodes running Ansible 2.9 or earlier only support
Juniper.junos role. On Ansible
control nodes running Ansible 2.10 or later, you can install and use
juniper.device collection or the
Juniper.junos role. However, we recommend migrating
playbooks to use the collection.
- To install the
juniper.devicecollection from the Ansible Galaxy website, issue the
ansible-galaxy collection installcommand and specify the
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.0' to '/home/user/.ansible/collections/ansible_collections/juniper/device' Downloading https://galaxy.ansible.com/download/juniper-device-1.0.0.tar.gz to /home/user/.ansible/tmp/ansible-local-23916uzdfbjsk/tmp4nhxnw3v juniper.device (1.0.0) was installed successfully
- To install the
Juniper.junosrole from the Ansible Galaxy website, issue the
ansible-galaxy installcommand and specify the
user@ansible-cn:~$ sudo ansible-galaxy install Juniper.junos
- downloading role 'junos', owned by Juniper - downloading role from https://github.com/Juniper/ansible-junos-stdlib/archive/2.4.3.tar.gz - extracting Juniper.junos to /etc/ansible/roles/Juniper.junos - Juniper.junos (2.4.3) was installed successfully
Using 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.junos role and the
(depending on the release), 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
To use the Ansible for Junos OS Docker image on your Ansible control node:
- Install Docker.
See the Docker website at https://www.docker.com for instructions on installing and configuring Docker on your specific operating system.
- Download the juniper/pyez-ansible Docker image from Docker Hub.
To download the latest image, issue the following command:user@host:~$ docker pull juniper/pyez-ansible
The latest Ansible for Junos OS Docker image is built using the most recently committed code in the Juniper/ansible-junos-stdlib GitHub source repository, which is under active development and might not be stable.
To download a specific image, append the appropriate release tag to the image name, for example, 2.0.0.user@host:~$ docker pull juniper/pyez-ansible:tag
- Run the container.
For instructions on running the container, see the official usage examples at https://github.com/Juniper/ansible-junos-stdlib/blob/master/README.md#docker.