Given the following example list and Jinja template:
List:
list:
- foo
- bar
Jinja template:
{% for key in list %}
results:
- "{{ key }}"
{% endfor %}
I am able to produce the following output:
results:
- foo
results:
- bar
How can I instead append a line, for each item in the list, to the template to produce this result?
results:
- foo
- bar
Is this possible with Ansible without using something like lineinfile
? I am moreorless trying to replicate the Helm range filter which might look like this:
results:
{{- range .Values.list }}
- {{ . }}
{{- end }}
The join
filter appears to get me a little closer. For example:
results:
- "{{ list | join('\n- ') }}"
Produces the following. But it is not syntactically correct yet:
results:
- "foo
- bar"