showldp-playbook.yml
The playbook below shows how to check the runtime status of the LDP protocol through the show ldp session command. It is assumed that the neighboring nodes are configured accordingly to get the LDP session up and running:
osboxes@osboxes:~/playbooks$ cat showldp-playbook.yml
---
- hosts: ocnos
gather_facts: no
tasks:
- name: show LDP config ocnos
cli_command:
command: show ldp session
register: result
- name: debug
debug:
msg: "{{ result.stdout_lines }}"
osboxes@osboxes:~/playbooks$
When you run this playbook, the example below is its output. Parsing of the show command output needs to be done to determine if the runtime status of the protocol is correct:
(ansible) osboxes@osboxes:~/playbooks$ ansible-playbook showldp-playbook.yml
PLAY [ocnos] ******************************************************************************************************
TASK [show LDP config ocnos] **************************************************************************************
ok: [sw2]
TASK [debug] ******************************************************************************************************
ok: [sw2] => {
"msg": [
"Peer IP Address IF Name My Role State KeepAlive UpTime",
"3.3.3.3 eth2 Passive OPERATIONAL 30 03:58:20",
"1.1.1.1 eth1 Active OPERATIONAL 30 03:58:20"
]
}
PLAY RECAP ********************************************************************************************************
sw2 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
(ansible) osboxes@osboxes:~/playbooks$
Last modified date: 06/08/2023