Ansible地图字典项到列表

时间:2018-08-08 12:05:34

标签: python ansible jinja2

您有一个可用的字典列表:

domains:
  - { domain: example.com, cert: cert1.pem }
  - { domain: example.in, cert: cert2.pem }

如何仅通过域在jinja2模板中生成联接数组列表?

domains=example.com,example.in

1 个答案:

答案 0 :(得分:2)

domains={{ domains | map(attribute='domain') | list | join(",") }}

Ansible: filter a list by its attributes

https://github.com/ansible/ansible/issues/24338