|
|
@ -34,6 +34,12 @@ options:
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
default: null
|
|
|
|
default: null
|
|
|
|
aliases: []
|
|
|
|
aliases: []
|
|
|
|
|
|
|
|
iops:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- the provisioned IOPs you want to associate with this volume (integer).
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: 100
|
|
|
|
|
|
|
|
aliases: []
|
|
|
|
device_name:
|
|
|
|
device_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- device id to override device mapping. Assumes /dev/sdf for Linux/UNIX and /dev/xvdf for Windows.
|
|
|
|
- device id to override device mapping. Assumes /dev/sdf for Linux/UNIX and /dev/xvdf for Windows.
|
|
|
@ -63,7 +69,15 @@ EXAMPLES = '''
|
|
|
|
instance: XXXXXX
|
|
|
|
instance: XXXXXX
|
|
|
|
volume_size: 5
|
|
|
|
volume_size: 5
|
|
|
|
device_name: sdd
|
|
|
|
device_name: sdd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Example using custom iops params
|
|
|
|
|
|
|
|
- local_action:
|
|
|
|
|
|
|
|
module: ec2_vol
|
|
|
|
|
|
|
|
instance: XXXXXX
|
|
|
|
|
|
|
|
volume_size: 5
|
|
|
|
|
|
|
|
iops: 200
|
|
|
|
|
|
|
|
device_name: sdd
|
|
|
|
|
|
|
|
|
|
|
|
# Playbook example combined with instance launch
|
|
|
|
# Playbook example combined with instance launch
|
|
|
|
- local_action:
|
|
|
|
- local_action:
|
|
|
|
module: ec2
|
|
|
|
module: ec2
|
|
|
@ -99,6 +113,7 @@ def main():
|
|
|
|
argument_spec = dict(
|
|
|
|
argument_spec = dict(
|
|
|
|
instance = dict(),
|
|
|
|
instance = dict(),
|
|
|
|
volume_size = dict(required=True),
|
|
|
|
volume_size = dict(required=True),
|
|
|
|
|
|
|
|
iops = dict(),
|
|
|
|
device_name = dict(),
|
|
|
|
device_name = dict(),
|
|
|
|
region = dict(),
|
|
|
|
region = dict(),
|
|
|
|
zone = dict(),
|
|
|
|
zone = dict(),
|
|
|
@ -110,6 +125,7 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
instance = module.params.get('instance')
|
|
|
|
instance = module.params.get('instance')
|
|
|
|
volume_size = module.params.get('volume_size')
|
|
|
|
volume_size = module.params.get('volume_size')
|
|
|
|
|
|
|
|
iops = module.params.get('iops')
|
|
|
|
device_name = module.params.get('device_name')
|
|
|
|
device_name = module.params.get('device_name')
|
|
|
|
region = module.params.get('region')
|
|
|
|
region = module.params.get('region')
|
|
|
|
zone = module.params.get('zone')
|
|
|
|
zone = module.params.get('zone')
|
|
|
@ -155,12 +171,20 @@ def main():
|
|
|
|
if device_name:
|
|
|
|
if device_name:
|
|
|
|
if device_name in inst.block_device_mapping:
|
|
|
|
if device_name in inst.block_device_mapping:
|
|
|
|
module.exit_json(msg="Volume mapping for %s already exists on instance %s" % (device_name, instance),
|
|
|
|
module.exit_json(msg="Volume mapping for %s already exists on instance %s" % (device_name, instance),
|
|
|
|
|
|
|
|
|
|
|
|
changed=False)
|
|
|
|
changed=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If custom iops is defined we use volume_type "io1" rather than the default of "standard"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if iops:
|
|
|
|
|
|
|
|
volume_type = 'io1'
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
volume_type = 'standard'
|
|
|
|
|
|
|
|
|
|
|
|
# If no instance supplied, try volume creation based on module parameters.
|
|
|
|
# If no instance supplied, try volume creation based on module parameters.
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = ec2.create_volume(volume_size, zone)
|
|
|
|
volume = ec2.create_volume(volume_size, zone, None, volume_type, iops)
|
|
|
|
while volume.status != 'available':
|
|
|
|
while volume.status != 'available':
|
|
|
|
time.sleep(3)
|
|
|
|
time.sleep(3)
|
|
|
|
volume.update()
|
|
|
|
volume.update()
|
|
|
|