In ansible 1.5.4 the following command worked flawlessly:

- name: Generate postfix dhparams
  command: "{{ item }}"
    - 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: [] => 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?


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}}"
    - { 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
| improve this answer | |
  • Can you explain the difference between command: "{{ item.command }} creates={{ item.file}}" and command: "{{ item.command }}" creates="{{ item.file}}"? – Zulakis Jun 1 '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 yaml-online-parser.appspot.com for a useful syntax checker. – mvermaes Jun 1 '15 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.