Retrieve data from a Junos device using a PyEZ table/view

New in version 2.0.0.


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


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
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.
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 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
str no list_of_dicts
  • list_of_dicts
  • juniper_items
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.
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.


- name: Retrieve data from a Junos device using a PyEZ table/view.
  hosts: junos-all
  connection: local
  gather_facts: no
    - Juniper.junos

    - name: Retrieve LLDP Neighbor Information Using PyEZ-included Table
        file: "lldp.yml"
      register: response
    - name: Print response
        var: response

    - name: Retrieve routes within 192.68.1/8
        file: "routes.yml"
        table: "RouteTable"
          destination: ""
        response_type: "juniper_items"
      register: response
    - name: Print response
        var: response

    - name: Retrieve from custom table in playbook directory
        file: "fpc.yaml"
        path: "."
      register: response
    - name: Print response
        var: response

Return Values

name description returned type sample
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
Indicates if the task failed.
always bool
A human-readable message indicating a summary of the result.
always str
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" ] ] ] ]



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


  • Jason Edelman (@jedelman8)
  • Updated by 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.