From a14420dcf0e1dde7664732e13b0801f80ba67dc8 Mon Sep 17 00:00:00 2001 From: Alan Loi Date: Wed, 24 Jun 2015 07:45:23 +1000 Subject: [PATCH] Fix sqs_queue module to check that boto library is installed and AWS region & credentials are provided. --- .../modules/extras/cloud/amazon/sqs_queue.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/amazon/sqs_queue.py b/lib/ansible/modules/extras/cloud/amazon/sqs_queue.py index 6bc41544cf..a40433441a 100644 --- a/lib/ansible/modules/extras/cloud/amazon/sqs_queue.py +++ b/lib/ansible/modules/extras/cloud/amazon/sqs_queue.py @@ -84,7 +84,7 @@ EXAMPLES = ''' try: import boto.sqs - from boto.exception import BotoServerError + from boto.exception import BotoServerError, NoAuthHandlerFound HAS_BOTO = True except ImportError: @@ -204,8 +204,18 @@ def main(): argument_spec=argument_spec, supports_check_mode=True) + if not HAS_BOTO: + module.fail_json(msg='boto required for this module') + region, ec2_url, aws_connect_params = get_aws_connection_info(module) - connection = boto.sqs.connect_to_region(region) + if not region: + module.fail_json(msg='region must be specified') + + try: + connection = connect_to_aws(boto.sqs, region, **aws_connect_params) + + except (NoAuthHandlerFound, StandardError), e: + module.fail_json(msg=str(e)) state = module.params.get('state') if state == 'present':