Repository: ansible/ansible

Issue:
ec2_vol is unable to create larger volumes from snapshots
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ec2_vol

##### ANSIBLE VERSION
```
ansible 2.3.1.0

```

##### CONFIGURATION
Default configuration

##### OS / ENVIRONMENT
Ubuntu  16.04.2 but it's not relevant

##### SUMMARY
Creating a new larger EBS volume from a snapshot using ec2_vol module, produces an error:
"Cannot specify volume_size together with id or snapshot"

##### STEPS TO REPRODUCE
Use the following task to reproduce:

```yaml
- name: Create volume and restore from snapshot
  ec2_vol:
    volume_size: 10
    volume_type: standard
    instance: XXXXXXXX
    snapshot: XXXXXXXXXXXXX
    device_name: "/dev/sdX"
```


##### EXPECTED RESULTS
A new larger EBS volume should be created by the snapshot

##### ACTUAL RESULTS

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Cannot specify volume_size together with id or snapshot"}
--

##### SOLUTION
ansible/lib/ansible/modules/cloud/amazon/ec2_vol.py
lines 612, 613

ORIGINAL:
```
if volume_size and (id or snapshot):
        module.fail_json(msg="Cannot specify volume_size together with id or snapshot")
```
CHANGE TO:
```
if volume_size and id :
        module.fail_json(msg="Cannot specify volume_size together with id ")
```


ec2_vol is unable to create larger volumes from snapshots
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ec2_vol

##### ANSIBLE VERSION
```
ansible 2.3.1.0

```

##### CONFIGURATION
Default configuration

##### OS / ENVIRONMENT
Ubuntu  16.04.2 but it's not relevant

##### SUMMARY
Creating a new larger EBS volume from a snapshot using ec2_vol module, produces an error:
"Cannot specify volume_size together with id or snapshot"

##### STEPS TO REPRODUCE
Use the following task to reproduce:

```yaml
- name: Create volume and restore from snapshot
  ec2_vol:
    volume_size: 10
    volume_type: standard
    instance: XXXXXXXX
    snapshot: XXXXXXXXXXXXX
    device_name: "/dev/sdX"
```


##### EXPECTED RESULTS
A new larger EBS volume should be created by the snapshot

##### ACTUAL RESULTS

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Cannot specify volume_size together with id or snapshot"}
--

##### SOLUTION
ansible/lib/ansible/modules/cloud/amazon/ec2_vol.py
lines 612, 613

ORIGINAL:
```
if volume_size and (id or snapshot):
        module.fail_json(msg="Cannot specify volume_size together with id or snapshot")
```
CHANGE TO:
```
if volume_size and id :
        module.fail_json(msg="Cannot specify volume_size together with id ")
```




Discussion:
cc @willthames @s-hertel 
cc @lwade
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @willthames @s-hertel 
cc @lwade
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_vol.py b/lib/ansible/modules/cloud/amazon/ec2_vol.py
--- a/lib/ansible/modules/cloud/amazon/ec2_vol.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_vol.py
@@ -609,8 +609,8 @@ def main():
     if not volume_size and not (id or name or snapshot):
         module.fail_json(msg="You must specify volume_size or identify an existing volume by id, name, or snapshot")
 
-    if volume_size and (id or snapshot):
-        module.fail_json(msg="Cannot specify volume_size together with id or snapshot")
+    if volume_size and id:
+        module.fail_json(msg="Cannot specify volume_size together with id")
 
     if state == 'present':
         volume, changed = create_volume(module, ec2, zone)


Test patch: