junipernetworks.junos.junos_rpc (8.0.0) — module

Runs an arbitrary RPC over NetConf on an Juniper JUNOS device

| "added in version" 1.0.0 of junipernetworks.junos"

Authors: Peter Sprygada (@privateip)

Install collection

Install with ansible-galaxy collection install junipernetworks.junos:==8.0.0


Add to requirements.yml

  collections:
    - name: junipernetworks.junos
      version: 8.0.0

Description

Sends a request to the remote device running JUNOS to execute the specified RPC using the NetConf transport. The reply is then returned to the playbook in the C(xml) key. If an alternate output format is requested, the reply is transformed to the requested output.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: collect interface information using rpc
  junipernetworks.junos.junos_rpc:
    rpc: get-interface-information
    args:
      interface-name: em0
      media: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: get system information
  junipernetworks.junos.junos_rpc:
    rpc: get-system-information
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: load configuration
  junipernetworks.junos.junos_rpc:
    rpc: load-configuration
    attrs:
      action: override
      url: /tmp/config.conf

Inputs

    
rpc:
    description:
    - The C(rpc) argument specifies the RPC call to send to the remote devices to be executed.  The
      RPC Reply message is parsed and the contents are returned to the playbook.
    required: true
    type: str

args:
    description:
    - The C(args) argument provides a set of arguments for the RPC call and are encoded
      in the request message.  This argument accepts a set of key=value arguments.
    type: dict

attrs:
    description:
    - The C(attrs) arguments defines a list of attributes and their values to set for
      the RPC call. This accepts a dictionary of key-values.
    type: dict

output:
    choices:
    - xml
    - json
    - text
    default: xml
    description:
    - The C(output) argument specifies the desired output of the return data.  This argument
      accepts one of C(xml), C(text), or C(json).  For C(json), the JUNOS device must
      be running a version of software that supports native JSON output.
    type: str

Outputs

output:
  description: The rpc rely converted to the output format.
  returned: always
  type: str
output_lines:
  description: The text output split into lines for readability.
  returned: always
  type: list
xml:
  description: The xml return string from the rpc request.
  returned: always
  type: str