From fb82e1f94258ac6d4ede297ad179c1bcbb5f6ccc Mon Sep 17 00:00:00 2001 From: Andy Hill Date: Wed, 18 Dec 2013 07:52:17 -0700 Subject: [PATCH] lldp: Added EXAMPLES --- net_infrastructure/lldp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net_infrastructure/lldp b/net_infrastructure/lldp index eb027231d84..047cd39d0b2 100755 --- a/net_infrastructure/lldp +++ b/net_infrastructure/lldp @@ -19,15 +19,31 @@ import subprocess DOCUMENTATION = ''' --- module: lldp -short_description: get details reported by lldp +short_description: get details reported by lldp description: - - Reads data out of lldp + - Reads data out of lldpctl author: Andy Hill notes: - Requires lldpd running and lldp enabled on switches ''' +EXAMPLES = ''' +# Retrieve switch/port information + - name: Gather information from lldp + lldp: + + - name: Print each switch/port + debug: msg="{{ lldp[item]['chassis']['name'] }} / {{ lldp[item]['port']['ifalias'] }} + with_items: lldp.keys() + +# TASK: [Print each switch/port] *********************************************************** +# ok: [10.13.0.22] => (item=eth2) => {"item": "eth2", "msg": "switch1.example.com / Gi0/24"} +# ok: [10.13.0.22] => (item=eth1) => {"item": "eth1", "msg": "switch2.example.com / Gi0/3"} +# ok: [10.13.0.22] => (item=eth0) => {"item": "eth0", "msg": "switch3.example.com / Gi0/3"} + +''' + def gather_lldp(): cmd = ['lldpctl', '-f', 'keyvalue'] proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)