Looping through a Template

Hi,

I am new to ansible and new to the form.

I am wondering how to loop through a template

my template looks like this

{ item.sitename }}-test,{{ item.sitename }} description

and my variables look like this

Hi,

I think you are almost there.

You almost certainly don’t want to have ‘with_items’ on your template call. This will try to template once for each item in “{{parameters}}”. But “{{parameters}}” is already a list of things, and is going to be available to use in the template as a list, so I think you just need to make your template like this

{% item for in parameters %}
{ item.sitename }}-test,{{ item.sitename }} description
{% endfor %}

That should loop through “{{parameters}}” and put each templated item onto a new line I think (not tested).

Hope this helps,

Jon

Jon I actually got it with this

{% for myitem in item.sitename|list %}

I left my Task the same with with items but changed my VAR to an array