# Iterate on more than one task: shell and pause

**URL:** <https://forum.ansible.com/t/iterate-on-more-than-one-task-shell-and-pause/17437>\
**Category:** Ansible Project\
**Created:** [February 4, 2015, 7:25am UTC](https://forum.ansible.com/t/iterate-on-more-than-one-task-shell-and-pause/17437 "2015-02-04T07:25:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tzach\_Livyatan](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@Tzach\_Livyatan](https://forum.ansible.com/u/Tzach_Livyatan)\
**Post date:** [February 4, 2015, 7:25am UTC](https://forum.ansible.com/t/iterate-on-more-than-one-task-shell-and-pause/17437/1 "2015-02-04T07:25:42Z")

</div>

Hello again  
I have a command to execute X times, pausing for a few second after each iteration.  
One (working) way to do it is:

`

- shell: sleep 60; the-command  
with\_sequence: count={{X}}  
`

But its look ugly to me:

- does not use built-in pause command
- make each of the host iterate independently, which may cause sync issue

I would like to do something like (not legal)

`

- shell: the-command  
action: pause: seconds=60  
with\_sequence: count={{X}}

`  
Using include for the two tasks didnt work either as include and with\_items is deprecated.

What is the right solution in this case?  
Thanks  
Tzach

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [February 4, 2015, 10:54am UTC](https://forum.ansible.com/t/iterate-on-more-than-one-task-shell-and-pause/17437/2 "2015-02-04T10:54:23Z")

</div>

I think your initial solution is the cleanest way to do this right now.

I was thinking if the shell module could be enhanced to accept a pause  
parameter, but I don't know how Ansible "unroll" the list of activities  
that should be carried out when there is looping involved. The module  
might not even know it's going to run multiple times (so then it  
couldn't pause anything, because it'd think it's running just once).

If that's the case, then perhaps the looping construct(s) would have to  
accept a pause parameter.

Perhaps something like the concept of "blocks" [1] being worked on in v2  
might help your situation. Create a block with a shell and a pause task  
and iterate over them.

[1] -  
[https://groups.google.com/d/msg/ansible-project/4IXdJqzhuM8/aGIJglZ8G\_4J](https://groups.google.com/d/msg/ansible-project/4IXdJqzhuM8/aGIJglZ8G_4J)

Giovanni

---

<div class="post-metadata">

**Author:** ![Tzach\_Livyatan](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@Tzach\_Livyatan](https://forum.ansible.com/u/Tzach_Livyatan)\
**Post date:** [February 4, 2015, 2:40pm UTC](https://forum.ansible.com/t/iterate-on-more-than-one-task-shell-and-pause/17437/3 "2015-02-04T14:40:37Z")

</div>

Thanks Giovanni
