Carmine Fabrizio
Carmine Fabrizio

Reputation: 21

Define variable in Jinja template

I have this loop

{% for node in groups['PROXY'] %}
{% if ansible_default_ipv4 != hostvars[node].ansible_ssh_host %}
  {{ hostvars[node].ansible_ssh_host }}
{% endif %}
{% endfor %}

very simple, my question is, how can I change this

groups['PROXY']

in a variable that I could define in my vars/main.yml?

Upvotes: 1

Views: 998

Answers (1)

aaldilai
aaldilai

Reputation: 271

Try group: "{{ groups['PROXY'] }}"

This will tell ansible to store the value of the variable groups (because of the the brackets), as opposed to a string (without the brackets)

Upvotes: 1

Related Questions