lldp: Added EXAMPLES

This commit is contained in:
Andy Hill 2013-12-18 07:52:17 -07:00 committed by Michael DeHaan
parent b31a92a30d
commit fb82e1f942

View file

@ -21,13 +21,29 @@ DOCUMENTATION = '''
module: lldp module: lldp
short_description: get details reported by lldp short_description: get details reported by lldp
description: description:
- Reads data out of lldp - Reads data out of lldpctl
author: Andy Hill author: Andy Hill
notes: notes:
- Requires lldpd running and lldp enabled on switches - 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(): def gather_lldp():
cmd = ['lldpctl', '-f', 'keyvalue'] cmd = ['lldpctl', '-f', 'keyvalue']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)