1

I would like to run this command on a remote host with Ansible (version (3.6.5):

DEBCONF_DB_OVERRIDE='File /tmp/config.dat' dpkg-reconfigure -fnoninteractive exim4-config

I tried by including this task in my playbook:

- name: dpkg-reconfigure exim4-config
  command: DEBCONF_DB_OVERRIDE='File /tmp/config.dat' dpkg-reconfigure -fnoninteractive exim4-config

This leads to the following error message:

FAILED! => {"changed": false, "cmd": "'DEBCONF_DB_OVERRIDE=File /tmp/config.dat' dpkg-reconfigure -fnoninteractive exim4-config", "msg": "[Errno 2] No such file or directory", "rc": 2}

It looks to me as if Ansible's command module places additional surrounding quotes, which seem to disturb mine.

So how can I run this command with Ansible? I have tried both single and double quotes as well as escaping characters (with \', \", or \) but to no avail so far.

Drux
  • 11,992
  • 13
  • 66
  • 116

1 Answers1

2

For custom command, you should use shell instead of command:

- name: dpkg-reconfigure exim4-config
    shell: DEBCONF_DB_OVERRIDE='File /tmp/config.dat' dpkg-reconfigure -fnoninteractive exim4-config
Samiul Amin Shanto
  • 1,397
  • 9
  • 19
  • `DEBCONF_DB_OVERRIDE='File /tmp/config.dat'` is set value for DEBCONF_DB_OVERRIDE variable, then run command `dpkg-reconfigure -fnoninteractive exim4-config` – Samiul Amin Shanto Jul 25 '18 at 05:26