mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Ability to specify new SSD EBS option
This commit is contained in:
parent
8a6a4a7757
commit
3f4d412bff
1 changed files with 19 additions and 3 deletions
|
@ -48,6 +48,13 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
aliases: []
|
aliases: []
|
||||||
|
volume_type:
|
||||||
|
description:
|
||||||
|
- Type of EBS volume; standard (magnetic), gp2 (SSD), io1 (Provisioned IOPS). "Standard" is the old EBS default
|
||||||
|
and continues to remain the Ansible default for backwards compatibility.
|
||||||
|
required: false
|
||||||
|
default: standard
|
||||||
|
aliases: []
|
||||||
iops:
|
iops:
|
||||||
description:
|
description:
|
||||||
- the provisioned IOPs you want to associate with this volume (integer).
|
- the provisioned IOPs you want to associate with this volume (integer).
|
||||||
|
@ -164,6 +171,14 @@ EXAMPLES = '''
|
||||||
- ec2_vol:
|
- ec2_vol:
|
||||||
instance: i-XXXXXX
|
instance: i-XXXXXX
|
||||||
state: list
|
state: list
|
||||||
|
|
||||||
|
# Create new volume using SSD storage
|
||||||
|
- local_action:
|
||||||
|
module: ec2_vol
|
||||||
|
instance: XXXXXX
|
||||||
|
volume_size: 50
|
||||||
|
volume_type: gp2
|
||||||
|
device_name: /dev/xvdf
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
@ -239,12 +254,11 @@ def create_volume(module, ec2, zone):
|
||||||
iops = module.params.get('iops')
|
iops = module.params.get('iops')
|
||||||
encrypted = module.params.get('encrypted')
|
encrypted = module.params.get('encrypted')
|
||||||
volume_size = module.params.get('volume_size')
|
volume_size = module.params.get('volume_size')
|
||||||
|
volume_type = module.params.get('volume_type')
|
||||||
snapshot = module.params.get('snapshot')
|
snapshot = module.params.get('snapshot')
|
||||||
# If custom iops is defined we use volume_type "io1" rather than the default of "standard"
|
# If custom iops is defined we use volume_type "io1" rather than the default of "standard"
|
||||||
if iops:
|
if iops:
|
||||||
volume_type = 'io1'
|
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.
|
||||||
if name or id:
|
if name or id:
|
||||||
|
@ -324,6 +338,7 @@ def main():
|
||||||
id = dict(),
|
id = dict(),
|
||||||
name = dict(),
|
name = dict(),
|
||||||
volume_size = dict(),
|
volume_size = dict(),
|
||||||
|
volume_type = dict(choices=['standard', 'gp2', 'io1'], default='standard'),
|
||||||
iops = dict(),
|
iops = dict(),
|
||||||
encrypted = dict(),
|
encrypted = dict(),
|
||||||
device_name = dict(),
|
device_name = dict(),
|
||||||
|
@ -338,6 +353,7 @@ def main():
|
||||||
name = module.params.get('name')
|
name = module.params.get('name')
|
||||||
instance = module.params.get('instance')
|
instance = module.params.get('instance')
|
||||||
volume_size = module.params.get('volume_size')
|
volume_size = module.params.get('volume_size')
|
||||||
|
volume_type = module.params.get('volume_type')
|
||||||
iops = module.params.get('iops')
|
iops = module.params.get('iops')
|
||||||
encrypted = module.params.get('encrypted')
|
encrypted = module.params.get('encrypted')
|
||||||
device_name = module.params.get('device_name')
|
device_name = module.params.get('device_name')
|
||||||
|
@ -411,7 +427,7 @@ def main():
|
||||||
volume = create_volume(module, ec2, zone)
|
volume = create_volume(module, ec2, zone)
|
||||||
if instance:
|
if instance:
|
||||||
attach_volume(module, ec2, volume, inst)
|
attach_volume(module, ec2, volume, inst)
|
||||||
module.exit_json(volume_id=volume.id, device=device_name)
|
module.exit_json(volume_id=volume.id, device=device_name, volume_type=volume.type)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
|
Loading…
Reference in a new issue