In my playbook I have a list like this
users:
- readonly
- write
and I need to translate it to a list of objects/dictionaries
userDict:
- {'username': readonly, 'database': admin}
- {'username': write, 'database': admin}
I know, I can do it with Jinja templates:
userDict: |
{% set ret = [] %}
{% for item in users %}
{% set _ = ret.append({'username': item, 'database': 'admin'}) %}
{% endfor %}
{{ ret }}
But I am looking for a shorter solution with filter, something like this:
userDict: "{{ users | map('map', 'username') | combine({'database': admin}) }}"