如何在ansible中使用jinja2过滤器提取和构建字典项列表

如何在ansible中使用jinja2过滤器提取和构建字典项列表,ansible,jinja2,Ansible,Jinja2,我有这样的东西: [ [ { name: abc attr: testabc }, { name: def attr: testdef } ], [ { name: ghi attr: testabc } ], [] ] 数据: 负责任务: - name: All migrations set_fact: migrations: "{{modules|map(attribute='

我有这样的东西:

[
  [
   {
     name: abc
     attr: testabc
   },
   {
     name: def
     attr: testdef
   }
 ],
 [
   {
    name: ghi
    attr: testabc
   }
 ],
 []
]
数据:

负责任务:

- name: All migrations
  set_fact:
   migrations: "{{modules|map(attribute='migrations')|list }}"
输出:

我看到的输出是这样的:

[
  [
   {
     name: abc
     attr: testabc
   },
   {
     name: def
     attr: testdef
   }
 ],
 [
   {
    name: ghi
    attr: testabc
   }
 ],
 []
]
我需要的是:

[ 
   {
     name: abc
     attr: testabc
   },
   {
     name: def
     attr: testdef
   },     
   {
    name: ghi
    attr: testabc
   }     
]

这可能有助于我通过以下方式获取dict列表:

- name: All migrations
  set_fact:
    migrations: "{% set migrations = migrations|default([]) + [item.1] %}{{migrations|list}}"
  with_subelements:
      - "{{ modules }}"
      - migrations
可能有一个较短的版本,但我还不知道