I’m sorry if this has come up before - I couldn’t find any answers directly related to my question.
I’m trying to use set_fact to set an array and use that in a for loop inside a template file.
In my playbook I have:
set_fact: av_name=“[‘av1’, ‘av2’, ‘av3’]”
And in my template file I’m testing with:
{% for item in av_name %}
“this”: “{{ item }}”
{% endfor %}
Here’s my templated file - jinja2 doesn’t seem to understand the array:
“this”: “[”
“this”: “'”
“this”: “a”
“this”: “v”
“this”: “1”
“this”: “'”
“this”: “,”
“this”: " "
“this”: “'”
“this”: “a”
“this”: “v”
“this”: “2”
“this”: “'”
“this”: “,”
“this”: " "
“this”: “'”
“this”: “a”
“this”: “v”
“this”: “3”
“this”: “'”
“this”: “]”
Hopefully I’m doing something wrong!