Ansible template for loop any given number of iterations

194 views
Skip to first unread message

Faisal Ali Rabbani

unread,
Jun 2, 2014, 6:25:43 AM6/2/14
to ansible...@googlegroups.com
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.

Brian Coca

unread,
Jun 2, 2014, 10:11:01 PM6/2/14
to ansible...@googlegroups.com
you are 'overtemplating', you don't need {{}} inside {% %}​
Reply all
Reply to author
Forward
0 new messages