Closed IamLunchbox closed 1 month ago
I tried to debug it, I think ansible by default flattens returns from plugins, editing the return content did not lead to the desired effect.
I could not create a PR because I did not find out, where the flattening actually takes place. I helped myself wrapping all output in brackets and flattening it again.
{{ [ lookup(...) ] flatten | items2dict ] }}
The lookup returns different data structures depending on the content of the lookup directory.
If there are several entries in a directory, it will return a list of entries, which can be cast into
items2dict
and used with jinja expressions (mysecrets.API_KEY
).If there is only one entry, a dictionary instead of a list is returned - this then is not compatible to
items2dict
and will fail playbook execution.Proposed solution: Always return a list, even if it contains only one entry.