If placed them in the rundeck command, then:- sudo su - ansible bash -c "ANSIBLE_FORCE_COLOR=true; echo '{\"versions\":{\"campaigns_manager\":\"0.9.310\"}}' "
- Fails to execute at all (fails around the export command)
- sudo su - ansible bash -c """ANSIBLE_FORCE_COLOR=true; echo '{\"versions\":{\"campaigns_manager\":\"0.9.310\"}}' """
- Runs but produces:
- {\versions\:{\campaigns_manager\:\0.9.310\}}
- does remove double-quotes that leads to
- ERROR: Expecting property name enclosed in double quotes: line 1 column 2 (char 1
- expected result:
- '{"versions":{"campaigns_manager":"0.9.310"}}'
- additionaly, following command:
- sudo su - ansible bash -c """ANSIBLE_FORCE_COLOR=true; echo '{"versions":{"campaigns_manager":"0.9.310"}}' """
- evaluates to
- {versions:{campaigns_manager:0.9.310}}
I need to pass the JSON
Any way of keeping double-quotes in the executed shell command?
Alternatively - I could try to switch :
- sudo su - ansible bash -c """ something """
- sudo su - ansible bash -c " something "
If You know how to do escaping only with double+single quotes, when _inside_ of the command (that is marked by single or double quotes), You need to use a combination of the two (singe and double quotes)
- sudo su - ansible bash -c " something; echo '{"versions":{"campaigns_manager":"0.9.310"}}' "
In case You were wanderring, the full command to run looks like:
sudo su - ansible bash -c "export ANSIBLE_FORCE_COLOR=true; cd ~/ansible; source ~/ansible/environment.sh; ansible-playbook -i ~/ansible/etc/inv/inventory ~/ansible/etc/playbooks/run_server.yml -e '{"versions":{"manaegr":"0.9.3"}}' --check --diff -v"