Iterate on more than one task: shell and pause

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

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

Giovanni

Thanks Giovanni