Merge pull request #7410 from willthames/ec2_vol_fix_error_check
Fix parameters check for ec2_vol
This commit is contained in:
commit
2084629dee
1 changed files with 9 additions and 3 deletions
|
@ -325,9 +325,6 @@ def main():
|
||||||
if id and name:
|
if id and name:
|
||||||
module.fail_json(msg="Both id and name cannot be specified")
|
module.fail_json(msg="Both id and name cannot be specified")
|
||||||
|
|
||||||
if not (id or name or volume_size):
|
|
||||||
module.fail_json(msg="Cannot specify volume_size and either one of name or id")
|
|
||||||
|
|
||||||
# Here we need to get the zone info for the instance. This covers situation where
|
# Here we need to get the zone info for the instance. This covers situation where
|
||||||
# instance is specified but zone isn't.
|
# instance is specified but zone isn't.
|
||||||
# Useful for playbooks chaining instance launch with volume create + attach and where the
|
# Useful for playbooks chaining instance launch with volume create + attach and where the
|
||||||
|
@ -345,6 +342,15 @@ def main():
|
||||||
device=device_name,
|
device=device_name,
|
||||||
changed=False)
|
changed=False)
|
||||||
|
|
||||||
|
# Delaying the checks until after the instance check allows us to get volume ids for existing volumes
|
||||||
|
# without needing to pass an unused volume_size
|
||||||
|
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")
|
||||||
|
|
||||||
|
if volume_size and (id or name):
|
||||||
|
module.fail_json(msg="Cannot specify volume_size and either one of name or id")
|
||||||
|
|
||||||
|
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
delete_volume(module, ec2)
|
delete_volume(module, ec2)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue