table¶
Retrieve data from a Junos device using a PyEZ table/view
Synopsis¶
Retrieve data from a Junos device using PyEZ’s operational table/views. This module may be used with the tables/views which are included in the PyEZ distribution or it may be used with user-defined tables/views.
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 |
---|---|---|---|---|---|
file |
path | yes | none |
Name of the YAML file, relative to the path option, that contains the table/view definition. The file name must end with the
.yml or .yaml extension. |
|
kwargs |
dict | no | none |
Optional keyword arguments and values to the table's get() method. The value of this option is a dictionary of keywords and values which are used to refine the data return from performing a get() on the table. The exact keywords and values which are supported are specific to the table's definition and the underlying RPC which the table invokes.
aliases: kwarg, args, arg
|
|
path |
path | no | op directory in jnpr.junos.op |
The directory containing the YAML table/view definition file as specified by the file option. The default value is the
op directory in jnpr.junos.op . This is the directory containing the table/view definitions which are included in the PyEZ distribution.aliases: directory, dir
|
|
response_type |
str | no | list_of_dicts |
|
Defines the format of data returned by the module. See RETURN. The value of the resource key in the module's response is either a list of dictionaries
list_of_dicts or PyEZ's native return format juniper_items . Because Ansible module's may only return JSON data, PyEZ's native return format juniper_items is translated into a list of lists. |
table |
str | no | The name of the table defined in the file option. |
Name of the PyEZ table used to retrieve data. If not specified, defaults to the name of the table defined in the file option. Any table names in file which begin with
_ are ignored. If more than one table is defined in file, the module fails with an error message. In this case, you must manually specify the name of the table by setting this option. |
Examples¶
---
- name: Retrieve data from a Junos device using a PyEZ table/view.
hosts: junos-all
connection: local
gather_facts: no
collections:
- juniper.device
tasks:
- name: Retrieve LLDP Neighbor Information Using PyEZ-included Table
table:
file: "lldp.yml"
register: response
- name: Print response
debug:
var: response
- name: Retrieve routes within 192.68.1/8
table:
file: "routes.yml"
table: "RouteTable"
kwargs:
destination: "192.68.1.0/8"
response_type: "juniper_items"
register: response
- name: Print response
debug:
var: response
- name: Retrieve from custom table in playbook directory
table:
file: "fpc.yaml"
path: "."
register: response
- name: Print response
debug:
var: response
Return Values¶
name | description | returned | type | sample |
---|---|---|---|---|
changed |
Indicates if the device's configuration 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 | |
failed |
Indicates if the task failed.
|
always | bool | |
msg |
A human-readable message indicating a summary of the result.
|
always | str | |
resource |
The items retrieved by the table/view.
|
success | list of dicts if response_type is list_of_dicts or list of lists if respsonse_type is juniper_items . |
# when response_type == 'list_of_dicts' [ { "local_int": "ge-0/0/3", "local_parent": "-", "remote_chassis_id": "00:05:86:08:d4:c0", "remote_port_desc": null, "remote_port_id": "ge-0/0/0", "remote_sysname": "r5", "remote_type": "Mac address" }, { "local_int": "ge-0/0/0", "local_parent": "-", "remote_chassis_id": "00:05:86:18:f3:c0", "remote_port_desc": null, "remote_port_id": "ge-0/0/2", "remote_sysname": "r4", "remote_type": "Mac address" } ] # when response_type == 'juniper_items' [ [ "ge-0/0/3", [ [ "local_parent", "-" ], [ "remote_port_id", "ge-0/0/0" ], [ "remote_chassis_id", "00:05:86:08:d4:c0" ], [ "remote_port_desc", null ], [ "remote_type", "Mac address" ], [ "local_int", "ge-0/0/3" ], [ "remote_sysname", "r5" ] ] ], [ "ge-0/0/0", [ [ "local_parent", "-" ], [ "remote_port_id", "ge-0/0/2" ], [ "remote_chassis_id", "00:05:86:18:f3:c0" ], [ "remote_port_desc", null ], [ "remote_type", "Mac address" ], [ "local_int", "ge-0/0/0" ], [ "remote_sysname", "r4" ] ] ] ] |
Notes¶
Note
This module only works with operational tables/views; it does not work with configuration tables/views.
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.