# recursive loop detected in template string problem

**URL:** <https://forum.ansible.com/t/recursive-loop-detected-in-template-string-problem/22805>\
**Category:** Ansible Project\
**Created:** [October 17, 2016, 12:30pm UTC](https://forum.ansible.com/t/recursive-loop-detected-in-template-string-problem/22805 "2016-10-17T12:30:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yosef\_Yudilevich](https://avatars.discourse-cdn.com/v4/letter/y/f08c70/32.png) [@Yosef\_Yudilevich](https://forum.ansible.com/u/Yosef_Yudilevich)\
**Post date:** [October 17, 2016, 12:30pm UTC](https://forum.ansible.com/t/recursive-loop-detected-in-template-string-problem/22805/1 "2016-10-17T12:30:50Z")

</div>

hi , how do i address CB.C1.COUNTER in CB.C1.BUCKETS\_DICT

vars file:

CB:  
C1:  
COUNT: 4  
BUCKETS\_DICT:

- { bucket\_name: “Test”, bucket\_type: ‘couchbase’, bucket\_port: ‘11211’, bucket\_ram\_quota: “{{ ( 800 / CB.C1[‘COUNT’] ) | int }}” }

task:

- name: create buckets  
run\_once: true  
shell: “/opt/couchbase/bin/couchbase-cli bucket-create -c 127.0.0.1:8091 --bucket={{ item.bucket\_name }} --bucket-type={{ item.bucket\_type }} --bucket-port={{ item.bucket\_port }} --bucket-ramsize={{ item.bucket\_ram\_quota }} -u {{ admin\_user }} -p {{ admin\_password }}”  
with\_items: “{{ CB.C1.BUCKETS\_DICT }}”

thanks

---

<div class="post-metadata">

**Author:** ![Yosef\_Yudilevich](https://avatars.discourse-cdn.com/v4/letter/y/f08c70/32.png) [@Yosef\_Yudilevich](https://forum.ansible.com/u/Yosef_Yudilevich)\
**Post date:** [October 19, 2016, 9:19am UTC](https://forum.ansible.com/t/recursive-loop-detected-in-template-string-problem/22805/2 "2016-10-19T09:19:26Z")

</div>

need help with this really  
cant move on with infrastructure  
pls help

---

<div class="post-metadata">

**Author:** ![Lukasz\_Gorski](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@Lukasz\_Gorski](https://forum.ansible.com/u/Lukasz_Gorski)\
**Post date:** [October 19, 2016, 1:17pm UTC](https://forum.ansible.com/t/recursive-loop-detected-in-template-string-problem/22805/3 "2016-10-19T13:17:35Z")

</div>

I can’t answer the dictionary lookup question directly. I suggest you use a flatter variable structure instead if you can, i.e.

cb\_c1\_count: 4  
cb\_c1\_buckets:

- name: ‘xxx’
- type: ‘yyy’
- quota: “{{ 800 / cb\_c1\_count | int }}”

This should avoid using self-referential lookups. Not quite elegant for large number of variables though.
