# Ansible template for loop any given number of iterations

**URL:** <https://forum.ansible.com/t/ansible-template-for-loop-any-given-number-of-iterations/15387>\
**Category:** Ansible Project\
**Created:** [June 2, 2014, 10:25am UTC](https://forum.ansible.com/t/ansible-template-for-loop-any-given-number-of-iterations/15387 "2014-06-02T10:25:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Faisal\_Ali\_Rabbani](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Faisal\_Ali\_Rabbani](https://forum.ansible.com/u/Faisal_Ali_Rabbani)\
**Post date:** [June 2, 2014, 10:25am UTC](https://forum.ansible.com/t/ansible-template-for-loop-any-given-number-of-iterations/15387/1 "2014-06-02T10:25:43Z")

</div>

I am running a for lo0p in creating file via ansible template.

If I hard code my loop count everything works fine.

> {% for x in range(0,3) %}  
> Value of x is : {{x}}  
> {% endfor %}

But as I give dinamic value it gives error

> {% for x in range(0,{{count}}) %}  
> Value of x is : {{x}}  
> {% endfor %}

fatal: [localhost] =\> {‘msg’: “file: ~/playbook.yml, line number: 23, error: expected token ‘:’, got ‘}’”, ‘failed’: True},

Any suggestion please.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [June 3, 2014, 2:10am UTC](https://forum.ansible.com/t/ansible-template-for-loop-any-given-number-of-iterations/15387/2 "2014-06-03T02:10:58Z")

</div>

you are ‘overtemplating’, you don’t need {{}} inside {% %}​
