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...
{% endfor %}
}
And it works well.
But when I try to parametrize inventory group name like this:
upstream portal {
{% set nodes = groups["{{cluster_name}}"] %}
{% for node in nodes %}
...do something with nodes...
{% endfor %}
}
I get an exception like:
FAILED! => {"changed": false, "failed": true, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute '{{cluster_name}}'"}
Here, cluster_name - is a simple string variable defined in defaults section.
Is it possible to parametrize it at all?
Thanks in advance!