07-06-2020 10:19 AM - edited 07-06-2020 10:56 AM
I’m running into a weird problem when attempting to create a template with the vrf. I tried both the current XR and XE neds. I think there may be a problem with the ansible nso_config module. It feels like there’s something with the empty dictionary at the end of “unicast”. I’ve tried using single and double quotes around and inside of {}. I even tried an empty value, a single and double quoted value and even null.
I get the same return error to ansible if I try to put anything in the VRF, such as NTP source, DNS source and etc.
Any ideas???
NSO Version 5.3.2.1, local install on a vagrant bento/ubuntu-18.04 box
The “api” variables:
--- url: http://172.28.128.2:8080/jsonrpc username: admin password: admin
Some info:
Works, but does not create the address families, they are commented out:
Vrf.yml:
- name: Build a VRF nso_config: url: "{{ api.url }}" username: "{{ api.username }}" password: "{{ api.password }}" data: tailf-ncs:devices: template: - name: vrf ned-id: # IOS XR Config - id: cisco-iosxr-cli-7.28:cisco-iosxr-cli-7.28 config: tailf-ned-cisco-ios-xr:vrf: vrf-list: - name: Mgmt-intf # address-family: # ipv4: # unicast: {} # ipv6: # unicast: {}
If you then uncomment the address families and re-run the playbook, it does work, but Ansible notes it as “ok”, so it does not push a change to NSO
If you try to run the play without any existing config:
Error, ansible error: fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "NSO get_schema returned JSON-RPC error: {'type': 'data.not_found', 'code': -32000, 'message': 'Data not found'}"}
Vrf.yml
- name: Build a VRF nso_config: url: "{{ api.url }}" username: "{{ api.username }}" password: "{{ api.password }}" data: tailf-ncs:devices: template: - name: vrf ned-id: # IOS XR Config - id: cisco-iosxr-cli-7.28:cisco-iosxr-cli-7.28 config: tailf-ned-cisco-ios-xr:vrf: vrf-list: - name: Mgmt-intf address-family: ipv4: unicast: {} ipv6: unicast: {}
If I create it via NSO, the template looks like this:
admin@ncs# show running-config devices template vrf devices template vrf ned-id cisco-iosxr-cli-7.28 config vrf vrf-list Mgmt-intf address-family ipv4 unicast address-family ipv6 unicast ! ! ! !
Output via JSON here:
{ "data": { "tailf-ncs:devices": { "template": [ { "name": "vrf", "ned-id": [ { "id": "cisco-iosxr-cli-7.28:cisco-iosxr-cli-7.28", "config": { "tailf-ned-cisco-ios-xr:vrf": { "vrf-list": [ { "name": "Mgmt-intf", "address-family": { "ipv4": { "unicast": { } }, "ipv6": { "unicast": { } } } } ] } } } ] } ] } } }
JSON to YAML python script output:
data: tailf-ncs:devices: template: - name: vrf ned-id: - config: tailf-ned-cisco-ios-xr:vrf: vrf-list: - address-family: ipv4: unicast: {} ipv6: unicast: {} name: Mgmt-intf id: cisco-iosxr-cli-7.28:cisco-iosxr-cli-7.28
I have fumbled thru the jsonrpc docs and think the commit is working fine using the API, it seems the problem is the implementation of the Ansible module?
First I started by deleting the vrf template from the CDB using traditional NSO cli.
After getting the login cookie, and a new “read_write” transaction handler, I posted some create methods:
{ "jsonrpc": "2.0", "id": 1, "method": "create", "params": { "th": 1, "path": "/devices/template{vrf}/ned-id{cisco-ios-cli-6.58:cisco-ios-cli-6.58}/config/ios:vrf/definition{Mgmt-intf}/address-family/ipv4" } }
Repeat for these paths (used “show running-config devices template vrf | display keypath” to get the syntax):
/devices/template{vrf}/ned-id{cisco-ios-cli-6.58:cisco-ios-cli-6.58}/config/ios:vrf/definition{Mgmt-intf}/address-family/ipv4
/devices/template{vrf}/ned-id{cisco-ios-cli-6.58:cisco-ios-cli-6.58}/config/ios:vrf/definition{Mgmt-intf}/address-family/ipv6
/devices/template{vrf}/ned-id{cisco-iosxr-cli-7.28:cisco-iosxr-cli-7.28}/config/cisco-ios-xr:vrf/vrf-list{Mgmt-intf}/address-family/ipv4/unicast
/devices/template{vrf}/ned-id{cisco-iosxr-cli-7.28:cisco-iosxr-cli-7.28}/config/cisco-ios-xr:vrf/vrf-list{Mgmt-intf}/address-family/ipv6/unicast
Then did validate_commit followed by commit methods:
Result:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }
Afterwards did:
POST:
{ "jsonrpc": "2.0", "id": 1, "method": "show_config", "params": { "th": 2, "path": "/devices/template{vrf}", "result_as": "json" } }
Result:
{ "jsonrpc": "2.0", "result": { "data": { "tailf-ncs:devices": { "template": [ { "name": "vrf", "ned-id": [ { "id": "cisco-ios-cli-6.58:cisco-ios-cli-6.58", "config": { "tailf-ned-cisco-ios:vrf": { "definition": [ { "name": "Mgmt-intf", "address-family": { "ipv4": {}, "ipv6": {} } } ] } } }, { "id": "cisco-iosxr-cli-7.28:cisco-iosxr-cli-7.28", "config": { "tailf-ned-cisco-ios-xr:vrf": { "vrf-list": [ { "name": "Mgmt-intf", "address-family": { "ipv4": { "unicast": {} }, "ipv6": { "unicast": {} } } } ] } } } ] } ] } } }, "id": 1 }
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: