代码之家  ›  专栏  ›  技术社区  ›  George Shuklin

使用Ansible中的嵌套列表遍历词典列表

  •  0
  • George Shuklin  · 技术社区  · 7 年前

    debug )在字典列表内的内部列表的每个元素上以及字典的键。

    输入数据:

    ---
    - hosts: localhost
      tasks:
       - debug: msg='{{ mykey_item }} with {{ inner_list_item }}'
         loop: '{{ something_here }}'
      vars:
        example:
          - mykey: key1
            inner_list:
              - one
              - two
          - mykey: key2
            inner_list:
              - three
              - four
    

    key1 with one
    key1 with two
    key2 with three
    key2 with four
    
    0 回复  |  直到 7 年前