netconf_get - Fetch configuration/state data from NETCONF enabled network devices.

New in version 2.6.

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 fetch configuration and state data from NETCONF enabled network devices.

Requirements

The below requirements are needed on the host that executes this module.

  • ncclient (>=v0.5.2)
  • jxmlease

Parameters

Parameter Choices/Defaults Comments
display
    Choices:
  • json
  • pretty
  • xml
Encoding scheme to use when serializing output from the device. The option json will serialize the output as JSON data. If the option value is json it requires jxmlease to be installed on control node. The option pretty is similar to received XML response but is using human readable format (spaces, new lines). The option value xml is similar to received XML response but removes all XML namespaces.
filter
This argument specifies the XML string which acts as a filter to restrict the portions of the data to be are retrieved from the remote device. If this option is not specified entire configuration or state data is returned in result depending on the value of source option. The filter value can be either XML string or XPath, if the filter is in XPath format the NETCONF server running on remote host should support xpath capability else it will result in an error.
lock
    Choices:
  • never
  • always
  • if-supported
Instructs the module to explicitly lock the datastore specified as source before fetching configuration and/or state information from remote host. If the value is never in that case the source datastore is never locked, if the value is if-supported the source datastore is locked only if the Netconf server running on remote host supports locking of that datastore, if the lock on source datastore is not supported module will report appropriate error before executing lock. If the value is always the lock operation on source datastore will always be executed irrespective if the remote host supports it or not, if it doesn't the module with fail will the execption message received from remote host and might vary based on the platform.
source
    Choices:
  • running
  • candidate
  • startup
This argument specifies the datastore from which configuration data should be fetched. Valid values are running, candidate and startup. If the source value is not set both configuration and state information are returned in response from running datastore.

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

Examples

- name: Get running configuration and state data
  netconf_get:

- name: Get configuration and state data from startup datastore
  netconf_get:
    source: startup

- name: Get system configuration data from running datastore state (junos)
  netconf_get:
    source: running
    filter: <configuration><system></system></configuration>

- name: Get configuration and state data in JSON format
  netconf_get:
    display: json

- name: get schema list using subtree w/ namespaces
  netconf_get:
    format: json
    filter: <netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"><schemas><schema/></schemas></netconf-state>
    lock: False

- name: get schema list using xpath
  netconf_get:
    format: json
    filter: /netconf-state/schemas/schema

- name: get interface confiugration with filter (iosxr)
  netconf_get:
    filter: <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg"></interface-configurations>

- name: Get system configuration data from running datastore state (sros)
  netconf_get:
    source: running
    filter: <state xmlns="urn:nokia.com:sros:ns:yang:sr:conf"/>
    lock: True

- name: Get state data (sros)
  netconf_get:
    filter: <state xmlns="urn:nokia.com:sros:ns:yang:sr:state"/>

Return Values

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

Key Returned Description
output
complex
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 retured as a string apart from low-level errors (such as action plugin).
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.

formatted_output

stdout
string
always apart from low-level errors (such as action plugin)
The raw XML string containing configuration or state data received from the underlying ncclient library.

Sample:
...
stdout_lines
list
always apart from low-level errors (such as action plugin)
The value of stdout split into a list

Sample:
['...', '...']


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as network which means that it is maintained by the Ansible Network Team. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Network Team, see here.

Support

For more information about Red Hat’s support of this module, please refer to this Knowledge Base article

Author

  • Ganesh Nalawade (@ganeshrn)
  • Sven Wisotzky (@wisotzky)

Hint

If you notice any issues in this documentation you can edit this document to improve it.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.6/modules/netconf_get_module.html