4

In ansible 1.5.4 the following command worked flawlessly:

- 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

After upgrading to 1.9.1, the command fails with a 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}}"). error.

As {{ item }} is already quotes, I don't know what is wrong.

How can I get this command working again?

Zulakis
  • 4,153
  • 14
  • 48
  • 76

1 Answers1

5

Have a look at https://github.com/ansible/ansible/issues/8260 for the details on why this change in behaviour was made (to prevent additional arguments being injected in the command module). The following format should work:

- 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
mvermaes
  • 671
  • 5
  • 7
  • Can you explain the difference between `command: "{{ item.command }} creates={{ item.file}}"` and `command: "{{ item.command }}" creates="{{ item.file}}"`? – Zulakis Jun 01 '15 at 11:54
  • 2
    The latter isn't valid YAML syntax, which is what Ansible uses for its playbook language. If you start a value with a quote, you need to end the value (and line) with a quote. Try https://yaml-online-parser.appspot.com/ for a useful syntax checker. – mvermaes Jun 01 '15 at 12:38