Hi
I am very new with ansible and I am struggling to solve the following “problem”
I have two json inputs
a list of “locations” (you can think them as stores). For each "location"I have the name and the unique ID
and a list of “parts” . For each item, I have an array which tells me in which “locations” I can find the item
I want to build an array of locations, for each location I want to know the list of “items” available in this location
I don;t know how to do that with ansible
Thank you
Chris
locations with their IDs
{
“offset”: 0,
“locations”: [
{
“name”: “Dallas”,
“id”: “42086a89-910f-4903-6db5-1f40995a6920”,
“foo”: “value1”
},
{
“name”: “Houston”,
“id”: “42083339-7472-0ed6-3c34-eb51865dd50f”,
“foo”: “something”
},
{
“name”: “Austin”,
“id”: “42081ecb-ff7d-20c2-156f-1b748411eadd”,
“foo”: “sonethingelse”
}
],
“count”: 3,
“bar”: 500
}
parts
{
“foo”: 500,
“count”: 3,
“items”: [
{
“name”: “item1”,
“locations”: [
{
“id”: “42083339-7472-0ed6-3c34-eb51865dd50f”
},
{
“id”: “42086a89-910f-4903-6db5-1f40995a6920”
}
],
“foobar”: “Yes”
},
{
“name”: “item2”,
“locations”: [
{
“id”: “42083339-7472-0ed6-3c34-eb51865dd50f”
},
{
“id”: “42081ecb-ff7d-20c2-156f-1b748411eadd”
}
],
“foobar”: “No”
},
{
“name”: “item3”,
“locations”: [
{
“id”: “42083339-7472-0ed6-3c34-eb51865dd50f”
},
{
“id”: “42081ecb-ff7d-20c2-156f-1b748411eadd”
}
],
“foobar”: “Sure”
}
]
}
and I want to build this (or a variable that will let me find which parts are available in each location)
{
“locations”: [
{
“name”: “Dallas”,
“parts”: [
{“item”: “item1”}
]
},
{
“name”: “Houston”,
“parts”: [
{“item”: “item2”},
{“item”: “item3”},
{“item”: “item1”}
]
},
{
“name”: “Austin”,
“parts”: [
{“item”: “item2”},
{“item”: “item3”}
]
}
]
}