Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Understanding Ansible for Junos OS

SUMMARY You can use Ansible to deploy and manage Junos devices.

Ansible for Junos OS Overview

Ansible is an IT automation framework that is used for infrastructure configuration management. Ansible supports automating the network infrastructure in addition to the compute and cloud infrastructure, and Juniper Networks supports using Ansible to manage Junos devices. You can use Ansible to perform operational and configuration tasks on Junos devices, including retrieving information, managing the configuration, installing and upgrading Junos OS, and resetting, rebooting, or shutting down managed devices.

Ansible comes in several varieties. You can use the following applications to manage Junos devices:

  • Ansible Core—Free, open-source, base version of Ansible

  • Red Hat Ansible Tower—Commercial application that is a superset of Ansible Core with additional features such as a visual dashboard, role-based access control, job scheduling, and graphical inventory management

  • AWX—Open-source upstream project for Ansible Tower

Ansible uses a client-server architecture. You install the Ansible software on the control node, which is a Unix-like system that performs operations on one or more managed nodes. Ansible uses an agentless architecture and thus does not require installing any Ansible-specific software on the managed devices. Although Ansible typically requires Python on the managed nodes, it is not required to manage Junos devices. Instead, Ansible for Junos OS requires all tasks to run locally on the Ansible control node and uses the Junos XML API over NETCONF to interface with Junos devices.

Ansible typically uses a push model in which the server sends state information to the managed nodes on demand. Ansible modules, which are discrete units of code, perform the requested functions on a node. The managed node executes the job and returns the result to the server. In general, Ansible modules are idempotent such that executing the same playbook or operation multiple times yields the same result, because the modules only apply a change if it’s required.

Juniper Networks and Ansible provide modules that enable you to manage Junos devices. The Juniper Networks modules are distributed through collections or roles, depending on the Ansible release. For more information about the available collections, roles, and modules, see Understanding the Ansible for Junos OS Collections, Roles, and Modules.

Ansible is written in Python, but it uses simple YAML syntax to express automation jobs. Thus, Ansible users can get started quickly, because they do not require extensive knowledge of Python to use Ansible. Ansible also leverages the Jinja2 templating language to enable dynamic expressions and access to variables.

Benefits of Ansible and Ansible for Junos OS

  • Use a simple, easy-to-learn syntax

  • Accelerate the time to deploy new network devices and applications

  • Provide an efficient and scalable solution for managing large numbers of devices

  • Increase operational efficiency by automating tasks and reducing the manual configuration and management of devices

  • Minimize risk and errors through standardization

  • Improve change management processes

  • Use an agentless architecture

Additional Resources

This documentation assumes that the reader is familiar with the Ansible framework. Table 1 provides resources for using Ansible to manage Junos devices.

Table 1: Ansible for Junos OS Resources

Resource

Description

URL

Ansible for Junos OS documentation

Documentation detailing how to use Ansible to manage Junos devices.

https://www.juniper.net/documentation/product/en_US/ansible-for-junos-os

Ansible for Junos OS modules overview

Documentation that outlines the different modules available for managing Junos devices.

Understanding the Ansible for Junos OS Collections, Roles, and Modules

Ansible Galaxy

Ansible Galaxy website and Juniper Networks Ansible Galaxy content

https://galaxy.ansible.com

https://galaxy.ansible.com/ui/namespaces/juniper/

Ansible website and documentation

Official Ansible website and documentation.

https://www.ansible.com

https://docs.ansible.com/

GitHub repository

Public repository for the Ansible for Junos OS project. This repository includes the most current source code, installation instructions, and release note summaries for all releases.

https://github.com/Juniper/ansible-junos-stdlib/

Google Groups forum

Forum that addresses questions and provides general support for Ansible for Junos OS.

http://groups.google.com/group/junos-python-ez

Juniper Networks juniper.device collection

Download site, API reference documentation, and sample playbooks for the Juniper Networks juniper.device collection.

https://galaxy.ansible.com/ui/repo/published/juniper/device/

https://ansible-juniper-collection.readthedocs.io/en/latest/

https://github.com/Juniper/ansible-junos-stdlib/tree/master/Samples

Juniper Networks Juniper.junos role

Download site and API reference documentation for the Juniper Networks Juniper.junos role.

https://galaxy.ansible.com/ui/standalone/roles/juniper/junos/

https://junos-ansible-modules.readthedocs.io/en/latest/