Skip to content

Commit

Permalink
corrections to ec2_vol module
Browse files Browse the repository at this point in the history
  • Loading branch information
falcon78921 committed May 18, 2020
1 parent 6299e53 commit a858d2c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/modules/ec2_vol.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def delete_volume(module, ec2_conn, volume_id=None):
module.fail_json_aws(e, msg='Error while deleting volume') # TODO: https://github.com/ansible/ansible/pull/45500/files#r218858613
return changed


def create_volume(module, ec2_conn, zone):
changed = False
iops = module.params.get('iops')
Expand Down Expand Up @@ -376,6 +377,7 @@ def create_volume(module, ec2_conn, zone):

return volume, changed


def attach_volume(module, ec2_conn, volume_dict, instance_dict, device_name):
changed = False

Expand Down Expand Up @@ -458,6 +460,7 @@ def get_attachment_data(volume_dict, wanted_state=None):

return attachment_data


def detach_volume(module, ec2_conn, volume_dict):
changed = False

Expand Down Expand Up @@ -498,6 +501,7 @@ def get_volume_info(volume):

return volume_info


def get_mapped_block_device(instance_dict=None, device_name=None):
mapped_block_device = None
if not instance_dict:
Expand Down Expand Up @@ -570,7 +574,7 @@ def ensure_tags(module, connection, res_id, res_type, tags, add_only):


def main():
ec2_argument_spec.update(dict(
argument_spec = dict(
instance=dict(),
id=dict(),
name=dict(),
Expand All @@ -585,9 +589,9 @@ def main():
snapshot=dict(),
state=dict(choices=['absent', 'present', 'list'], default='present'),
tags=dict(type='dict', default={})
))
)

module = AnsibleAWSModule(ec2_argument_spec=ec2_argument_spec)
module = AnsibleAWSModule(argument_spec=argument_spec)

param_id = module.params.get('id')
name = module.params.get('name')
Expand Down Expand Up @@ -696,5 +700,6 @@ def main():
changed = delete_volume(module, ec2_conn, volume_id=volume['volume_id'])
module.exit_json(changed=changed)


if __name__ == '__main__':
main()
16 changes: 16 additions & 0 deletions plugins/modules/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
argument_spec = dict(
instance=dict(),
id=dict(),
name=dict(),
volume_size=dict(type='int'),
volume_type=dict(choices=['standard', 'gp2', 'io1', 'st1', 'sc1'], default='standard'),
iops=dict(),
encrypted=dict(type='bool', default=False),
kms_key_id=dict(),
device_name=dict(),
delete_on_termination=dict(type='bool', default=False),
zone=dict(aliases=['availability_zone', 'aws_zone', 'ec2_zone']),
snapshot=dict(),
state=dict(choices=['absent', 'present', 'list'], default='present'),
tags=dict(type='dict', default={})
)

0 comments on commit a858d2c

Please sign in to comment.