Created
April 11, 2018 15:03
-
-
Save ericpulvino/37d4ced97f7ca7195c393c030f4c0263 to your computer and use it in GitHub Desktop.
LLDP Interface Description Playbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(eric@xenial3)-(09:27 PM Sun Dec 10)-> | |
-(17 files, 344Kb)--> cat ./test.yml | |
- name: LLDP LABELER | |
hosts: all | |
become: yes | |
tasks: | |
- name: COLLECT LLDP INFO in JSON Format | |
shell: net show lldp json | |
register: lldp_info_json | |
- name: CONVERT TO AN ANSIBLE NATIVE VARIABLE | |
set_fact: | |
lldp_info: "{{lldp_info_json.stdout | from_json }}" | |
- name: SET LLDP LABELS | |
nclu: | |
atomic: true | |
description: "Set Interface Descriptions" | |
template: | | |
{% for port in lldp_info %} | |
add interface {{port}} alias CONNECTED TO: {{lldp_info[port].iface_obj.lldp[0].adj_hostname}} -- {{lldp_info[port].iface_obj.lldp[0].adj_port}} | |
{% endfor %} | |
(eric@xenial3)-(09:27 PM Sun Dec 10)-> | |
-(17 files, 344Kb)--> ansible-playbook ./test.yml | |
PLAY [LLDP LABELER] *********************************************************************************************** | |
TASK [Gathering Facts] ******************************************************************************************** | |
Sunday 10 December 2017 21:28:58 -0500 (0:00:00.060) 0:00:00.060 ******* | |
ok: [leaf1] | |
ok: [leaf2] | |
TASK [COLLECT LLDP INFO in JSON Format] *************************************************************************** | |
Sunday 10 December 2017 21:29:00 -0500 (0:00:01.738) 0:00:01.798 ******* | |
changed: [leaf2] | |
changed: [leaf1] | |
TASK [CONVERT TO AN ANSIBLE NATIVE VARIABLE] ********************************************************************** | |
Sunday 10 December 2017 21:29:01 -0500 (0:00:00.694) 0:00:02.493 ******* | |
ok: [leaf2] | |
ok: [leaf1] | |
TASK [SET LLDP LABELS] ******************************************************************************************** | |
Sunday 10 December 2017 21:29:01 -0500 (0:00:00.091) 0:00:02.584 ******* | |
changed: [leaf1] | |
changed: [leaf2] | |
PLAY RECAP ******************************************************************************************************** | |
leaf1 : ok=4 changed=2 unreachable=0 failed=0 | |
leaf2 : ok=4 changed=2 unreachable=0 failed=0 | |
Sunday 10 December 2017 21:29:03 -0500 (0:00:02.628) 0:00:05.213 ******* | |
=============================================================================== | |
SET LLDP LABELS -------------------------------------------------------------------------------------------- 2.63s | |
Gathering Facts -------------------------------------------------------------------------------------------- 1.74s | |
COLLECT LLDP INFO in JSON Format --------------------------------------------------------------------------- 0.69s | |
CONVERT TO AN ANSIBLE NATIVE VARIABLE ---------------------------------------------------------------------- 0.09s | |
(eric@xenial3)-(09:29 PM Sun Dec 10)-> | |
-(17 files, 344Kb)--> ansible -m shell -a "/sbin/ifquery -a" leaf1 | |
leaf1 | SUCCESS | rc=0 >> | |
auto lo | |
iface lo inet loopback | |
auto swp1 | |
iface swp1 | |
alias CONNECTED TO: cumulus -- swp1 | |
auto swp2 | |
iface swp2 | |
alias CONNECTED TO: cumulus -- swp2 | |
auto swp3 | |
iface swp3 | |
alias CONNECTED TO: cumulus -- swp3 | |
auto swp4 | |
iface swp4 | |
alias CONNECTED TO: cumulus -- swp4 | |
auto vagrant | |
iface vagrant inet dhcp | |
auto eth0 | |
iface eth0 inet dhcp | |
(eric@xenial3)-(09:29 PM Sun Dec 10)-> | |
-(17 files, 344Kb)--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment