I am trying to pass JSON string in environment.
- name: Start {{service_name}}
shell: \"<> --server.port={{service_por
There is a thing about Ansible template engine.
If a string seems like an object (starts with { or [) Ansible converts it into object. See code.
To prevent this, you may use one of STRING_TYPE_FILTERS:
- SPRING_APPLICATION_JSON: "{{ {'test-host.1':test_host_1,'test-host.2':test_host_2} | to_json }}"
P.S. this is why hack with space character from @techraf's answer works: Ansible misses startswith("{") comparison and don't convert string to object.