# unable to specify volumes for new instance

**URL:** <https://forum.ansible.com/t/unable-to-specify-volumes-for-new-instance/14690>\
**Category:** Ansible Project\
**Created:** [March 4, 2014, 4:03am UTC](https://forum.ansible.com/t/unable-to-specify-volumes-for-new-instance/14690 "2014-03-04T04:03:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![i\_iordanov](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@i\_iordanov](https://forum.ansible.com/u/i_iordanov)\
**Post date:** [March 4, 2014, 4:03am UTC](https://forum.ansible.com/t/unable-to-specify-volumes-for-new-instance/14690/1 "2014-03-04T04:03:17Z")

</div>

Hi guys,

I’m stuck with an issue and hoping somebody can spot my mistake. I have a task like the following where I’m trying to specify a volume for the ec2 instance.

tasks:

- name: Start instance  
ec2: image=ami-xxxx  
count=1  
aws\_access\_key=xxx  
aws\_secret\_key=yyy  
.  
.  
volumes=‘{ “device\_name”:/dev/sdb, “volume\_size”:“10” }’  
wait=true

No matter what syntax I try, ansible refuses to accept my specification. I can’t specify a single, let alone multiple volumes. Can anybody tell me what the syntax should look like?

Many thanks!  
iordan

---

<div class="post-metadata">

**Author:** ![Fred\_Badel](https://avatars.discourse-cdn.com/v4/letter/f/f07891/32.png) [@Fred\_Badel](https://forum.ansible.com/u/Fred_Badel)\
**Post date:** [March 4, 2014, 8:09am UTC](https://forum.ansible.com/t/unable-to-specify-volumes-for-new-instance/14690/2 "2014-03-04T08:09:40Z")

</div>

Hi,

I had some trouble putting everything together with the ec2 module …  
with the help of the list I finally got it working.

As Michael pointed out, with the ec2 module, it is easier to use complex arguments style.

This is a working example:

- hosts: 127.0.0.1  
connection: local  
gather\_facts: True  
vars:  
…  
tasks:
- name: create a vm  
local\_action:  
module: ec2  
image: “{{ image }}”  
count: 1  
instance\_type: “{{ instance\_type }}”  
group: “{{ group }}”  
key\_name: “{{ keypair }}”  
vpc\_subnet\_id: “{{ subnet }}”  
private\_ip: “{{ ip }}”  
user\_data: “{{ hostname }}.{{ dnsdomain }}”  
instance\_tags: ‘{“Name”:“{{ hostname }}”}’  
volumes:
- device\_name: /dev/sda1  
volume\_size: 10
- device\_name: /dev/sdb  
ephemeral: ephemeral0
- device\_name: /dev/sdc  
volume\_size: 25  
wait: true  
wait\_timeout: 500  
state: present  
register: ec2

Hope this help.

Fred

---

<div class="post-metadata">

**Author:** ![i\_iordanov](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@i\_iordanov](https://forum.ansible.com/u/i_iordanov)\
**Post date:** [March 6, 2014, 1:38pm UTC](https://forum.ansible.com/t/unable-to-specify-volumes-for-new-instance/14690/3 "2014-03-06T13:38:38Z")

</div>

Hi Fred,

Thank you very much, your suggestion to use complex arguments style was spot on. However, for some reason I couldn’t get the parser to accept local\_action and my rule took on yet a different form. Here it is, in case it helps somebody!

- name: Make {{ hostname }}  
ec2:  
image: “{{ ami }}”  
id: “{{ hostname }}”  
instance\_tags: ‘{“Name”:“{{ hostname }}”, “type”:“{{ group }}”}’  
instance\_type: “{{ type }}”  
count: “{{ count }}”  
aws\_access\_key: “{{ ec2\_access\_key }}”  
aws\_secret\_key: “{{ ec2\_secret\_key }}”  
region: “{{ region }}”  
keypair: “{{ keypair }}”  
group\_id: “{{ group\_id }}”  
vpc\_subnet\_id: “{{ vpc\_subnet\_id }}”  
volumes:
- device\_name: “{{ root\_dev\_name }}”  
volume\_size: “{{ root\_dev\_size }}”  
state: present  
wait: true  
register: machine\_info  
delegate\_to: 127.0.0.1
