Is there any way to create a nested loop over a dict and a list?

Say I have two variable like these:

var1:
  key1: val1
  key2: val2
var2:
  - item1
  - item2

Can I loop over these two variables like below?

- shell: echo {{ item.0.value }} {{ item.1 }}
  with_dict: "{{ var1 }}"
  with_items: "{{ var2 }}"

I have no idea to loop over these two variables together and don’t wanna change the data type of the variables. Is there any way to achieve this kind of loop in ansible?

Hello,

You can use with_nested:

`

  • shell: “echo {{item.0}} {{item.1}}”
    with_nested:
  • var1.values()
  • var2

`