# How to loop over these items ?

**URL:** <https://forum.ansible.com/t/how-to-loop-over-these-items/19099>\
**Category:** Ansible Project\
**Created:** [August 24, 2015, 6:24pm UTC](https://forum.ansible.com/t/how-to-loop-over-these-items/19099 "2015-08-24T18:24:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Syx](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@Julien\_Syx](https://forum.ansible.com/u/Julien_Syx)\
**Post date:** [August 24, 2015, 6:24pm UTC](https://forum.ansible.com/t/how-to-loop-over-these-items/19099/1 "2015-08-24T18:24:46Z")

</div>

Hello everyone,

I’m trying to create a role to manage backup with this script: [https://github.com/redhat-cip/simple\_ec2\_snapshot](https://github.com/redhat-cip/simple_ec2_snapshot)

I would like to take in parameter a tags list (for example), then create a cron with the right command line.

How to iterate over the list and construct my command for my cron line please ?

For example, having :  
tags:

- { key: Name, value: test }

- { key: env, value: prod }

And generate something like :

- cron: name=“check dirs” minute=“0” hour=“5,2” job=“simplec2snap.py {{ tags\_loop }}” =\> job= “simplec2snap.py -t Name test -t env prod”

Thanks for giving me a clue 😉

Cheers
