Ansible list of lists - flattening

后端 未结 1 435
情深已故
情深已故 2021-01-20 06:56

I am using a set_fact in a playbook to gather data using a regex_findall(). I\'m pulling out two groups with the regex and the ending result becomes a list of lists.

<
相关标签:
1条回答
  • 2021-01-20 07:57

    You want to use with_list instead of with_items.

    with_items forcefully flattens nested lists, while with_list feeds argument as is.

    ---
    - hosts: localhost
      gather_facts: no
      vars:
        nested_list: [[a,b],[c,d],[e,f],[g,h]]
      tasks:
        - debug: msg="{{ item[0] }} {{ item[1] }}"
          with_list: "{{ nested_list }}"
    
    0 讨论(0)
提交回复
热议问题