Hello, I am using the shell module to run a command inside a docker container and it is giving me a yaml error. The command is stupid silly complicated Is there a way to get Ansible to just send it as is and ignore \ escape out the characters that may be freaking out Yaml?
Here is an example of a basic command that does work.
shell: docker exec -it 9d5e563a6e9e bash -c “cd /var/log ; ls; cat bootstrap.log”
However this command gives me a yaml eror
shell: docker exec -it 9d5e563a6e9e bash -c “echo ‘rs.initiate({_id: "mongors1conf",configsvr: true, members: [{ _id : 0, host : "mongocfg1" },{ _id : 1, host : "mongocfg2" }, { _id : 2, host : "mongocfg3" }]})’ | mongo”
Here is a snippet of the error
ERROR! Syntax Error while loading YAML.
mapping values are not allowed in this context
shell: docker exec -it 9d5e563a6e9e bash -c "echo 'rs.initiate({_id: \"mongors1conf\",configsvr: true, members: [{ _id : 0, host : \"mongocfg1\" },{ _id : 1, host : \"mongocfg2\" }, { _id : 2, host : \"mongocfg3\" }]})' | mongo" **^ here**This command works just fine at the bash shell of the docker host. I have tried the ansible shell and the Ansible command module
I know this command looks complicated but please keep in mind I am only asking how to format this to work in Ansible. I am not asking you to understand docker exec Mongodb commands
Thanks for your help