In my ansible I need to make a rest call to get a rather large json object (which comes in as a dict). Then I need to modify a few fields in the json and repost it to update the status of the components I want to change.
I already have the rest response and I'm trying to figure out how to cleanly modify numerous values. My current attempt looks like this (simplified a little):
- name: update locations for remote processor
set_fact:
request: "{{ response.json | combine(item)}}"
loop:
- { 'component': { 'targetUri': "{{remoteProcessorUri}}"
- { 'component': { 'targetUris': "{{remoteProcessorUri}}"
...
Unfortunately while this does change the request, it replaces the larger component dict with an dict that only contains targetUri, all the other content that was in component was erased where as I want to keep it and only modify targetUri.
I tried a variant where my loop had a location and a value field for each item, but I can't get the location field syntax right to be able to replace response.json with item.location.
So how can I create this to make it easy, and readable, to make various changes across my dict without changing anything other then the specific subfields I call out?