# ec2\_vol create dynamic number

**URL:** <https://forum.ansible.com/t/ec2-vol-create-dynamic-number/17554>\
**Category:** Ansible Project\
**Created:** [February 18, 2015, 5:07pm UTC](https://forum.ansible.com/t/ec2-vol-create-dynamic-number/17554 "2015-02-18T17:07:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Olliver1](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@Mark\_Olliver1](https://forum.ansible.com/u/Mark_Olliver1)\
**Post date:** [February 18, 2015, 5:07pm UTC](https://forum.ansible.com/t/ec2-vol-create-dynamic-number/17554/1 "2015-02-18T17:07:09Z")

</div>

Hi,

How can I extend the following code to allow me to specify a number of additional volumes to add?

- name: create ec2 vols for raid  
local\_action: ec2\_vol  
instance=“{{ item[0].id }}”  
volume\_size=“{{ md\_vol\_size }}”  
device\_name=“{{ item[1] }}”  
region=“{{ item[0].region }}”  
with\_nested:
- ec2\_info.instances
- [‘xvdg’, ‘xvdh’, ‘xvdi’, ‘xvdj’]

I.e sometimes i might want just one additional volume but others i might want to attach 10 xvdg-p ideally based of a variable called ec2\_vol\_count=X

Thanks

Mark

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [February 20, 2015, 10:11am UTC](https://forum.ansible.com/t/ec2-vol-create-dynamic-number/17554/2 "2015-02-20T10:11:05Z")

</div>

Although not the nicest way to do it, I recon the with\_sequence could come in handy: [http://docs.ansible.com/playbooks\_loops.html#looping-over-integer-sequences](http://docs.ansible.com/playbooks_loops.html#looping-over-integer-sequences)
