How to resolve the variable reference conflict between n8n and ansible?

Ansible uses the {{ aa }} format to reference variables, but n8n also uses this format, causing commands to not be transmitted to the SSH node at all. How can this be resolved?

Hi @bfbz, welcome!
This is because n8n processes anything in between {{ }} as JavaScript, so instead of {{ aa }}, try this:
{{ '{' + '{' + ' aa ' + '}' + '}' }}
And this should work, but you can also just construct the whole command:
ansible-playbook site.yml -e "var={{ '{' + '{' + ' aa ' + '}' + '}' }}"

Hi @bfbz. In my experience, if n8n can’t see the actual schema value declared in a previous node, it will tag it as undefined. I experienced something similar sending dynamic variables to Vapi.

So, make sure the value is actually being passed from a previous n8n node.

If the value comes dynamically, store it first through a Set node, database node, or another node that outputs it before referencing it.

This way, n8n can see and use the actual value.

there are multiple options.
One was provided by @Anshul_Namdev

another one is using the escaping syntax:

msg={"host_ip": "{{ '\{\{ ansible_host \}\}' }}", "host_group": "{{ '\{\{ group_names \}\}' }}"}

But with JSON it’s always better to use JSON.stringify:

msg={{ 
JSON.stringify({ 
  host_ip: "{{ ansible_host }\}", 
  host_group: "{{ group_names }\}" 
}) 
}}

Welcome to the n8n community @bfbz

these docs can help: