Escaping { character in a task that has an ansible variable

Hello all,

I have a task that need to run the command below:

ipa dnsrecord-add idm.example.com cluster --a-rec={192.0.2.40,192.0.2.41}

The problem is that the IPA and ansible both use the "{" character. I
have attempted to escape one of the "{" with a back slash, and ansible
is fine with that, but then the resulting command isn't valid as far
as IPA server is concerned.

How would you guys go about resolving this? This is what I am seeing.

# please read this.
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/linux_domain_identity_authentication_and_policy_guide/retrieve-existing-keytabs

    - name: Create a DNS FQDN that will be shared by both active and
replica systems

      shell: ipa dnsrecord-add eng.example.com {{service_username}}
--a-rec=[{{ cluster_IP|join(",") }}]

      delegate_to: "{{ipa_server}}"

      tags:

         - svn_load_balancing_1

TASK [svn : Create a DNS FQDN that will be shared by both active and
replica systems]

I don't now why you have those square brackets in there since you command should not have them according to your command on top.
To get the curly bracket in just use string concatenation.

--a-rec={{ '{' ~ ip | join(',') ~ '}' }}

Hello Kai Stian Olstad

further to this context, could you please advise how to escape square bracket from the output in ansible?