I have k:v dictionary of hostname: IP that I want to use in a lookup from another dictionary to replace entries matching key from 1st dictionary and replacing it with the corresponding value in 2nd dictionary;
1st:
"nb_console_ip": {
"office-con01": "10.20.30.100",
2nd:
"nb_console_port": [
{
"console": "office-con01",
"hostname": "office-core01",
"port": "con1"
},
{
"console": "office-con01",
"hostname": "office-core02",
"port": "con2"
},
{
"console": "office-con01",
"hostname": "office-fw01",
"port": "con5"
},
{
"console": "office-con01",
"hostname": "office-fw02",
"port": "con6"
},
{
"console": "office-con01",
"hostname": "office-vpn01",
"port": "con3"
},
{
"console": "office-con01",
"hostname": "office-vpn02",
"port": "con4"
}
]
Essentially Im trying to set_fact for 2nd dict with a find and replace of office-con01
with 10.20.30.100
but for a list of 30+ hosts.
Reason being I then have a jinja template that will use the 3 values of console_ip, hostname & port.
I was thinking maybe within there are better suited filters for lookup, find, replace etc.
Both sets of data are results of json_query on return from an API call.