ansible - index counter with "with_item"

Hi,

I want to have a counter (incrementation) in “with_items” in order to look over a list (index).

ec2_metric_alarm:


description: ‘{{ item.ec2_alarm_description }}’
dimensions: ‘{{item.ec2_alarm_dimensions }}’

alarm_actions: ‘{{ ec2_scaling_policy_reg.results[0].arn }}’
with_items: ‘{{ ec2_metric_alarm_item }}’

Any suggestion?

thanks

Use with_indexed_items instead

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