summaryrefslogtreecommitdiff
path: root/cloud
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2016-10-23 13:41:03 -0700
committerToshio Kuratomi <a.badger@gmail.com>2016-10-23 16:40:52 -0700
commit79c7997952ec790f38caf027078bbcc294f928d1 (patch)
treed722683f45d40a93f5b1614d1ec4887b0a9d76ca /cloud
parent7ce17ab49ef232af2064d2a680dc6ca78c2211f5 (diff)
downloadansible-modules-extras-79c7997952ec790f38caf027078bbcc294f928d1.tar.gz
Fix amazon extras modules to compile under python3
Diffstat (limited to 'cloud')
-rw-r--r--cloud/amazon/cloudtrail.py12
-rw-r--r--cloud/amazon/dynamodb_table.py16
-rw-r--r--cloud/amazon/ec2_ami_copy.py20
-rw-r--r--cloud/amazon/ec2_customer_gateway.py12
-rw-r--r--cloud/amazon/ec2_eni.py10
-rw-r--r--cloud/amazon/ec2_eni_facts.py10
-rw-r--r--cloud/amazon/ec2_remote_facts.py9
-rw-r--r--cloud/amazon/ec2_snapshot_facts.py9
-rw-r--r--cloud/amazon/ec2_vol_facts.py8
-rw-r--r--cloud/amazon/ec2_vpc_igw.py9
-rw-r--r--cloud/amazon/ec2_vpc_nacl.py14
-rw-r--r--cloud/amazon/ec2_vpc_net_facts.py8
-rw-r--r--cloud/amazon/ec2_vpc_route_table.py11
-rw-r--r--cloud/amazon/ec2_vpc_route_table_facts.py8
-rw-r--r--cloud/amazon/ec2_vpc_subnet.py8
-rw-r--r--cloud/amazon/ec2_vpc_subnet_facts.py8
-rw-r--r--cloud/amazon/ecs_cluster.py13
-rw-r--r--cloud/amazon/ecs_service.py17
-rw-r--r--cloud/amazon/ecs_service_facts.py12
-rw-r--r--cloud/amazon/ecs_task.py11
-rw-r--r--cloud/amazon/ecs_taskdefinition.py11
-rw-r--r--cloud/amazon/route53_facts.py10
-rw-r--r--cloud/amazon/route53_health_check.py14
-rw-r--r--cloud/amazon/route53_zone.py13
-rw-r--r--cloud/amazon/s3_lifecycle.py23
-rw-r--r--cloud/amazon/s3_logging.py7
-rw-r--r--cloud/amazon/sns_topic.py13
-rw-r--r--cloud/amazon/sqs_queue.py12
-rw-r--r--cloud/amazon/sts_assume_role.py13
-rw-r--r--cloud/amazon/sts_session_token.py11
30 files changed, 192 insertions, 160 deletions
diff --git a/cloud/amazon/cloudtrail.py b/cloud/amazon/cloudtrail.py
index 557f2eba..f0ca3239 100644
--- a/cloud/amazon/cloudtrail.py
+++ b/cloud/amazon/cloudtrail.py
@@ -101,6 +101,10 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import connect_to_aws, ec2_argument_spec, get_ec2_creds
+
+
class CloudTrailManager:
"""Handles cloudtrail configuration"""
@@ -112,7 +116,7 @@ class CloudTrailManager:
try:
self.conn = connect_to_aws(boto.cloudtrail, self.region, **self.aws_connect_params)
- except boto.exception.NoAuthHandlerFound, e:
+ except boto.exception.NoAuthHandlerFound as e:
self.module.fail_json(msg=str(e))
def view_status(self, name):
@@ -222,8 +226,6 @@ def main():
module.exit_json(**results)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-main()
+if __name__ == '__main__':
+ main()
diff --git a/cloud/amazon/dynamodb_table.py b/cloud/amazon/dynamodb_table.py
index ceafbdea..3799c0ff 100644
--- a/cloud/amazon/dynamodb_table.py
+++ b/cloud/amazon/dynamodb_table.py
@@ -133,6 +133,8 @@ table_status:
sample: ACTIVE
'''
+import traceback
+
try:
import boto
import boto.dynamodb2
@@ -152,6 +154,10 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
+
DYNAMO_TYPE_DEFAULT = 'STRING'
INDEX_REQUIRED_OPTIONS = ['name', 'type', 'hash_key_name']
INDEX_OPTIONS = INDEX_REQUIRED_OPTIONS + ['hash_key_type', 'range_key_name', 'range_key_type', 'includes', 'read_capacity', 'write_capacity']
@@ -244,7 +250,7 @@ def dynamo_table_exists(table):
table.describe()
return True
- except JSONResponseError, e:
+ except JSONResponseError as e:
if e.message and e.message.startswith('Requested resource not found'):
return False
else:
@@ -281,7 +287,7 @@ def update_dynamo_table(table, throughput=None, check_mode=False, global_indexes
# todo: remove try once boto has https://github.com/boto/boto/pull/3447 fixed
try:
global_indexes_changed = table.update_global_secondary_index(global_indexes=index_throughput_changes) or global_indexes_changed
- except ValidationException as e:
+ except ValidationException:
pass
else:
global_indexes_changed = True
@@ -398,7 +404,7 @@ def main():
try:
connection = connect_to_aws(boto.dynamodb2, region, **aws_connect_params)
- except (NoAuthHandlerFound, AnsibleAWSError), e:
+ except (NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
state = module.params.get('state')
@@ -408,9 +414,5 @@ def main():
delete_dynamo_table(connection, module)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_ami_copy.py b/cloud/amazon/ec2_ami_copy.py
index 88eba110..c053eb31 100644
--- a/cloud/amazon/ec2_ami_copy.py
+++ b/cloud/amazon/ec2_ami_copy.py
@@ -124,6 +124,8 @@ EXAMPLES = '''
kms_key_id: arn:aws:kms:us-east-1:XXXXXXXXXXXX:key/746de6ea-50a4-4bcb-8fbc-e3b29f2d367b
'''
+import time
+
try:
import boto
import boto.ec2
@@ -131,6 +133,9 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import ec2_argument_spec, ec2_connect, get_aws_connection_info
+
def copy_image(module, ec2):
"""
@@ -160,7 +165,7 @@ def copy_image(module, ec2):
}
image_id = ec2.copy_image(**params).image_id
- except boto.exception.BotoServerError, e:
+ except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
img = wait_until_image_is_recognized(module, ec2, wait_timeout, image_id, wait)
@@ -198,7 +203,7 @@ def wait_until_image_is_recognized(module, ec2, wait_timeout, image_id, wait):
for i in range(wait_timeout):
try:
return ec2.get_image(image_id)
- except boto.exception.EC2ResponseError, e:
+ except boto.exception.EC2ResponseError as e:
# This exception we expect initially right after registering the copy with EC2 API
if 'InvalidAMIID.NotFound' in e.error_code and wait:
time.sleep(1)
@@ -231,12 +236,12 @@ def main():
try:
ec2 = ec2_connect(module)
- except boto.exception.NoAuthHandlerFound, e:
+ except boto.exception.NoAuthHandlerFound as e:
module.fail_json(msg=str(e))
try:
region, ec2_url, boto_params = get_aws_connection_info(module)
- except boto.exception.NoAuthHandlerFound, e:
+ except boto.exception.NoAuthHandlerFound as e:
module.fail_json(msg=str(e))
if not region:
@@ -245,9 +250,6 @@ def main():
copy_image(module, ec2)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
-main()
+if __name__ == '__main__':
+ main()
diff --git a/cloud/amazon/ec2_customer_gateway.py b/cloud/amazon/ec2_customer_gateway.py
index 4e02523a..64a77bb0 100644
--- a/cloud/amazon/ec2_customer_gateway.py
+++ b/cloud/amazon/ec2_customer_gateway.py
@@ -120,6 +120,11 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import (boto3_conn, camel_dict_to_snake_dict,
+ ec2_argument_spec, get_aws_connection_info)
+
+
class Ec2CustomerGatewayManager:
def __init__(self, module):
@@ -130,7 +135,7 @@ class Ec2CustomerGatewayManager:
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ec2 = boto3_conn(module, conn_type='client', resource='ec2', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except ClientError, e:
+ except ClientError as e:
module.fail_json(msg=e.message)
def ensure_cgw_absent(self, gw_id):
@@ -211,8 +216,6 @@ def main():
gw_mgr = Ec2CustomerGatewayManager(module)
- bgp_asn = module.params.get('bgp_asn')
- ip_address = module.params.get('ip_address')
name = module.params.get('name')
existing = gw_mgr.describe_gateways(module.params['ip_address'])
@@ -259,9 +262,6 @@ def main():
pretty_results = camel_dict_to_snake_dict(results)
module.exit_json(**pretty_results)
-# import module methods
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_eni.py b/cloud/amazon/ec2_eni.py
index 79d44f9d..6946ec6d 100644
--- a/cloud/amazon/ec2_eni.py
+++ b/cloud/amazon/ec2_eni.py
@@ -241,6 +241,12 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import (AnsibleAWSError, connect_to_aws,
+ ec2_argument_spec, get_aws_connection_info,
+ get_ec2_security_group_ids_from_names)
+
+
def get_eni_info(interface):
# Private addresses
@@ -539,7 +545,7 @@ def main():
try:
connection = connect_to_aws(boto.ec2, region, **aws_connect_params)
vpc_connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
@@ -561,8 +567,6 @@ def main():
elif state == 'absent':
delete_eni(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_eni_facts.py b/cloud/amazon/ec2_eni_facts.py
index 8b385dab..116c8c74 100644
--- a/cloud/amazon/ec2_eni_facts.py
+++ b/cloud/amazon/ec2_eni_facts.py
@@ -60,6 +60,12 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import (AnsibleAWSError,
+ ansible_dict_to_boto3_filter_list, boto3_conn,
+ boto3_tag_list_to_ansible_dict, camel_dict_to_snake_dict,
+ connect_to_aws, ec2_argument_spec, get_aws_connection_info)
+
def list_ec2_snapshots_boto3(connection, module):
@@ -163,15 +169,13 @@ def main():
if region:
try:
connection = connect_to_aws(boto.ec2, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
list_eni(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_remote_facts.py b/cloud/amazon/ec2_remote_facts.py
index 5b3f9099..cb80068a 100644
--- a/cloud/amazon/ec2_remote_facts.py
+++ b/cloud/amazon/ec2_remote_facts.py
@@ -65,6 +65,10 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
+
def get_instance_info(instance):
# Get groups
@@ -171,16 +175,13 @@ def main():
if region:
try:
connection = connect_to_aws(boto.ec2, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
list_ec2_instances(connection, module)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_snapshot_facts.py b/cloud/amazon/ec2_snapshot_facts.py
index 9904eb85..357a1692 100644
--- a/cloud/amazon/ec2_snapshot_facts.py
+++ b/cloud/amazon/ec2_snapshot_facts.py
@@ -163,6 +163,11 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import (ansible_dict_to_boto3_filter_list,
+ boto3_conn, boto3_tag_list_to_ansible_dict, camel_dict_to_snake_dict,
+ ec2_argument_spec, get_aws_connection_info)
+
def list_ec2_snapshots(connection, module):
@@ -173,7 +178,7 @@ def list_ec2_snapshots(connection, module):
try:
snapshots = connection.describe_snapshots(SnapshotIds=snapshot_ids, OwnerIds=owner_ids, RestorableByUserIds=restorable_by_user_ids, Filters=filters)
- except ClientError, e:
+ except ClientError as e:
module.fail_json(msg=e.message)
# Turn the boto3 result in to ansible_friendly_snaked_names
@@ -219,8 +224,6 @@ def main():
list_ec2_snapshots(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vol_facts.py b/cloud/amazon/ec2_vol_facts.py
index e053a772..5d099d0f 100644
--- a/cloud/amazon/ec2_vol_facts.py
+++ b/cloud/amazon/ec2_vol_facts.py
@@ -66,6 +66,10 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
+
def get_volume_info(volume):
attachment = volume.attach_data
@@ -125,15 +129,13 @@ def main():
if region:
try:
connection = connect_to_aws(boto.ec2, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, StandardError), e:
+ except (boto.exception.NoAuthHandlerFound, StandardError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
list_ec2_volumes(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vpc_igw.py b/cloud/amazon/ec2_vpc_igw.py
index a4e58faa..fc057bae 100644
--- a/cloud/amazon/ec2_vpc_igw.py
+++ b/cloud/amazon/ec2_vpc_igw.py
@@ -50,8 +50,6 @@ register: igw
'''
-import sys # noqa
-
try:
import boto.ec2
import boto.vpc
@@ -62,6 +60,9 @@ except ImportError:
if __name__ != '__main__':
raise
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
class AnsibleIGWException(Exception):
pass
@@ -134,7 +135,7 @@ def main():
if region:
try:
connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
@@ -152,8 +153,6 @@ def main():
module.exit_json(**result)
-from ansible.module_utils.basic import * # noqa
-from ansible.module_utils.ec2 import * # noqa
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vpc_nacl.py b/cloud/amazon/ec2_vpc_nacl.py
index 73eafbc8..b3d4f197 100644
--- a/cloud/amazon/ec2_vpc_nacl.py
+++ b/cloud/amazon/ec2_vpc_nacl.py
@@ -122,13 +122,15 @@ task:
'''
try:
- import json
import botocore
import boto3
HAS_BOTO3 = True
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
# Common fields for the default rule that is contained within every VPC NACL.
DEFAULT_RULE_FIELDS = {
@@ -179,7 +181,6 @@ def subnets_added(nacl_id, subnets, client, module):
def subnets_changed(nacl, client, module):
changed = False
- response = {}
vpc_id = module.params.get('vpc_id')
nacl_id = nacl['NetworkAcls'][0]['NetworkAclId']
subnets = subnets_to_associate(nacl, client, module)
@@ -528,9 +529,9 @@ def main():
try:
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
client = boto3_conn(module, conn_type='client', resource='ec2', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except botocore.exceptions.NoCredentialsError, e:
- module.fail_json(msg="Can't authorize connection - "+str(e))
-
+ except botocore.exceptions.NoCredentialsError as e:
+ module.fail_json(msg="Can't authorize connection - %s" % str(e))
+
invocations = {
"present": setup_network_acl,
"absent": remove_network_acl
@@ -538,9 +539,6 @@ def main():
(changed, results) = invocations[state](client, module)
module.exit_json(changed=changed, nacl_id=results)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vpc_net_facts.py b/cloud/amazon/ec2_vpc_net_facts.py
index 8de47ed9..dfa29ba9 100644
--- a/cloud/amazon/ec2_vpc_net_facts.py
+++ b/cloud/amazon/ec2_vpc_net_facts.py
@@ -58,6 +58,10 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
+
def get_vpc_info(vpc):
try:
@@ -111,15 +115,13 @@ def main():
if region:
try:
connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, StandardError), e:
+ except (boto.exception.NoAuthHandlerFound, StandardError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
list_ec2_vpcs(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vpc_route_table.py b/cloud/amazon/ec2_vpc_route_table.py
index 416e0b43..4062f094 100644
--- a/cloud/amazon/ec2_vpc_route_table.py
+++ b/cloud/amazon/ec2_vpc_route_table.py
@@ -107,8 +107,6 @@ EXAMPLES = '''
'''
-
-import sys # noqa
import re
try:
@@ -121,6 +119,9 @@ except ImportError:
if __name__ != '__main__':
raise
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
class AnsibleRouteTableException(Exception):
pass
@@ -179,7 +180,7 @@ def find_subnets(vpc_conn, vpc_id, identified_subnets):
for cidr in subnet_cidrs:
if not any(s.cidr_block == cidr for s in subnets_by_cidr):
raise AnsibleSubnetSearchException(
- 'Subnet CIDR "{0}" does not exist'.format(subnet_cidr))
+ 'Subnet CIDR "{0}" does not exist'.format(cidr))
subnets_by_name = []
if subnet_names:
@@ -605,7 +606,7 @@ def main():
if region:
try:
connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
@@ -627,8 +628,6 @@ def main():
module.exit_json(**result)
-from ansible.module_utils.basic import * # noqa
-from ansible.module_utils.ec2 import * # noqa
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vpc_route_table_facts.py b/cloud/amazon/ec2_vpc_route_table_facts.py
index 8b5e60ab..394c4b28 100644
--- a/cloud/amazon/ec2_vpc_route_table_facts.py
+++ b/cloud/amazon/ec2_vpc_route_table_facts.py
@@ -62,6 +62,10 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
+
def get_route_table_info(route_table):
# Add any routes to array
@@ -111,15 +115,13 @@ def main():
if region:
try:
connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
list_ec2_vpc_route_tables(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vpc_subnet.py b/cloud/amazon/ec2_vpc_subnet.py
index 6e7c3e7d..ddc4f5e9 100644
--- a/cloud/amazon/ec2_vpc_subnet.py
+++ b/cloud/amazon/ec2_vpc_subnet.py
@@ -74,7 +74,6 @@ EXAMPLES = '''
'''
-import sys # noqa
import time
try:
@@ -87,6 +86,9 @@ except ImportError:
if __name__ != '__main__':
raise
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
class AnsibleVPCSubnetException(Exception):
pass
@@ -242,7 +244,7 @@ def main():
if region:
try:
connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
@@ -265,8 +267,6 @@ def main():
module.exit_json(**result)
-from ansible.module_utils.basic import * # noqa
-from ansible.module_utils.ec2 import * # noqa
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ec2_vpc_subnet_facts.py b/cloud/amazon/ec2_vpc_subnet_facts.py
index c3637292..98f1e487 100644
--- a/cloud/amazon/ec2_vpc_subnet_facts.py
+++ b/cloud/amazon/ec2_vpc_subnet_facts.py
@@ -77,6 +77,10 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
+
def get_subnet_info(subnet):
subnet_info = { 'id': subnet.id,
@@ -126,15 +130,13 @@ def main():
if region:
try:
connection = connect_to_aws(boto.vpc, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
list_ec2_vpc_subnets(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ecs_cluster.py b/cloud/amazon/ecs_cluster.py
index 22049a9f..ad029d4e 100644
--- a/cloud/amazon/ecs_cluster.py
+++ b/cloud/amazon/ecs_cluster.py
@@ -115,6 +115,10 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
+
class EcsClusterManager:
"""Handles ECS Clusters"""
@@ -127,8 +131,8 @@ class EcsClusterManager:
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except boto.exception.NoAuthHandlerFound, e:
- self.module.fail_json(msg="Can't authorize connection - "+str(e))
+ except boto.exception.NoAuthHandlerFound as e:
+ self.module.fail_json(msg="Can't authorize connection - %s" % str(e))
def find_in_array(self, array_of_clusters, cluster_name, field_name='clusterArn'):
for c in array_of_clusters:
@@ -180,7 +184,7 @@ def main():
cluster_mgr = EcsClusterManager(module)
try:
existing = cluster_mgr.describe_cluster(module.params['name'])
- except Exception, e:
+ except Exception as e:
module.fail_json(msg="Exception describing cluster '"+module.params['name']+"': "+str(e))
results = dict(changed=False)
@@ -230,9 +234,6 @@ def main():
module.exit_json(**results)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ecs_service.py b/cloud/amazon/ecs_service.py
index 94d7078c..3ae77e6b 100644
--- a/cloud/amazon/ecs_service.py
+++ b/cloud/amazon/ecs_service.py
@@ -175,6 +175,8 @@ ansible_facts:
returned: when service existed and was deleted
type: complex
'''
+import time
+
try:
import boto
import botocore
@@ -188,6 +190,10 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
+
class EcsServiceManager:
"""Handles ECS Services"""
@@ -200,8 +206,8 @@ class EcsServiceManager:
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except boto.exception.NoAuthHandlerFound, e:
- self.module.fail_json(msg="Can't authorize connection - "+str(e))
+ except boto.exception.NoAuthHandlerFound as e:
+ self.module.fail_json(msg="Can't authorize connection - %s" % str(e))
# def list_clusters(self):
# return self.client.list_clusters()
@@ -321,7 +327,7 @@ def main():
service_mgr = EcsServiceManager(module)
try:
existing = service_mgr.describe_service(module.params['cluster'], module.params['name'])
- except Exception, e:
+ except Exception as e:
module.fail_json(msg="Exception describing service '"+module.params['name']+"' in cluster '"+module.params['cluster']+"': "+str(e))
results = dict(changed=False )
@@ -392,7 +398,7 @@ def main():
module.params['name'],
module.params['cluster']
)
- except botocore.exceptions.ClientError, e:
+ except botocore.exceptions.ClientError as e:
module.fail_json(msg=e.message)
results['changed'] = True
@@ -418,9 +424,6 @@ def main():
module.exit_json(**results)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ecs_service_facts.py b/cloud/amazon/ecs_service_facts.py
index f363c56a..aaee2aa0 100644
--- a/cloud/amazon/ecs_service_facts.py
+++ b/cloud/amazon/ecs_service_facts.py
@@ -139,6 +139,10 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
+
class EcsServiceManager:
"""Handles ECS Services"""
@@ -151,8 +155,8 @@ class EcsServiceManager:
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except boto.exception.NoAuthHandlerFound, e:
- self.module.fail_json(msg="Can't authorize connection - "+str(e))
+ except boto.exception.NoAuthHandlerFound as e:
+ self.module.fail_json(msg="Can't authorize connection - %s" % str(e))
# def list_clusters(self):
# return self.client.list_clusters()
@@ -227,10 +231,6 @@ def main():
ecs_facts_result = dict(changed=False, ansible_facts=ecs_facts)
module.exit_json(**ecs_facts_result)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.urls import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ecs_task.py b/cloud/amazon/ecs_task.py
index f263ef0d..86c77ece 100644
--- a/cloud/amazon/ecs_task.py
+++ b/cloud/amazon/ecs_task.py
@@ -165,6 +165,10 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
+
class EcsExecManager:
"""Handles ECS Tasks"""
@@ -176,8 +180,8 @@ class EcsExecManager:
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except boto.exception.NoAuthHandlerFound, e:
- module.fail_json(msg="Can't authorize connection - "+str(e))
+ except boto.exception.NoAuthHandlerFound as e:
+ module.fail_json(msg="Can't authorize connection - %s " % str(e))
def list_tasks(self, cluster_name, service_name, status):
response = self.ecs.list_tasks(
@@ -316,9 +320,6 @@ def main():
module.exit_json(**results)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/ecs_taskdefinition.py b/cloud/amazon/ecs_taskdefinition.py
index e924417f..2fefe231 100644
--- a/cloud/amazon/ecs_taskdefinition.py
+++ b/cloud/amazon/ecs_taskdefinition.py
@@ -108,6 +108,10 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
+
class EcsTaskManager:
"""Handles ECS Tasks"""
@@ -119,8 +123,8 @@ class EcsTaskManager:
if not region:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except boto.exception.NoAuthHandlerFound, e:
- module.fail_json(msg="Can't authorize connection - "+str(e))
+ except boto.exception.NoAuthHandlerFound as e:
+ module.fail_json(msg="Can't authorize connection - " % str(e))
def describe_task(self, task_name):
try:
@@ -213,9 +217,6 @@ def main():
module.exit_json(**results)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/route53_facts.py b/cloud/amazon/route53_facts.py
index 95c1491a..15379688 100644
--- a/cloud/amazon/route53_facts.py
+++ b/cloud/amazon/route53_facts.py
@@ -172,6 +172,9 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
def get_hosted_zone(client, module):
params = dict()
@@ -413,8 +416,8 @@ def main():
try:
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
route53 = boto3_conn(module, conn_type='client', resource='route53', region=region, endpoint=ec2_url, **aws_connect_kwargs)
- except boto.exception.NoAuthHandlerFound, e:
- module.fail_json(msg="Can't authorize connection - "+str(e))
+ except boto.exception.NoAuthHandlerFound as e:
+ module.fail_json(msg="Can't authorize connection - %s " % str(e))
invocations = {
'change': change_details,
@@ -428,9 +431,6 @@ def main():
module.exit_json(**results)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/route53_health_check.py b/cloud/amazon/route53_health_check.py
index 9ad7f63d..9bbb7b3e 100644
--- a/cloud/amazon/route53_health_check.py
+++ b/cloud/amazon/route53_health_check.py
@@ -125,7 +125,6 @@ EXAMPLES = '''
'''
-import time
import uuid
try:
@@ -138,6 +137,11 @@ try:
except ImportError:
HAS_BOTO = False
+# import module snippets
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info
+
+
# Things that can't get changed:
# protocol
# ip_address or domain
@@ -318,7 +322,7 @@ def main():
# connect to the route53 endpoint
try:
conn = Route53Connection(**aws_connect_kwargs)
- except boto.exception.BotoServerError, e:
+ except boto.exception.BotoServerError as e:
module.fail_json(msg = e.error_message)
changed = False
@@ -351,8 +355,6 @@ def main():
module.exit_json(changed=changed, health_check=dict(id=check_id), action=action)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-main()
+if __name__ == '__main__':
+ main()
diff --git a/cloud/amazon/route53_zone.py b/cloud/amazon/route53_zone.py
index 328d48db..d08ed88a 100644
--- a/cloud/amazon/route53_zone.py
+++ b/cloud/amazon/route53_zone.py
@@ -108,8 +108,6 @@ zone_id:
sample: "Z6JQG9820BEFMW"
'''
-import time
-
try:
import boto
import boto.ec2
@@ -120,6 +118,9 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info
+
def main():
argument_spec = ec2_argument_spec()
@@ -150,7 +151,7 @@ def main():
# connect to the route53 endpoint
try:
conn = Route53Connection(**aws_connect_kwargs)
- except boto.exception.BotoServerError, e:
+ except boto.exception.BotoServerError as e:
module.fail_json(msg=e.error_message)
results = conn.get_all_hosted_zones()
@@ -218,7 +219,5 @@ def main():
elif state == 'absent':
module.exit_json(changed=False)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
-main()
+if __name__ == '__main__':
+ main()
diff --git a/cloud/amazon/s3_lifecycle.py b/cloud/amazon/s3_lifecycle.py
index 25415395..c34b8ccf 100644
--- a/cloud/amazon/s3_lifecycle.py
+++ b/cloud/amazon/s3_lifecycle.py
@@ -159,6 +159,9 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, ec2_argument_spec, get_aws_connection_info
+
def create_lifecycle_rule(connection, module):
name = module.params.get("name")
@@ -174,13 +177,13 @@ def create_lifecycle_rule(connection, module):
try:
bucket = connection.get_bucket(name)
- except S3ResponseError, e:
+ except S3ResponseError as e:
module.fail_json(msg=e.message)
# Get the bucket's current lifecycle rules
try:
current_lifecycle_obj = bucket.get_lifecycle_config()
- except S3ResponseError, e:
+ except S3ResponseError as e:
if e.error_code == "NoSuchLifecycleConfiguration":
current_lifecycle_obj = Lifecycle()
else:
@@ -243,7 +246,7 @@ def create_lifecycle_rule(connection, module):
# Write lifecycle to bucket
try:
bucket.configure_lifecycle(lifecycle_obj)
- except S3ResponseError, e:
+ except S3ResponseError as e:
module.fail_json(msg=e.message)
module.exit_json(changed=changed)
@@ -305,13 +308,13 @@ def destroy_lifecycle_rule(connection, module):
try:
bucket = connection.get_bucket(name)
- except S3ResponseError, e:
+ except S3ResponseError as e:
module.fail_json(msg=e.message)
# Get the bucket's current lifecycle rules
try:
current_lifecycle_obj = bucket.get_lifecycle_config()
- except S3ResponseError, e:
+ except S3ResponseError as e:
if e.error_code == "NoSuchLifecycleConfiguration":
module.exit_json(changed=changed)
else:
@@ -343,7 +346,7 @@ def destroy_lifecycle_rule(connection, module):
bucket.configure_lifecycle(lifecycle_obj)
else:
bucket.delete_lifecycle_configuration()
- except BotoServerError, e:
+ except BotoServerError as e:
module.fail_json(msg=e.message)
module.exit_json(changed=changed)
@@ -397,7 +400,7 @@ def main():
# use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases
if connection is None:
connection = boto.connect_s3(**aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
expiration_date = module.params.get("expiration_date")
@@ -409,13 +412,13 @@ def main():
if expiration_date is not None:
try:
datetime.datetime.strptime(expiration_date, "%Y-%m-%dT%H:%M:%S.000Z")
- except ValueError, e:
+ except ValueError as e:
module.fail_json(msg="expiration_date is not a valid ISO-8601 format. The time must be midnight and a timezone of GMT must be included")
if transition_date is not None:
try:
datetime.datetime.strptime(transition_date, "%Y-%m-%dT%H:%M:%S.000Z")
- except ValueError, e:
+ except ValueError as e:
module.fail_json(msg="expiration_date is not a valid ISO-8601 format. The time must be midnight and a timezone of GMT must be included")
boto_required_version = (2,40,0)
@@ -427,8 +430,6 @@ def main():
elif state == 'absent':
destroy_lifecycle_rule(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/s3_logging.py b/cloud/amazon/s3_logging.py
index dca2a28a..91ca1b34 100644
--- a/cloud/amazon/s3_logging.py
+++ b/cloud/amazon/s3_logging.py
@@ -72,6 +72,9 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, ec2_argument_spec, get_aws_connection_info
+
def compare_bucket_logging(bucket, target_bucket, target_prefix):
@@ -162,7 +165,7 @@ def main():
# use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases
if connection is None:
connection = boto.connect_s3(**aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
state = module.params.get("state")
@@ -172,8 +175,6 @@ def main():
elif state == 'absent':
disable_bucket_logging(connection, module)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/sns_topic.py b/cloud/amazon/sns_topic.py
index f4916693..34bae494 100644
--- a/cloud/amazon/sns_topic.py
+++ b/cloud/amazon/sns_topic.py
@@ -122,7 +122,6 @@ sns_topic:
attributes_set: []
'''
-import sys
import time
import json
import re
@@ -134,6 +133,9 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
class SnsTopicManager(object):
""" Handles SNS Topic creation and destruction """
@@ -176,7 +178,7 @@ class SnsTopicManager(object):
try:
return connect_to_aws(boto.sns, self.region,
**self.aws_connect_params)
- except BotoServerError, err:
+ except BotoServerError as err:
self.module.fail_json(msg=err.message)
def _get_all_topics(self):
@@ -185,8 +187,8 @@ class SnsTopicManager(object):
while True:
try:
response = self.connection.get_all_topics(next_token)
- except BotoServerError, err:
- module.fail_json(msg=err.message)
+ except BotoServerError as err:
+ self.module.fail_json(msg=err.message)
topics.extend(response['ListTopicsResponse']['ListTopicsResult']['Topics'])
next_token = response['ListTopicsResponse']['ListTopicsResult']['NextToken']
if not next_token:
@@ -400,8 +402,5 @@ def main():
module.exit_json(**sns_facts)
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/sqs_queue.py b/cloud/amazon/sqs_queue.py
index d00a3b63..d5e17ad2 100644
--- a/cloud/amazon/sqs_queue.py
+++ b/cloud/amazon/sqs_queue.py
@@ -103,6 +103,9 @@ EXAMPLES = '''
state: absent
'''
+import json
+import traceback
+
try:
import boto.sqs
from boto.exception import BotoServerError, NoAuthHandlerFound
@@ -111,6 +114,9 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
def create_or_update_sqs_queue(connection, module):
queue_name = module.params.get('name')
@@ -255,7 +261,7 @@ def main():
try:
connection = connect_to_aws(boto.sqs, region, **aws_connect_params)
- except (NoAuthHandlerFound, AnsibleAWSError), e:
+ except (NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
state = module.params.get('state')
@@ -265,9 +271,5 @@ def main():
delete_sqs_queue(connection, module)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/sts_assume_role.py b/cloud/amazon/sts_assume_role.py
index a3fab121..da8ba9a7 100644
--- a/cloud/amazon/sts_assume_role.py
+++ b/cloud/amazon/sts_assume_role.py
@@ -91,6 +91,9 @@ try:
except ImportError:
HAS_BOTO = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info
+
def assume_role_policy(connection, module):
@@ -106,7 +109,7 @@ def assume_role_policy(connection, module):
try:
assumed_role = connection.assume_role(role_arn, role_session_name, policy, duration_seconds, external_id, mfa_serial_number, mfa_token)
changed = True
- except BotoServerError, e:
+ except BotoServerError as e:
module.fail_json(msg=e)
module.exit_json(changed=changed, sts_creds=assumed_role.credentials.__dict__, sts_user=assumed_role.user.__dict__)
@@ -135,20 +138,16 @@ def main():
if region:
try:
connection = connect_to_aws(boto.sts, region, **aws_connect_params)
- except (boto.exception.NoAuthHandlerFound, AnsibleAWSError), e:
+ except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
try:
assume_role_policy(connection, module)
- except BotoServerError, e:
+ except BotoServerError as e:
module.fail_json(msg=e)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
if __name__ == '__main__':
main()
diff --git a/cloud/amazon/sts_session_token.py b/cloud/amazon/sts_session_token.py
index dc284dea..320cc1d2 100644
--- a/cloud/amazon/sts_session_token.py
+++ b/cloud/amazon/sts_session_token.py
@@ -46,6 +46,7 @@ extends_documentation_fragment:
requirements:
- boto3
- botocore
+ - python >= 2.6
'''
RETURN = """
@@ -92,6 +93,10 @@ try:
except ImportError:
HAS_BOTO3 = False
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
+
+
def normalize_credentials(credentials):
access_key = credentials.get('AccessKeyId', None)
secret_key = credentials.get('SecretAccessKey', None)
@@ -121,7 +126,7 @@ def get_session_token(connection, module):
try:
response = connection.get_session_token(**args)
changed = True
- except ClientError, e:
+ except ClientError as e:
module.fail_json(msg=e)
credentials = normalize_credentials(response.get('Credentials', {}))
@@ -151,9 +156,5 @@ def main():
get_session_token(connection, module)
-# import module snippets
-from ansible.module_utils.basic import *
-from ansible.module_utils.ec2 import *
-
if __name__ == '__main__':
main()