juniper_junos_facts

Retrieve facts from a Junos device

New in version 2.0.0.

Synopsis

  • 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.

Requirements

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
config_format
no none
  • none
  • xml
  • set
  • text
  • json
The format of the configuration returned. The specified format must be supported by the target Junos device.
savedir
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.

Examples

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

# 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
ansible_facts.junos
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
contains:
name description returned type sample
master_state
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
config
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
re_name
The name of the current Routing Engine to which Ansible is connected.
success str
has_2RE
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
changed
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
facts
Returned for backwards compatibility. Returns the same keys and values which are returned under ansible_facts.junos.
success dict
failed
Indicates if the task failed.
always bool False


Notes

Note

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

Author

  • Juniper Networks - Stacy Smith (@stacywsmith)

Status

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