From a858d2c2de3a3bdc7f07c53097530072fa6f5cdf Mon Sep 17 00:00:00 2001 From: James McClune Date: Mon, 18 May 2020 16:55:58 -0400 Subject: [PATCH] corrections to ec2_vol module --- plugins/modules/ec2_vol.py | 11 ++++++++--- plugins/modules/test | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 plugins/modules/test diff --git a/plugins/modules/ec2_vol.py b/plugins/modules/ec2_vol.py index c453ac800ac..24a05306bb5 100644 --- a/plugins/modules/ec2_vol.py +++ b/plugins/modules/ec2_vol.py @@ -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') @@ -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 @@ -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 @@ -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: @@ -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(), @@ -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') @@ -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() diff --git a/plugins/modules/test b/plugins/modules/test new file mode 100644 index 00000000000..3e295b05160 --- /dev/null +++ b/plugins/modules/test @@ -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={}) +)