Issue escaping curly braces in template file

Hey. I am having a bit of trouble trying to convert a jinja template because of the some issues escaping curly braces. Consider this simple jinja template that is currently returning an error:

activationID: {{{ lookup(‘ansible.builtin.env’, ‘QUALYS_ACTIVATIONID’) }}}
CustomerID: {{{ lookup(‘ansible.builtin.env’, ‘QUALYS_CUSTOMERID’) }}}

As you can see, there is an environment variable storing a string value that I need, but the final string that my playbook needs is that value surrounded by single curly brackets, eg:

{34-34-456-34}

I have tried various methods I found online to attempt to get ansible to properly convert the jinja template, including:

Example 1:
activationID: {{{ lookup(‘ansible.builtin.env’, ‘QUALYS_ACTIVATIONID’) }}}
CustomerID: {{{ lookup(‘ansible.builtin.env’, ‘QUALYS_CUSTOMERID’) }}}

Example 2:
activationID: “{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_ACTIVATIONID’) }}}”
CustomerID: “{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_CUSTOMERID’) }}}”

Example 3:
activationID: “{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_ACTIVATIONID’) }}}”
CustomerID: “{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_CUSTOMERID’) }}}”

But no matter what I try, I keep getting this error:

The error was: . expected token ‘:’, got '}
I did notice some interesting output from ansible regarding how the template is being parsed as I ran the examples listed above. For example, the output when I ran example 1:
String: activationID: \{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_ACTIVATIONID’) }}\}\nCustomerID: \{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_CUSTOMERID’) }}\}\n. expected token ‘:’, got ‘}’"

As you can see, "" which I want to escape the outer most curly brace is itself being automatically escaped by ansible. Same when I run example 3:

“msg”: “AnsibleError: template error while templating string: expected token ‘:’, got ‘}’. String: activationID: "\{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_ACTIVATIONID’) }}\}"\nCustomerID: "\{{{ lookup(‘ansible.builtin.env’, ‘QUALYS_CUSTOMERID’) }}\}"\n. expected token ‘:’, got ‘}’”

I am at a loss as to what to do here. Any help would be awesome.

Maybe try these expressions:

{{ '{' ~ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') ~ '}' }}
{{ '{' ~ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') ~ '}' }}

If you need this a lot then you could even dedicate a filter to it.
For example, create a directory called ‘filter_plugins’ adjacent to your playbook and then create a file called ‘filters.py’ that contains:

def embrace(string):
return ‘{’ + string + ‘}’
class FilterModule(object):
def filters(self):
return {
‘embrace’: embrace
}

Now you can do:

activationID: “{{ lookup(‘ansible.builtin.env’, ‘QUALYS_ACTIVATIONID’) | embrace }}”
CustomerID: “{{ lookup(‘ansible.builtin.env’, ‘QUALYS_CUSTOMERID’) | embrace }}”

Dick