aruba / aoscx-ansible-role

Ansible roles for AOS-CX switches
24 stars 10 forks source link

Getting mac address in lldp_neighbors with ansible fact aoscx_fact #16

Open DungKHoang opened 3 years ago

DungKHoang commented 3 years ago

I have this ansible playbook to get lldp information and I'd like to retrieve the mac_addr of a lldp neighbor Here is the code:

Here is the output: TASK [debug] ***** ok: [aoscx_1] => { "var_lldp": { "32383170-3133-4D32-3231-313030365254,94:40:c9:ac:b5:c0": { "chassis_id": "32383170-3133-4D32-3231-313030365254", "dcbx_application_priorities": {}, "mac_addr": "94:40:c9:ac:b5:c0", "med_network_policy": {}, "neighbor_info": { "chassis_capability_available": " ", "chassis_capability_enabled": " ", "chassis_description": "ProLiant DX360 Gen10 10NVMe", "chassis_id_len": "36", "chassis_id_subtype": "local", "chassis_index": "16", "chassis_name": "", "chassis_protocol": "LLDP", "chassis_refcount": "2", "chassis_ttl": "100", "mgmt_iface_list": "0,0", "mgmt_ip_list": "10.1.1.10,b4:7a:f1:55:31:5a", "port_description": "Undefined Slot, Port 1", "port_hidden_in": "0", "port_hidden_out": "0", "port_id_len": "6", "port_id_subtype": "link_local_addr", "port_lastchange": "60bc298a", "port_lastupdate": "60bec29e", "port_mfs": "0", "port_protocol": "LLDP", "remote_index": 1 }, "neighbor_info_organizational": {}, "port_id": "94:40:c9:ac:b5:c0" } } }

Question: How can I get the mac_addr from this dict object?

I try var_lldp['mac_addr] but get an error stating that the dict_object has no mac_addr attribute

Thanks for helping