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\"/>",
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
10-13-2023 05:08 AM
10-13-2023 06:57 AM
Glad to know all working, we mark as resolved now.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide