It basically allows the generated filename to be customised, but fall back to the template name if none is provided. The problem is it doesn’t work, the generated filename is literally {{ item.target_name|item.name }}. But it works fine without the default syntax (ie just {{ item.name }}). Is that expected behaviour and is there any workaround?
set_fact: item.target_name = item.name
when: item.target_name is not defined
with_items: configs
This way I could just always use item.target_name. It runs on the correct items, but seems that set_fact doesn’t work as I expected for an item dict, as item.target_name is still undefined on the next task.
I also changed target_name to not use dot notation, as that can sometimes still create issues with the default filter. In the above case, if item does not have a ‘target_name’ key, it will default to ‘item.name’.