# newbie to ansible

**URL:** <https://forum.ansible.com/t/newbie-to-ansible/32614>\
**Category:** Ansible Project\
**Created:** [April 7, 2020, 4:59am UTC](https://forum.ansible.com/t/newbie-to-ansible/32614 "2020-04-07T04:59:36Z")\
**Posts on this page:** 3\
**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:59am UTC](https://forum.ansible.com/t/newbie-to-ansible/32614/1 "2020-04-07T04:59:36Z")

</div>

I have the below playbook which creates 20 volumes

i have parameter called **type** which has 2 values [rw and dp].

my req is: how to create 10 volumes with type rw and 10 volumes type dp in one playbook.

tasks:

- name: Create FlexVol  
na\_ontap\_volume:  
state: absent  
name: vol1{{item}}  
is\_infinite: False  
aggregate\_name: aggr1  
**type** :  
size: 10  
size\_unit: gb  
junction\_path: “/vol{{ item }}”  
tiering\_policy: auto  
policy: default  
percent\_snapshot\_space: 20  
vserver: systemic\_iscsi\_aggr3svm1  
wait\_for\_completion: True  
space\_slo: none  
nvfail\_enabled: False  
comment: ansible created volume  
hostname: “{{aiqumip }}”  
username: “{{ aiqumusername }}”  
password: “{{ aiqumpassword }}”  
with\_sequence: start=1 end=20  
loop\_control:  
loop\_var: volume\_item  
register: volcreate  
ignore\_errors: True
- name: 100 volumes created successfully  
debug: msg “{{ volcreate }}”

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [April 7, 2020, 5:18am UTC](https://forum.ansible.com/t/newbie-to-ansible/32614/2 "2020-04-07T05:18:00Z")

</div>

An option would be the "ternary" filter. For example  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_filters.html#id8](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#id8)

&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: Create FlexVol  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;na\_ontap\_volume:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type: "{{ (volume\_item|int \< 11)|ternary('rw', 'dp') }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_sequence: start=1 end=20  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop\_control:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop\_var: volume\_item

HTH,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [April 7, 2020, 1:32pm UTC](https://forum.ansible.com/t/newbie-to-ansible/32614/3 "2020-04-07T13:32:18Z")

</div>

Yes. It's possible. Fit the condition to your needs. For example

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type: "{{ (volume\_item|int is odd)|ternary('rw', 'dp') }}"

HTH,

&nbsp;&nbsp;-vlado
