JSON user data when launching cloud instances?

Hi all,

Wondering if anyone else has seen this behavior and figured out a way around. I’m trying to pass in a json object at user_data when launching some VMs in both AWS and OpenStack. The role is very simple and looks like:

`

{
“role”: “node”,
“hostname”: “test-host-name-1”,
“clusterip”: “111.222.333.444”
}

`

where the values set here are information about other VMs booted and passed in to these newly created VMs. I tried to pass the user data in directly, but received errors and moved to passing the data in via the lookup module like:

`
user_data: “{{ lookup(‘template’, ‘master-user-data.j2’) }}”

`

This seems to work, but converts all of the strings in the JSON object to have single quotes instead of double quotes, therefore no longer being valid JSON.

Has anyone found a workaround to this behavior? I’m on Ansible 2.1.1.0.