facts¶
Retrieve facts from a Junos device
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:
junos-eznc >= 2.5.2
Python >= 3.5
Module-specific Options¶
The following options may be specified for this module:
parameter | type | required | default | choices | comments |
---|---|---|---|---|---|
config_format |
no | none |
|
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: 'Explicit host argument'
hosts: junos
connection: local
gather_facts: no
collections:
- juniper.device
tasks:
- name: "Get facts"
facts:
register: response
- name: Facts with login credentials
facts:
host: "10.x.x.x"
user: "user"
passwd: "user123"
port: "22"
- name: Facts in telnet mode
facts:
host: "10.x.x.x"
user: "user"
passwd: "user123"
port: "23"
mode: "telnet"
# 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: |
|
||||||||||||||||||||||||||||
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.
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.