# ec2\_vol parameter checking is a bit too aggressive

**URL:** <https://forum.ansible.com/t/ec2-vol-parameter-checking-is-a-bit-too-aggressive/18352>\
**Category:** Ansible Developer\
**Created:** [May 30, 2015, 3:23pm UTC](https://forum.ansible.com/t/ec2-vol-parameter-checking-is-a-bit-too-aggressive/18352 "2015-05-30T15:23:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [May 30, 2015, 3:23pm UTC](https://forum.ansible.com/t/ec2-vol-parameter-checking-is-a-bit-too-aggressive/18352/1 "2015-05-30T15:23:50Z")

</div>

I am configuring a mongodb cluster on ec2. After first creating instances I create and attach an EBS volume to the instance. But I also want to be able to reattach the EBS volume to a replacement instance when needed.

desired:

`

- name: Create mongod instance  
ec2:  
image: “{{ubuntu\_image.ami}}”  
region: “{{ec2\_region}}”  
vpc\_subnet\_id: “{{vpc\_subnets.private|for\_count(item)}}”  
instance\_type: “{{mongod\_rs\_intance\_type}}”  
assign\_public\_ip: false  
group: “{{security\_groups}}”  
ebs\_optimized: “{{mongod\_rs\_ebs\_optimized}}”  
instance\_tags:  
Name: “{{env\_prefix}}mongod-{{item}}”  
mongod\_rs\_member: group  
env: “{{env}}”  
managed\_by: ansible  
exact\_count: 1  
count\_tag:  
Name: “{{env\_prefix}}mongod-{{item}}”  
key\_name: “{{aws\_key\_name}}”  
wait: yes  
register: ec2\_mongods  
with\_sequence: count={{mongod\_rs\_instance\_count}}

- name: Attach EBS volume to mongod instance  
ec2\_vol:  
instance: “{{item.1.id}}”  
name: “{{env\_prefix}}mongod-{{item[0].item}}”  
volume\_size: “{{mongod\_rs\_ebs\_volume\_size}}”  
volume\_type: “{{mongod\_rs\_ebs\_volume\_type}}”  
device\_name: “{{mongod\_rs\_ebs\_device\_name}}”  
register: ec2\_vol  
with\_subelements:

- ec2\_mongods.results

- tagged\_instances

`

But the ebs\_vol module will error because it does not allow setting both the volume\_size and name or id parameters. Looking at the code I cannot see why this need be so. There is no conflict in specifying both.

If the volume does not exist it will be created by create\_volume. In that case create\_volume only uses the id parameter for logging. If the volume does exist (and is not already mounted) is attached with attach\_volume, which does not use the volume.

So I copied the module and commented out the offending parameter checks.

`

# if not volume\_size and not (id or name):

# module.fail\_json(msg=“You must specify an existing volume with id or name or a volume\_size”)
