cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
359
Views
0
Helpful
3
Replies

Netconf_get in ansible is returning an empty xml structure

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\"/>",

125
"stdout_lines": [126
"<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"
127
]128
}
 
If I don't set a filter, I get a timeout error. 
 
If I use the same filter in a python script, I get the configuration from the device.
 
any idea why this is not working with ansible? I am using an awx controller in version 22.5
 
Thanks! 
 

 

 

 

 

3 Replies 3

balaji.bandi
Hall of Fame
Hall of Fame

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

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Hi,

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!

Glad to know all working, we mark as resolved now.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help