# with\_items and increment

**URL:** <https://forum.ansible.com/t/with-items-and-increment/25766>\
**Category:** Ansible Project\
**Created:** [October 17, 2017, 9:15pm UTC](https://forum.ansible.com/t/with-items-and-increment/25766 "2017-10-17T21:15:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parth\_Patel1](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@Parth\_Patel1](https://forum.ansible.com/u/Parth_Patel1)\
**Post date:** [October 17, 2017, 9:15pm UTC](https://forum.ansible.com/t/with-items-and-increment/25766/1 "2017-10-17T21:15:04Z")

</div>

I am trying to run this simple task where I want to increment counter for “{{ esb\_name }}_ESB_?” like “ABC\_ESB\_01, ABC\_ESB\_02 …etc” until the loop is over. How do I do that ? I tried nested and other loops but was not able to do it. Any suggestions ?

---

<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:** [October 18, 2017, 12:57pm UTC](https://forum.ansible.com/t/with-items-and-increment/25766/2 "2017-10-18T12:57:13Z")

</div>

Not pretty, but you could try this

- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: msg: "./client -a 8101 -h localhost -u admin -p admin 'fabric:container-create-child --profile {{ esb\_name }}\_CAML\_PRFL {{ fuseesbdomhosts[item | int] }} {{ esb\_name }}\_ESB\_{% if item | int \> 9 %}{{ item }}{% else %}0{{ item }}{% endif %}'"  
&nbsp;&nbsp;&nbsp;with\_sequence: start=0 end={{ groups['fuseesbdomhosts'] | length -1 }}

---

<div class="post-metadata">

**Author:** ![Parth\_Patel1](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@Parth\_Patel1](https://forum.ansible.com/u/Parth_Patel1)\
**Post date:** [October 18, 2017, 8:11pm UTC](https://forum.ansible.com/t/with-items-and-increment/25766/3 "2017-10-18T20:11:46Z")

</div>

Thanks!
