ansible.netcommon.restconf_config module – Handles create, update, read and delete of configuration data on RESTCONF enabled devices.

Note

This module is part of the ansible.netcommon collection (version 3.1.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install ansible.netcommon.

To use it in a playbook, specify: ansible.netcommon.restconf_config.

New in version 1.0.0: of ansible.netcommon

Synopsis

  • RESTCONF is a standard mechanisms to allow web applications to configure and manage data. RESTCONF is a IETF standard and documented on RFC 8040.

  • This module allows the user to configure data on RESTCONF enabled devices.

Parameters

Parameter

Comments

content

string

The configuration data in format as specififed in format option. Required unless method is delete.

format

string

The format of the configuration provided as value of content. Accepted values are xml and json and the given configuration format should be supported by remote RESTCONF server.

Choices:

  • json ← (default)

  • xml

method

string

The RESTCONF method to manage the configuration change on device. The value post is used to create a data resource or invoke an operation resource, put is used to replace the target data resource, patch is used to modify the target resource, and delete is used to delete the target resource.

Choices:

  • post ← (default)

  • put

  • patch

  • delete

path

string / required

URI being used to execute API calls.

Notes

Note

  • This module requires the RESTCONF system service be enabled on the remote device being managed.

  • This module is supported with ansible_connection value of ansible.netcommon.httpapi and ansible_network_os value of ansible.netcommon.restconf.

  • This module is tested against Cisco IOSXE 16.12.02 version.

Examples

- name: create l3vpn services
  ansible.netcommon.restconf_config:
    path: /config/ietf-l3vpn-svc:l3vpn-svc/vpn-services
    content: |
      {
        "vpn-service":[
                        {
                          "vpn-id": "red_vpn2",
                          "customer-name": "blue",
                          "vpn-service-topology": "ietf-l3vpn-svc:any-to-any"
                        },
                        {
                          "vpn-id": "blue_vpn1",
                          "customer-name": "red",
                          "vpn-service-topology": "ietf-l3vpn-svc:any-to-any"
                        }
                      ]
       }

Return Values

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

Key

Description

candidate

dictionary

The configuration sent to the device.

Returned: When the method is not delete

Sample: “{\n \”vpn-service\”: [\n {\n \”customer-name\”: \”red\”,\n \”vpn-id\”: \”blue_vpn1\”,\n \”vpn-service-topology\”: \”ietf-l3vpn-svc:any-to-any\”\n }\n ]\n}\n”

running

dictionary

The current running configuration on the device.

Returned: When the method is not delete

Sample: “{\n \”vpn-service\”: [\n {\n \”vpn-id\”: \”red_vpn2\”,\n \”customer-name\”: \”blue\”,\n \”vpn-service-topology\”: \”ietf-l3vpn-svc:any-to-any\”\n },\n {\n \”vpn-id\”: \”blue_vpn1\”,\n \”customer-name\”: \”red\”,\n \”vpn-service-topology\”: \”ietf-l3vpn-svc:any-to-any\”\n }\n ]\n}\n”

Authors

  • Ganesh Nalawade (@ganeshrn)