# volumes parameter in ec2 module

**URL:** <https://forum.ansible.com/t/volumes-parameter-in-ec2-module/14590>\
**Category:** Ansible Project\
**Created:** [February 18, 2014, 12:57pm UTC](https://forum.ansible.com/t/volumes-parameter-in-ec2-module/14590 "2014-02-18T12:57:08Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [February 18, 2014, 12:57pm UTC](https://forum.ansible.com/t/volumes-parameter-in-ec2-module/14590/1 "2014-02-18T12:57:08Z")

</div>

Hello,

I am trying to create an ec2 instance with specific volumes requirement … but I keep getting a “this module requires key=value arguments” error message.  
Looking closer at ansible output (see below), it looks like the single-quoting of the volumes parameter is a little bit “fancy”…

Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 18, 2014, 1:48pm UTC](https://forum.ansible.com/t/volumes-parameter-in-ec2-module/14590/2 "2014-02-18T13:48:38Z")

</div>

When using the ec2 module it’s almost always easier to use the complex arguments style as shown in the examples.

If you are going to pass typed data to modules (like “volumes”), that is going to be required.

---

<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:** [February 18, 2014, 4:00pm UTC](https://forum.ansible.com/t/volumes-parameter-in-ec2-module/14590/3 "2014-02-18T16:00:19Z")

</div>

Hi Michael,

Thanks for your help.  
… I am not sure to understand though …

I tried to copy the example given on [doc.ansible.com](http://doc.ansible.com):

```auto
local_action:
    module: ec2
    keypair: mykey
    group: webserver
    instance_type: m1.large
    image: ami-6e649707
    wait: yes
    wait_timeout: 500
    volumes:
    - device_name: /dev/sdb
      snapshot: snap-abcdef12
      device_type: io1
      iops: 1000
      volume_size: 100

```

and I get the following error:

ERROR: parse error: playbooks must be formatted as a YAML list, got \<type 'dict’\>

Then I tried with

volumes: [{ device\_name: ‘/dev/sda1’, volume\_size: ‘10’ }, { device\_name: ‘/dev/xvdf’, ephemeral: ‘ephemeral0’ }, { device\_name: ‘/dev/xvdg’, volume\_size: ‘25’}]

and

volumes:

- { device\_name: ‘/dev/sda1’, volume\_size: ‘10’ },
- { device\_name: ‘/dev/xvdf’, ephemeral: 'ephemeral0’ }
- { device\_name: ‘/dev/xvdg’, volume\_size: '25’}

And with both, I get:

msg: this module requires key=value arguments ([‘key\_name=GenericLinux’, ‘image=ami-75342c01’, ‘instance\_type=m1.small’, ‘vpc\_subnet\_id=subnet-81407bf5’, ‘user\_data={shortname:test4, hostname:test4.[aws.onlotaris.com](http://aws.onlotaris.com)}’, ‘wait\_timeout=500’, ‘private\_ip=172.16.4.100’, ‘wait=yes’, ‘group=default’, ‘count=1’, ‘state=present’, ‘instance\_tags={“Name”:“test4”}’, ‘volumes=[{volume\_size:’, ‘10,’, ‘device\_name:’, ‘/dev/sda1},’, ‘{ephemeral:’, ‘ephemeral0,’, ‘device\_name:’, ‘/dev/xvdf},’, ‘{volume\_size:’, ‘25,’, ‘device\_name:’, ‘/dev/xvdg}]’])

Thanks in advance.

Fred

---

<div class="post-metadata">

**Author:** ![David\_Adams](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@David\_Adams](https://forum.ansible.com/u/David_Adams)\
**Post date:** [February 18, 2014, 5:31pm UTC](https://forum.ansible.com/t/volumes-parameter-in-ec2-module/14590/4 "2014-02-18T17:31:00Z")

</div>

That snippet of code you posted isn’t a complete playbook. You need at least:

- hosts: myhost  
tasks:
- local\_action: …

---

<div class="post-metadata">

**Author:** ![Paul\_Durivage](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Paul\_Durivage](https://forum.ansible.com/u/Paul_Durivage)\
**Post date:** [February 18, 2014, 10:24pm UTC](https://forum.ansible.com/t/volumes-parameter-in-ec2-module/14590/5 "2014-02-18T22:24:45Z")

</div>

Hi Fred,

In your first example, you **did not quote your variables in the play** :

tasks:

- name: create instance  
ec2: key\_name={{ keypair }} image={{ image }} instance\_type={{ instance\_type }} vpc\_subnet\_id={{ subnet }} user\_data=‘{“shortname”:“{{ hostname }}”, “hostname”:“{{ hostname }}.{{ dnsdomain }}”}’ wait\_timeout=500 private\_ip={{ ip }} wait=yes group={{ group }} count=1 state=present volumes={{ volumes }}

The second error you received:

ERROR: parse error: playbooks must be formatted as a YAML list, got \<type 'dict’\>

This error means that you likely did not format your playbook into a list of plays. The format should be as David Adams previously described.
