How to use quotes in the command?

Hi! I would like to use the curl command in “command”, but due to the fact that there are double and single quotes, I get an error all the time, how can I fix it? (The problem is in the curl request)

template {
  source = "/opt/consul-template/templates/mmm.ctmpl"
  destination = "/etc/ssl/private/mmm.com.pem"
  command = "if haproxy -c -f /etc/haproxy/haproxy.cfg; then systemctl reload haproxy && curl -d ‘{“token”:“123456”, “text”:“value2"}’ -H “Content-Type: application/json” -X POST https://blabla.com/; else systemctl stop consul-template;fi"}

Hey @vrublevskyyy,

Shell quoting can be difficult and it is generally better with long commands like this to move it into a separate shell script file and run that. It makes working with the shell script/command a lot easier as you don’t have the quoting limitations.

It seems like it should be possible to get it working as you have it with the proper quote escaping but that would take a lot of testing and IMO it’s better to go with the script if you can.

Hope this helps and good luck.