Fetch the device configuration and render it in JSON format defined by RFC7951
- The module will fetch the configuration data for a given YANG model and render it in JSON format (as per RFC 7951).
The below requirements are needed on the host that executes this module.
- ncclient (>=v0.5.2)
- pyang
- xsltproc
Note
- This module requires the NETCONF system service be enabled on the remote device being managed.
- This module supports the use of connection=ansible.netcommon.netconf
- To use this module xsltproc should be installed on control node
- name: fetch interface configuration and return it in JSON format
community.yang.get:
filter: |
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg"><interface-configuration>
</interface-configuration></interface-configurations>
file: "{{ playbook_dir }}/YangModels/yang/tree/master/vendor/cisco/xr/613/*.yang"
search_path: "{{ playbook_dir }}/YangModels/yang/tree/master/vendor/cisco/xr/613:{{ playbook_dir }}/pyang/modules"
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
json_data
dictionary
|
always |
The running configuration in json format
Sample:
{
"openconfig-interfaces:interfaces":
{
"interface": [{
"name" : "GigabitEthernet0/0/0/2",
"config" : {
"name" : "GigabitEthernet0/0/0/2",
"description": "configured by Ansible yang collection",
"mtu": 1024
}
}]
}
}
|
xml_data
string
|
always |
The running configuration in xml format
Sample:
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>GigabitEthernet0/0/0/2</interface-name>
<description>configured by Ansible yang collection</description>
<mtu>1024</mtu>
</interface-configuration>
</interface-configurations>
</data>
|
- Ganesh Nalawade (@ganeshrn)