From af31cb8fafc6594a225d2a94e002c29be6c26415 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 20 Feb 2015 09:28:11 -0500 Subject: [PATCH] now captures connection exceptions and returns in 'nicer' module failure --- cloud/amazon/ec2_ami.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cloud/amazon/ec2_ami.py b/cloud/amazon/ec2_ami.py index ab1f986356b..401b667c545 100644 --- a/cloud/amazon/ec2_ami.py +++ b/cloud/amazon/ec2_ami.py @@ -242,7 +242,10 @@ def main(): ) module = AnsibleModule(argument_spec=argument_spec) - ec2 = ec2_connect(module) + try: + ec2 = ec2_connect(module) + except Exception, e: + module.json_fail(msg="Error while connecting to aws: %s" % str(e)) if module.params.get('state') == 'absent': if not module.params.get('image_id'):