Template lookup formatting JSON to be passed on to shell module

Hi all,

I've lost the entire day on this and got nowhere...

I have a JSON file parameter that needs to be passed to aws CLI utility as a
file, and I'm trying to avoid creating temp files using bash here files.

Basically, I want to pass this to the shell module:

"bash -c 'aws s3api put-bucket-replication --profile {{ aws_profile }}
--bucket {{ vault_bucket_name }} --replication-configuration file://<(echo {{
lookup('template', 'this_is_my_template.json.j2') }})'"

with the lookup returning a single-line JSON string with double quotes.

I've tried using convert_data=false in the lookup, I've tried string and
to_json filters. I've tried adding a leading space at the beginning of the
template file, nothing worked.

I either get a string where fields are wrapped in u'', or I get escaped
newlines and double quotes that confuse bash. I've tried doing replace on the
resulting templated string, but it's very hard to see what's the actual string
being passed to the shell module, as any ansible output is JSON, so it gets
escaped back :slight_smile:

Thank you,