有用的命令with_items

在1.5.4中,以下命令完美地工作:

- name: Generate postfix dhparams command: "{{ item }}" with_items: - openssl gendh -out /etc/postfix/dh_512.pem -2 512 creates=/etc/postfix/dh_512.pem - openssl gendh -out /etc/postfix/dh_2048.pem -2 2048 creates=/etc/postfix/dh_2048.pem notify: Reload postfix 

升级到1.9.1后,命令失败,出现fatal: [127.0.0.1] => A variable inserted a new parameter into the module args. Be sure to quote variables if they contain equal signs (for example: "{{var}}"). fatal: [127.0.0.1] => A variable inserted a new parameter into the module args. Be sure to quote variables if they contain equal signs (for example: "{{var}}"). 错误。

由于{{ item }}已经被引用,所以我不知道什么是错的。

我怎样才能让这个命令再次工作?

请查看https://github.com/ansible/ansible/issues/8260了解为什么进行此行为更改的详细信息(以防止在命令模块中注入更多参数)。 以下格式应该工作:

 - name: Generate postfix dhparams command: "{{ item.command }} creates={{ item.file}}" with_items: - { command: 'openssl gendh -out /etc/postfix/dh_512.pem -2 512', file: '/etc/postfix/dh_512.pem' } - { command: 'openssl gendh -out /etc/postfix/dh_2048.pem -2 2048', file: '/etc/postfix/dh_2048.pem' } notify: Reload postfix