jinja2 获取属性列表

jinja2 get list of attributes

我正在使用 salt + jinja2 来制作 context.xml 文件的模板。我有以下支柱:

context:
  db_server: some_server
  resources:
    some_customer:
      name: some_name
      user: some_user
      passwd: some_passwd
    this_customer:
      name: this_name
      user: this_user
      passwd: this_passwd

我需要创建一个字符串,其中包含每个客户的姓名列表。现在我有这个:

{%- set nameList = pillar['context']['resources']|list()|join(', ') %}

这给了我这个列表:'some_customer, this_customer'。我想要这个列表:'some_name, this_name'

我该怎么做?

以下一行对我有用:

{%- set nameList = pillar['context']['resources'].values()
                 |map(attribute='name')|join(', ') %}