cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
251
Views
1
Helpful
4
Replies

Cisco Catalyst 9300 Wrap CLI in XML for NETCONF Transport

caesarkrit
Level 1
Level 1

Hi,

My current Cisco Lab environment details are as follows:
Cisco IOS XE Software, Version 17.12.04
Cisco IOS Software [Dublin], Catalyst L3 Switch Software (CAT9K_IOSXE)

My current Lab structure is as follows:

I use a linux system that runs Ansible in a virtual Env.

I have a YAML files called ntp.yml

# Description: Defines NTP servers for time synchronization
---
ntp:
  servers:
    - server: 10.0.0.10        # Primary NTP server
    - server: 10.0.0.12        # Secondary NTP server
    - server: time.stjude.org  # Tertiary NTP server
      vrf: Mgmt-vrf           # Using management VRF
 
I have XML that reads the configuration data:
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<ntp operation="replace">
<server xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-ntp">
{% if ntp.servers is defined %}
{% for server in ntp.servers %}
{% if server.vrf is defined %}
<vrf>
<name>{{ server.vrf }}</name>
<server-list>
<ip-address>{{ server.server }}</ip-address>
</server-list>
</vrf>
{% else %}
<server-list>
<ip-address>{{ server.server }}</ip-address>
</server-list>
{% endif %}
{% endfor %}
{% endif %}
</server>
</ntp>
</native>
</config>


I then have a task file in my ansible role that is able to read the configuration and send it via NETCONF to the switch to modify the configuration, it all works great. The problem I have found is that writing XML for each block of configurations(NTP, SNMP, Spanning_tree, VTY, Etc) is not really scalable for me or the network engineers. I was looking at wrapping CLI commands in the XML instead of going pure XML which will make things easier. I have been trying to figure this out for a while and cant seem to get a basic example going to being able to convert my current XML to wrap in CLI. Does anyone have experience in doing this? is it possible? do you suggest a specific tutorial or piece of documentation to do this? and is it well supported? just wanted to get the ins/outs of this and if it might be able to replace my long list of XML writings. Feel free to ask for code files or project structure.
 
Thanks
1 Accepted Solution

Accepted Solutions