netconf_rpc¶
Collection Note
This module is part of the ansible.netcommon collection. To install the collection, use:
Added in version1.0.0.
You need further requirements to be able to use this module, see the Requirements section for details.
Synopsis¶
- 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¶
The following Python packages are needed on the host that executes this module:
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| content str |
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 str |
Choices: json, pretty, xml | 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. |
| rpc str required |
This argument specifies the request (name of the operation) to be executed on the remote NETCONF enabled device. | |
| xmlns str |
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. |
Notes¶
Note
- This module requires the NETCONF system service be enabled on the remote device being managed.
- This module supports the use of connection=netconf
- To execute C(get-config), C(get) or C(edit-config) requests it is recommended to use the Ansible I(netconf_get) and I(netconf_config) modules.
- This module is supported on C(ansible_network_os) network platforms. See the :ref:
Network Platform Options <platform_options>for details.
Examples¶
- name: lock candidate
ansible.netcommon.netconf_rpc:
rpc: lock
content:
target:
candidate:
- name: unlock candidate
ansible.netcommon.netconf_rpc:
rpc: unlock
xmlns: urn:ietf:params:xml:ns:netconf:base:1.0
content: "{'target': {'candidate': None}}"
- name: discard changes
ansible.netcommon.netconf_rpc:
rpc: discard-changes
- name: get-schema
ansible.netcommon.netconf_rpc:
rpc: get-schema
xmlns: urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring
content:
identifier: ietf-netconf
version: '2011-06-01'
- name: copy running to startup
ansible.netcommon.netconf_rpc:
rpc: copy-config
content:
source:
running:
target:
startup:
- name: get schema list with JSON output
ansible.netcommon.netconf_rpc:
rpc: get
content: |
<filter>
<netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<schemas/>
</netconf-state>
</filter>
display: json
- name: get schema using XML request
ansible.netcommon.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
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| output | complex | 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. | 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). |
| stdout | str | The raw XML string containing configuration or state data received from the underlying ncclient library. | always apart from low-level errors (such as action plugin) |
| stdout_lines | list | The value of stdout split into a list | always apart from low-level errors (such as action plugin) |
Authors¶
- Ganesh Nalawade (@ganeshrn)
- Sven Wisotzky (@wisotzky)