Iterate over nested list inside a dict

hey, i have a little problem maybe someone can help.
I want to generate lets encrypt certs with ansible.builtin.acme_certificate
which seems to work, but i need to place the dns records, for this i use community.general.netcup_dns

My problem now is the result from acme_certicate

    challenge_data_dns:
      _acme-challenge.example.net:
        - BKA2g7FqDE
        - SiUKqRuYI
      _acme-challenge.home.example.net:
        - gbYWTwtx3
      _acme-challenge.lab.example.net:
        - bAkdltnD3
        - efL6bGiTXI

I need to run netcup_dns now multiple, 5 times in this example.

key:value
 _acme-challenge.example.net : BKA2g7FqDE
 _acme-challenge.example.net: SiUKqRuYI
_acme-challenge.home.example.net : gbYWTwtx3
_acme-challenge.lab.example.net : bAkdltnD3
_acme-challenge.lab.example.net : efL6bGiTXI

But the question is how to do this, i need somehow to loop over the single values in the list oh each key.

the with_subelements module does not fit, because iā€™m not really able to predict the names after _acme-challenge.

i has this litte example

- name: example
  hosts: all
  gather_facts: false
  strategy: linear
  vars:
    challenge_data_dns:
      _acme-challenge.example.net:
        - BKA2g7FqDE
        - SiUKqRuYI
      _acme-challenge.home.example.net:
        - gbYWTwtx3
      _acme-challenge.lab.example.net:
        - bAkdltnD3
        - efL6bGiTXI
  tasks:
    - name: debug out 
      debug:
        msg: "{{item}}"
      loop: "{{ challenge_data_dns | dict2items }}"
    
``
    - name: debug out 
      debug:
        msg: "{{ item.0.key }} : {{ item.1 }}"
      loop: "{{ challenge_data_dns|dict2items|subelements('value') }}"
1 Like