Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


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 juniper.device collection going forward.

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 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 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:

Installing the juniper.device Collection and the Juniper.junos Role

Ansible control nodes running Ansible 2.9 or earlier only support installing the Juniper.junos role. On Ansible control nodes running Ansible 2.10 or later, you can install and use the juniper.device collection or the Juniper.junos role. However, we recommend migrating playbooks to use the collection.

  • To install the juniper.device collection from the Ansible Galaxy website, issue the ansible-galaxy collection install command and specify the juniper.device collection.
  • To install the Juniper.junos role from the Ansible Galaxy website, issue the ansible-galaxy install command and specify the Juniper.junos role.

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 juniper.device collection (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 playbooks.

To use the Ansible for Junos OS Docker image on your Ansible control node:

  1. Install Docker.

    See the Docker website at for instructions on installing and configuring Docker on your specific operating system.

  2. Download the juniper/pyez-ansible Docker image from Docker Hub.
    • To download the latest image, issue the following command:


      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.

  3. Run the container.

    For instructions on running the container, see the official usage examples at