Loop over roles with a list

poinck
Wed, 27 Sep 2023 09:47:08 +0000
Get Help

Hi, I want to loop over a role with a var like that, but the loop below does not work, because it cannot find a definition for item.

array:
 - name: "a name"
   path: "/path/"

- name: "Do Role"
  roles:
    - role: my_role
      vars:
        - name: {{ item.name }}
        - path: {{ item.path }}
      loop: "{{ array }}"

I could not find any example in the official docs and other sources still use with_items which is deprciated. If anyone could point me to the correct documentation or reply with a possible solution, that would be wonderful.

7 posts - 6 participants