juniper_junos_table

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

New in version 2.0.0.

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:

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
  • 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.
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
  roles:
    - Juniper.junos

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

    - name: Retrieve routes within 192.68.1/8
      juniper_junos_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
      juniper_junos_table:
        file: "fpc.yaml"
        path: "."
      register: response
    - name: Print response
      debug:
        var: response

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.

Author

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