Infisical / ansible-collection

This collection provides a series of Ansible modules and plugins for interacting with the Infisical.
5 stars 1 forks source link

Consistent output for secrets #8

Closed IamLunchbox closed 1 month ago

IamLunchbox commented 1 month ago

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.

IamLunchbox commented 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.

IamLunchbox commented 1 month ago

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 ] }}