I have the next snippet in my role template:
upstream portal { {% set nodes = groups[\"my_dev_cluster\"] %} {% for node in nodes %} ...do something with nodes
You don't need {{...}} because you're already inside a jinja context (in this case, the {% set ... %} block. Just write:
{{...}}
{% set ... %}
{% set nodes = groups[cluster_name] %}