Skip to content

Latest commit

 

History

History
241 lines (207 loc) · 9.57 KB

ansible.netcommon.grpc_get_module.rst

File metadata and controls

241 lines (207 loc) · 9.57 KB

ansible.netcommon.grpc_get

Fetch configuration/state data from gRPC enabled target hosts.

Version added: 3.1.0

  • gRPC is a high performance, open-source universal RPC framework.
  • This module allows the user to fetch configuration and state data from gRPC enabled devices.

The below requirements are needed on the host that executes this module.

  • grpcio
  • protobuf
Parameter Choices/Defaults Comments
command
string
The option specifies the command to be executed on the target host and return the response in result. This option is supported if the gRPC target host supports executing CLI command over the gRPC connection.
data_type
string
The type of data that should be fetched from the target host. The value depends on the capability of the gRPC server running on target host. The values can be config, oper etc. based on what is supported by the gRPC server. By default it will return both configuration and operational state data in response.
display
string
Encoding scheme to use when serializing output from the device. The encoding scheme value depends on the capability of the gRPC server running on the target host. The values can be json, text etc.
section
string
This option specifies the string which acts as a filter to restrict the portions of the data to be retrieved from the target host device. If this option is not specified the entire configuration or state data is returned in response provided it is supported by target host.

aliases: filter

Note

  • This module requires the gRPC system service be enabled on the target host being managed.
  • This module supports the use of connection=ansible.netcommon.grpc.
  • This module requires the value of 'ansible_network_os or grpc_type' configuration option (refer ansible.netcommon.grpc connection plugin documentation) be defined as an inventory variable.
  • Tested against iosxrv 9k version 6.1.2.
- name: Get bgp configuration data
  grpc_get:
    section:
      Cisco-IOS-XR-ip-static-cfg:router-static:
        - null
- name: run cli command
  grpc_get:
    command: "show version"
    display: text

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
output
list
when the device response is valid JSON
A dictionary representing a JSON-formatted response, if the response is a valid json string

Sample:
[{ "Cisco-IOS-XR-ip-static-cfg:router-static": { "default-vrf": { "address-family": { "vrfipv4": { "vrf-unicast": { "vrf-prefixes": { "vrf-prefix": [ { "prefix": "0.0.0.0", "prefix-length": 0, "vrf-route": { "vrf-next-hop-table": { "vrf-next-hop-interface-name-next-hop-address": [ { "interface-name": "MgmtEth0/RP0/CPU0/0", "next-hop-address": "10.0.2.2" } ] } } } ] } } } } } } }]
stdout
string
always apart from low-level errors (such as action plugin)
The raw string containing configuration or state data received from the gRPC server.

Sample:
...
stdout_lines
list
always apart from low-level errors (such as action plugin)
The value of stdout split into a list

Sample:
['...', '...']


Authors

  • Ganesh Nalawade (@ganeshrn)
  • Gomathi Selvi S (@GomathiselviS)