Issue with curl command running with shell module

Hi Team,

Curl command is working fine on command line shell ,but when running the same command using Ansible shell module it’s throwing error .
The exact issue coming when i am using curl command with multiple parameters (example -i /opt/hosts proxy ) .

Here is my playbook

Output —

fatal: [localhost]: FAILED! => {“changed”: true, “cmd”: “curl -s http://localhost:8095/proxy/healthcheck -i /opt/hosts”, “delta”: “0:00:00.016367”, “end”: “2020-02-06 08:00:08.153617”, “msg”: “non-zero return code”, “rc”: 3, “start”: “2020-02-06 08:00:08.137250”, “stderr”: “”, “stderr_lines”: , “stdout”: "HTTP/1.1 200 OK\r\nDate: Thu, 06 Feb 2020 16:00:08 GMT\r\nContent-Type: application/json\r\nContent-Length: 159\r\n\r\n{"package":"PROXY"

While running the same curl command on linux shell , it’s working fine.

Hi Pawan

You state: "Curl command is working fine on command line shell".
But in fact, it is not working fine, because it exits with error code
3, which (according to
https://curl.haxx.se/libcurl/c/libcurl-errors.html) means "The URL was
not properly formatted."
You would have seen that if you didn't suppress the output with the
"-s" (silent) switch.
Running the same command from ansible shell will give exactly the same
result, but ansible is more vocal about non-zero exit codes and hence
will complain.

Remove the "-s" switch and try to manually tweak the curl command so
that it yields something useful (preferably something that cleanly
exits).
Once that works, it will also work in ansible shell/command.

Dick