# looping through the 5 values

**URL:** <https://forum.ansible.com/t/looping-through-the-5-values/32623>\
**Category:** Ansible Project\
**Created:** [April 7, 2020, 4:47pm UTC](https://forum.ansible.com/t/looping-through-the-5-values/32623 "2020-04-07T16:47:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh\_g\_o](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mahesh\_g\_o](https://forum.ansible.com/u/mahesh_g_o)\
**Post date:** [April 7, 2020, 4:47pm UTC](https://forum.ansible.com/t/looping-through-the-5-values/32623/1 "2020-04-07T16:47:07Z")

</div>

I have below playbook which creates policy:

i have parameter called policy which has 5 values(" mirror", “vault”, “mirrorandvault”, “default”, “XDP”)  
i have put with\_sequence loop.  
i want this policy to be created with each loop.  
i tried ternary operator for 2 policies "type: “{{ (volume\_item|int \< 7)|ternary(‘mirror’, ‘vault’) }}” It worked.  
I am not sure about how to implement for 5 policies.

- hosts: localhost  
gather\_facts: false  
vars\_files:
- /etc/ansible/group\_vars/host\_vars

tasks:

- name: Create ONTAP/ONTAP SnapMirror  
na\_ontap\_snapmirror:  
state: present  
source\_volume: “{{ vserver }}vol\_{{ item }}”  
destination\_volume: “{{ vserver }}vol\_{{ item | int +15}}”  
source\_vserver: “{{ vserver }}”  
destination\_vserver: “{{ vserver }}”  
schedule: hourly  
policy:  
max\_transfer\_rate: 1000  
hostname: “{{ aiqumip }}”  
username: “{{ aiqumusername }}”  
password: “{{ aiqumpassword }}”  
with\_sequence: start=1 end=15
