I am trying to use the cdp neighbor information gathered in cisco.ios.ios_facts to configure the descriptions on the interfaces that are relevant to the neighbors. in the following code, I can iterate through the interfaces with neighbors on them just fine, but I cannot get the descriptions to parse through the “hosts” that are given in the output. I can reference each member of the list, or put every member of the list on each line, but I am having trouble getting the hosts/interfaces to line up. Much of the following code is filled with my attempts to understand what output I get with each debug statement.
code
---
l
PLAY [Update Interface Descriptions] ********************************************************************************************************************************************************************************************************
TASK [Gather Facts] *************************************************************************************************************************************************************************************************************************
ok: [10.140.1.92]
TASK [set_fact] *****************************************************************************************************************************************************************************************************************************
ok: [10.140.1.92]
TASK [debug] ********************************************************************************************************************************************************************************************************************************
ok: [10.140.1.92] => (item=GigabitEthernet0/1) => {
"msg": "GigabitEthernet0/1"
}
ok: [10.140.1.92] => (item=GigabitEthernet0/14) => {
"msg": "GigabitEthernet0/14"
}
ok: [10.140.1.92] => (item=GigabitEthernet0/9) => {
"msg": "GigabitEthernet0/9"
}
TASK [debug] ********************************************************************************************************************************************************************************************************************************
ok: [10.140.1.92] => (item=[{'host': 'SEPDCEB94BC2486', 'platform': 'Cisco IP Phone 8811', 'port': 'Port 1', 'ip': '10.140.50.45'}]) => {
"msg": [
[
{
"host": "SEPDCEB94BC2486",
"ip": "10.140.50.45",
"platform": "Cisco IP Phone 8811",
"port": "Port 1"
}
]
]
}
ok: [10.140.1.92] => (item=[{'host': 'USACRSSRFSW090.newmont.net', 'platform': 'cisco WS-C4506-E', 'port': 'GigabitEthernet6/41', 'ip': '10.140.253.252'}]) => {
"msg": [
[
{
"host": "USACRSSRFSW090.newmont.net",
"ip": "10.140.253.252",
"platform": "cisco WS-C4506-E",
"port": "GigabitEthernet6/41"
}
]
]
}
ok: [10.140.1.92] => (item=[{'host': 'GQ_NET_Office', 'platform': 'cisco C9130AXI-B', 'port': 'GigabitEthernet0', 'ip': '10.140.14.87'}]) => {
"msg": [
[
{
"host": "GQ_NET_Office",
"ip": "10.140.14.87",
"platform": "cisco C9130AXI-B",
"port": "GigabitEthernet0"
}
]
]
}
TASK [Merge provided configuration with device configuration] *******************************************************************************************************************************************************************************
ok: [10.140.1.92] => (item={'msg': 'GigabitEthernet0/1', 'failed': False, 'changed': False, 'item': 'GigabitEthernet0/1', 'ansible_loop_var': 'item'})
ok: [10.140.1.92] => (item={'msg': 'GigabitEthernet0/14', 'failed': False, 'changed': False, 'item': 'GigabitEthernet0/14', 'ansible_loop_var': 'item'})
ok: [10.140.1.92] => (item={'msg': 'GigabitEthernet0/9', 'failed': False, 'changed': False, 'item': 'GigabitEthernet0/9', 'ansible_loop_var': 'item'})
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
10.140.1.92 : ok=5 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0