ansible with_items list of lists is flattening

后端 未结 4 1581
闹比i
闹比i 2021-01-01 19:23

I\'m trying to use ansible to loop over a list of lists to install some packages. But {{item}} is returning every element in the sub lists rather than the sublist itself.

4条回答
  •  無奈伤痛
    2021-01-01 19:39

    Replace with_items: "{{ modules }}" with:

    • in Ansible 2.5 and later (refer to with_list porting guide):

      loop: "{{ modules }}"
      
    • in Ansible 2.0 and later:

      with_list: "{{ modules }}"
      
    • in any Ansible pre-2.0:

      with_items:
        - "{{ modules }}"
      

      This way you'd have three levels of nested lists, and the default behaviour flattens only two of them.

提交回复
热议问题