# How to loop var number of times with Ansible 2.5

**URL:** <https://forum.ansible.com/t/how-to-loop-var-number-of-times-with-ansible-2-5/27135>\
**Category:** Ansible Project\
**Created:** [March 27, 2018, 7:38pm UTC](https://forum.ansible.com/t/how-to-loop-var-number-of-times-with-ansible-2-5/27135 "2018-03-27T19:38:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddrake2012](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@ddrake2012](https://forum.ansible.com/u/ddrake2012)\
**Post date:** [March 27, 2018, 7:38pm UTC](https://forum.ansible.com/t/how-to-loop-var-number-of-times-with-ansible-2-5/27135/1 "2018-03-27T19:38:32Z")

</div>

Hi,

Just looking over the new looping documentation for Ansible 2.5 and I’m not sure how to loop a var number of times. It seems that everything now needs to be a list that is fed into loop. We used to be able to run

“with\_sequence: count=var”

To loop var number of times. Is there any easy way to do this with the new schema?

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 27, 2018, 8:00pm UTC](https://forum.ansible.com/t/how-to-loop-var-number-of-times-with-ansible-2-5/27135/2 "2018-03-27T20:00:34Z")

</div>

You can still use the with\_sequence, it's not going away anytime soon and hopefully it will never go away because the new way is horrendous to type.

&nbsp;&nbsp;with\_sequence: count={{ var }}

equivalent with loop:

&nbsp;&nbsp;loop: "{{ lookup('sequence', 'count=' + var | string) | list }}"
