I am trying to do the following where I index groups by a variable instead of hardcoding it. Is that possible somehow?
{% for host in groups[‘{{VAR}}’] %}
STUFF
{% endfor %}
Thanks in advance,
Edgardo
I am trying to do the following where I index groups by a variable instead of hardcoding it. Is that possible somehow?
{% for host in groups[‘{{VAR}}’] %}
STUFF
{% endfor %}
Thanks in advance,
Edgardo
You can’t nest jinja2 delimiters. You just use bare variable names inside such as:
{% for host in groups[VAR] %}
I figured it out. You can just do the following and it will work.
{% for host in groups[VAR] %}
Thanks Matt! is there way to do this in a playbook. The first one works the second one doesn’t.
debug: msg=“hey {{ item }}”
with_items: groups[‘tag_env_prod’]
debug: msg=“hey {{ item }}”
with_items: groups[‘{{group_name}}’]
- debug: msg="hey {{ item }}"
with_items: "{{groups[group_name]}}"