Netconf_get in ansible is returning an empty xml structure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 04:02 AM
Hi,
I'm trying to get the configuration of an ISR1121 (ios-xe) in version 17.5 through an ansible playbook and the netconf_get module.
Here is the role I use:
- name: Get configuration and state data in JSON format netconf_get: display: json filter: | <filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"/> </filter> register: config - name: Parse and display interface state debug: var: config
This returns an empty xml structure:
"stdout": "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>",
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 04:25 AM
I have tested Long back as per my documentation below my YAML file
on your YAML File i dont see the Hosts and connection type ? here is my example :
hosts: BB-ROUTER
connection: netconf
tasks:
- name: Get Interface Config
netconf_get:
source: running
filter: |
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<interface>
<GigabitEthernet>
<name>1</name>
</GigabitEthernet>
</interface>
</native>
register: config
- name: Write Config To File
copy:
content: "{{ config['stdout'] }}"
dest: ./configs/{{ inventory_hostname }}-Interface-config.xml
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 05:08 AM
Thanks to your exemple I realized that the element is not needed
in the netconf_get. I removed them and it is now working
thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 06:57 AM
Glad to know all working, we mark as resolved now.
