# Loop until with delay: {{ variable.json.counter}}

**URL:** <https://forum.ansible.com/t/loop-until-with-delay-variable-json-counter/13985>\
**Category:** Ansible Project\
**Created:** [November 23, 2013, 5:43am UTC](https://forum.ansible.com/t/loop-until-with-delay-variable-json-counter/13985 "2013-11-23T05:43:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [November 23, 2013, 5:43am UTC](https://forum.ansible.com/t/loop-until-with-delay-variable-json-counter/13985/1 "2013-11-23T05:43:13Z")

</div>

Hi.

I’m running my playbook to get akamai to clear some caches and I’m using theit REST API that return json.

now I’m running into a problem with a look that I want to delay for X amount of seconds and X is part of the json response from the api so I’m doing something like :

- name: Wait for akamai to clear  
action: uri url=[https://api.ccu.akamai.com](https://api.ccu.akamai.com){{akamairesponse.json.progressUri}}  
method=GET user=xxx password=xxx  
HEADER\_Content-Type=“application/json”  
status\_code=200  
return\_content=yes  
register: akamaistatus  
#- debug: msg=“value of status {{akamaistatus.json.purgeStatus}}”  
until: “‘{{akamaistatus.json.purgeStatus}}’ == ‘Done’”  
retries: 10  
#delay: 60  
delay: ‘{{akamairesponse.json.estimatedSeconds|int}}’

debug shows :

TASK: [debug msg=“value of {{akamairesponse.json.estimatedSeconds|int}}”] \*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “value of 420”  
}

but when I run the playbook I get this :

TASK: [Wait for akamai to clear] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
 EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-1385160064.24-173468909890043 && chmod a+rx $HOME/.ansible/tmp/ansible-1385160064.24-173468909890043 && echo $HOME/.ansible/tmp/ansible-1385160064.24-173468909890043’]  
 REMOTE\_MODULE uri url=[https://api.ccu.akamai.com/ccu/v2/purges/ef63d1a5-5401-11e3-8c54-712f0c54712f](https://api.ccu.akamai.com/ccu/v2/purges/ef63d1a5-5401-11e3-8c54-712f0c54712f) method=GET user=xxx password=xxx HEADER\_Content-Type=“application/json” status\_code=200 return\_content=yes  
 PUT /tmp/tmpctvzt8 TO /usr/home/jamengual/.ansible/tmp/ansible-1385160064.24-173468909890043/uri  
 EXEC [‘/bin/sh’, ‘-c’, ‘/usr/local/bin/python /usr/home/jamengual/.ansible/tmp/ansible-1385160064.24-173468909890043/uri; rm -rf /usr/home/jamengual/.ansible/tmp/ansible-1385160064.24-173468909890043/ \>/dev/null 2\>&1’]  
fatal: [localhost] =\> Traceback (most recent call last):  
File “/usr/local/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 394, in \_executor  
exec\_rc = self.\_executor\_internal(host, new\_stdin)  
File “/usr/local/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 485, in \_executor\_internal  
return self.\_executor\_internal\_inner(host, self.module\_name, self.module\_args, inject, port, complex\_args=complex\_args)  
File “/usr/local/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 688, in \_executor\_internal\_inner  
time.sleep(delay)  
TypeError: a float is required

FATAL: all hosts have already failed – aborting

I tried using jinga2 filter as float and int and it doesn’t work is there a limitation with loops delay variables ?

Thanks.

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [November 23, 2013, 2:14pm UTC](https://forum.ansible.com/t/loop-until-with-delay-variable-json-counter/13985/2 "2013-11-23T14:14:22Z")

</div>

Hello,

I think this case was not coded in the handling of delay.  
example:

delay: 60

=\> ok

delay: “60”

=\>TypeError: a float is required

delay: !!float “60”

=\> ok

unfortunately the YAML cast cannot work in your case since yaml will complain that your string cannot be cast to float.

maybe others can confirm

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 23, 2013, 3:27pm UTC](https://forum.ansible.com/t/loop-until-with-delay-variable-json-counter/13985/3 "2013-11-23T15:27:03Z")

</div>

Hi guys,

Bugs get filed on github, not the mailing list.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [November 23, 2013, 3:34pm UTC](https://forum.ansible.com/t/loop-until-with-delay-variable-json-counter/13985/4 "2013-11-23T15:34:29Z")

</div>

you seem to confirm this is a bug  
bug filed : [https://github.com/ansible/ansible/issues/5031](https://github.com/ansible/ansible/issues/5031)

thanks

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [November 23, 2013, 4:53pm UTC](https://forum.ansible.com/t/loop-until-with-delay-variable-json-counter/13985/5 "2013-11-23T16:53:55Z")

</div>

Well I didn’t know that was a bug :)…until now.
