ansible.builtin.netconf_rpc (v2.9.17) — module

Execute operations on NETCONF enabled network devices.

| "added in version" 2.6 of ansible.builtin"

Authors: Ganesh Nalawade (@ganeshrn), Sven Wisotzky (@wisotzky)

preview | supported by network

Install Ansible via pip

Install with pip install ansible==2.9.17

Description

NETCONF is a network management protocol developed and standardized by the IETF. It is documented in RFC 6241.

This module allows the user to execute NETCONF RPC requests as defined by IETF RFC standards as well as proprietary requests.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: lock candidate
  netconf_rpc:
    rpc: lock
    content:
      target:
        candidate:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: unlock candidate
  netconf_rpc:
    rpc: unlock
    xmlns: "urn:ietf:params:xml:ns:netconf:base:1.0"
    content: "{'target': {'candidate': None}}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: discard changes
  netconf_rpc:
    rpc: discard-changes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: get-schema
  netconf_rpc:
    rpc: get-schema
    xmlns: urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring
    content:
      identifier: ietf-netconf
      version: "2011-06-01"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: copy running to startup
  netconf_rpc:
    rpc: copy-config
    content:
      source:
        running:
      target:
        startup:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: get schema list with JSON output
  netconf_rpc:
    rpc: get
    content: |
      <filter>
        <netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
          <schemas/>
        </netconf-state>
      </filter>
    display: json
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: get schema using XML request
  netconf_rpc:
    rpc: "get-schema"
    xmlns: "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"
    content: |
      <identifier>ietf-netconf-monitoring</identifier>
      <version>2010-10-04</version>
    display: json

Inputs

    
rpc:
    description:
    - This argument specifies the request (name of the operation) to be executed on the
      remote NETCONF enabled device.

xmlns:
    description:
    - NETCONF operations not defined in rfc6241 typically require the appropriate XML
      namespace to be set. In the case the I(request) option is not already provided in
      XML format, the namespace can be defined by the I(xmlns) option.

content:
    description:
    - This argument specifies the optional request content (all RPC attributes). The I(content)
      value can either be provided as XML formatted string or as dictionary.

display:
    choices:
    - json
    - pretty
    - xml
    description:
    - Encoding scheme to use when serializing output from the device. The option I(json)
      will serialize the output as JSON data. If the option value is I(json) it requires
      jxmlease to be installed on control node. The option I(pretty) is similar to received
      XML response but is using human readable format (spaces, new lines). The option
      value I(xml) is similar to received XML response but removes all XML namespaces.

Outputs

output:
  contains:
    formatted_output:
    - Contains formatted response received from remote host as per the value in display
      format.
  description: Based on the value of display option will return either the set of
    transformed XML to JSON format from the RPC response with type dict or pretty
    XML string response (human-readable) or response with namespace removed from XML
    string.
  returned: when the display format is selected as JSON it is returned as dict type,
    if the display format is xml or pretty pretty it is returned as a string apart
    from low-level errors (such as action plugin).
  type: complex
stdout:
  description: The raw XML string containing configuration or state data received
    from the underlying ncclient library.
  returned: always apart from low-level errors (such as action plugin)
  sample: '...'
  type: str
stdout_lines:
  description: The value of stdout split into a list
  returned: always apart from low-level errors (such as action plugin)
  sample:
  - '...'
  - '...'
  type: list