I need to properly escape single and double quotes in an ansible playbook in order to set the environment variable. None of this works:
- name: Set environment variable
command: >
export EXTRA_CONFIG=“'”{"client": {"subscriptions": ["DIND-Worker"], "cluster": "internal"}}“'”
- name: Set environment variable
command: >
export EXTRA_CONFIG=''{"client": {"subscriptions": ["DIND-Worker"], "cluster": "internal"}}''
- name: Set environment variable
command: >
export EXTRA_CONFIG=''{\"client\": {\"subscriptions\": [\"DIND-Worker\"], \"cluster\": \"internal\"}}''
Looked at this:
http://yaml.org/spec/current.html#id2532720
https://github.com/dotmaster/toYaml/issues/1
The error message I get is:
fatal: [ip.address]: FAILED! => {"changed": false, "cmd": "export 'EXTRA_CONFIG={\"client\":' '{\"subscriptions\":' '[\"DIND-Worker\"],' '\"cluster\":' '\"internal\"}}'", "failed": true, "msg": "[Errno 2] No such file or directory", "rc": 2}