谢谢Phil的解决方案;万一有人遇到与我相同的情况,这是一个(更复杂的)变体:
---
- set_fact:
    postconf_d: {}
- name: 'get postfix default configuration'
  command: 'postconf -d'
  register: command
- name: 'set postfix default configuration as fact'
  set_fact:
    postconf_d: >
      {{
        postconf_d |
        combine(
          dict([ item.partition('=')[::2]|map('trim') ])
        )
  with_items: command.stdout_lines
这将给出以下输出(以示例为例):
"postconf_d": {
    "alias_database": "hash:/etc/aliases", 
    "alias_maps": "hash:/etc/aliases, nis:mail.aliases",
    "allow_min_user": "no", 
    "allow_percent_hack": "yes"
}
更进一步,解析“值”中的列表:
- name: 'set postfix default configuration as fact'
  set_fact:
    postconf_d: >-
      {% set key, val = item.partition('=')[::2]|map('trim') -%}
      {% if ',' in val -%}
        {% set val = val.split(',')|map('trim')|list -%}
      {% endif -%}
      {{ postfix_default_main_cf | combine({key: val}) }}
  with_items: command.stdout_lines
...
"postconf_d": {
    "alias_database": "hash:/etc/aliases", 
    "alias_maps": [
        "hash:/etc/aliases", 
        "nis:mail.aliases"
    ], 
    "allow_min_user": "no", 
    "allow_percent_hack": "yes"
}
注意事项:
- 在这种情况下,它需要“微调”一切(使用- >-在YAML并- -%}在神社),否则你会得到这样的错误:
 - FAILED! => {"failed": true, "msg": "|combine expects dictionaries, got u\"  {u'...
 
- 显然,- {% if ..这远非防弹
 
- 在后缀的情况下,本- val.split(',')|map('trim')|list可以简化为- val.split(', '),但是我想指出一个事实,- |list否则您将需要得到以下错误:
 - "|combine expects dictionaries, got u\"{u'...': <generator object do_map at ...
 
希望这会有所帮助。