Counter in with_items loop ?

Hi list,

Is there a way to have a counter with the with_items loop ?

The idea would be to create several cron job not starting all at the same time.

tasks:

  • name: “Install some cron jobs”
    cron: name=“job {{ item }}” min=“COUNTER??” hour=“3” user=root cron_file=“myjobs” job=“/path/to/some/script {{ item }}”
    with_items: somelist

the result could look like so:

#Ansible: job item1
1 3 * * * root /path/to/some/script item1
#Ansible: job item2
2 3 * * * root /path/to/some/script item2
#Ansible: job item3
3 3 * * * root /path/to/some/script item3

any suggesstions ?

Many thanks,

Julien.

I think you look for this:

http://docs.ansible.com/playbooks_loops.html#looping-over-a-list-with-an-index

I was on this page, but somehow I missed it.

Thank you !