# Ansible keepalived increment int

**URL:** <https://forum.ansible.com/t/ansible-keepalived-increment-int/26666>\
**Category:** Ansible Project\
**Created:** [February 5, 2018, 5:24pm UTC](https://forum.ansible.com/t/ansible-keepalived-increment-int/26666 "2018-02-05T17:24:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Owen\_Corcoran](https://avatars.discourse-cdn.com/v4/letter/o/977dab/32.png) [@Owen\_Corcoran](https://forum.ansible.com/u/Owen_Corcoran)\
**Post date:** [February 5, 2018, 5:24pm UTC](https://forum.ansible.com/t/ansible-keepalived-increment-int/26666/1 "2018-02-05T17:24:24Z")

</div>

Hi all

I have a template I've been working on for keepalived and as part of the template, I want to get it to loop through a list of virtual ips and sub interface eth0 based on the number of virtual ips to manage . What i have so far is below . Any one any ideas ?

virtual\_ipaddress {

#virtual IP

{% for item in keepalived\_virtual\_ip %}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ item.address }} dev eth0 label eth0:{{ file\_number | int + 1 }}

&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;track\_script {

&nbsp;&nbsp;&nbsp;&nbsp;haproxy

&nbsp;&nbsp;&nbsp;&nbsp;pingable\_check\_script

&nbsp;&nbsp;&nbsp;&nbsp;}

---

<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:** [February 5, 2018, 6:17pm UTC](https://forum.ansible.com/t/ansible-keepalived-increment-int/26666/2 "2018-02-05T18:17:09Z")

</div>

Check out the loop.depth or loop.depth0 varaible that is available in a for loop  
[http://jinja.pocoo.org/docs/2.10/templates/#for](http://jinja.pocoo.org/docs/2.10/templates/#for)
