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.
答案 0 :(得分:1)
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