Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Last active July 9, 2021 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeitounator/8452c2a20860c0e924bd3ed9ff1af4e0 to your computer and use it in GitHub Desktop.
Save zeitounator/8452c2a20860c0e924bd3ed9ff1af4e0 to your computer and use it in GitHub Desktop.
---
vars:
ntp_peers:
address: "{{ item.address }}"
reachability: "{{ item.reachability}}"
keys:
result:
value: "{{ ntp_peers }}"
top: '{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}ntp/{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}nodes/{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}node/{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}associations/{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}peer-summary-info/{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}peer-info-common'
items:
address: "{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}address"
reachability: "{http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper}reachability"
---
- hosts: localhost
gather_facts: false
vars:
NTP_STATUS:
stdout : |-
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<ntp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-oper">
<nodes>
<node>
<node>0/0/CPU0</node>
<associations>
<is-ntp-enabled>true</is-ntp-enabled>
<sys-leap>ntp-leap-no-warning</sys-leap>
<peer-summary-info>
<peer-info-common>
<host-mode>ntp-mode-client</host-mode>
<is-configured>true</is-configured>
<address>10.1.1.1</address>
<reachability>0</reachability>
</peer-info-common>
<time-since>-1</time-since>
</peer-summary-info>
<peer-summary-info>
<peer-info-common>
<host-mode>ntp-mode-client</host-mode>
<is-configured>true</is-configured>
<address>172.16.252.29</address>
<reachability>255</reachability>
</peer-info-common>
<time-since>991</time-since>
</peer-summary-info>
</associations>
</node>
</nodes>
</ntp>
</data>
parsed_ntp_data: "{{ NTP_STATUS.stdout | parse_xml('specs/iosxr_ntp.yaml') }}"
tasks:
- name: Show entire list
debug:
var: parsed_ntp_data
PLAY [localhost] ***********************************************************************************************************************************************************************************************************************
TASK [Show entire list] ****************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"parsed_ntp_data": {
"result": [
{
"address": "10.1.1.1",
"reachability": 0
},
{
"address": "172.16.252.29",
"reachability": 255
}
]
}
}
PLAY RECAP *****************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment