On Thu, 17 Aug 2023 07:56:58 -0400 Todd Lewis <uto...@gmail.com> wrote:
> bn: > - - basename > - dev_wss_db > - - basename > - dev_wss_db_requests > - - basename > - dev_bss_service_database > - - basename > - dev_bss_frontend_db > - - basename > - dev_mss_db > > But I didn't find a way to map that using "community.general.dict" to create > > bn: > - basename: dev_wss_db > - basename: dev_wss_db_requests > - basename: dev_bss_service_database > - basename: dev_bss_frontend_db > - basename: dev_mss_db You can always use brute-force Jinja as the last resort. For example, given the list bn_list: - dev_wss_db - dev_wss_db_requests - dev_bss_service_database - dev_bss_frontend_db - dev_mss_db the below Jinja creates the list of the hashes bn: | {% filter from_yaml %} {% for basename in bn_list %} - basename: {{ basename }} {% endfor %} {% endfilter %} As a side-note, this is equivalent to bn: "{{ all_objects| map(attribute='Key')| map('regex_replace', bn_regex, '{basename: \\1}')| map('from_yaml') }}" > This for me is one of the more frustrating things about Jinja > pipelines. I keep wishing "map" would take arbitrary > expressions rather than the limited set it's stuck with. This is very good point. It would be possible to write such a filter. However, I'm not sure about the security implications. -- Vladimir Botka -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20230817170740.038163cc%40gmail.com.
pgpOgqpg7TAic.pgp
Description: OpenPGP digital signature