Retrieve facts from a Junos device

New in version 2.0.0.


  • Retrieve facts from a Junos device using the PyEZ fact gathering system.
  • Also returns the committed configuration of the Junos device if the config_format option has a value other than none.


The following software packages must be installed on hosts that execute this module:

Module-specific Options

The following options may be specified for this module:

parameter type required default choices comments
no none
  • none
  • xml
  • set
  • text
  • json
The format of the configuration returned. The specified format must be supported by the target Junos device.
path no none
A path to a directory, on the Ansible control machine, where facts will be stored in a JSON file.
The resulting JSON file is saved in savedir/hostname-facts.json.
The savedir directory is the value of the savedir option.
The hostname-facts.json filename begins with the value of the hostname fact returned from the Junos device, which might be different than the value of the host option passed to the module.
If the value of the savedir option is none, the default, then facts are NOT saved to a file.


- name: Gather facts from Junos devices
  hosts: junos-all
  connection: local
  gather_facts: no
    - Juniper.junos
    - name: Gather Junos facts with no configuration

# Print a fact

# Using config_format option

# Print the config

# Using savedir option

# Print the saved JSON file

Return Values

name description returned type sample
Facts collected from the Junos device. This dictionary contains the keys listed in the contains section of this documentation PLUS all of the keys returned from PyEZ's fact gathering system. See PyEZ facts for a complete list of these keys and their meaning.
success complex
name description returned type sample
The mastership state of the Routing Engine to which Ansible is connected. true if the RE is the master Routing Engine. false if the RE is not the master Routing Engine.
success bool
The device's committed configuration, in the format specified by config_format, as a single multi-line string.
when config_format is not none. str
The name of the current Routing Engine to which Ansible is connected.
success str
Indicates if the device has more than one Routing Engine installed. Because Ansible does not allow keys to begin with a number, this fact is returned in place of PyEZ's 2RE fact.
success bool
Indicates if the device's state has changed. Since this module does not change the operational or configuration state of the device, the value is always set to false.
success bool False
Returned for backwards compatibility. Returns the same keys and values which are returned under ansible_facts.junos.
success dict
Indicates if the task failed.
always bool False



  • The NETCONF system service must be enabled on the target Junos device.


  • Juniper Networks - Stacy Smith (@stacywsmith)


This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.