From 9167abdd10a7b5512f27f2f677eac4e99d7d1e93 Mon Sep 17 00:00:00 2001 From: Doug Luce Date: Wed, 30 Mar 2016 15:00:37 -0700 Subject: [PATCH] Fix S3 unavailable region error This is to address this error: fatal: [site]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to connect to S3: Region does not seem to be available for awsmodule boto.s3. If the region definitely exists, you may need to upgrade boto or extend with endpoints_path"} Commit 0dd58e9 changed the logic so an exception is thrown (by `connect_to_aws`) before the `s3 is None` check is performed. This changes the `None` check to a catch so the old logic can compensate. --- lib/ansible/modules/cloud/amazon/s3.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) mode change 100644 => 100755 lib/ansible/modules/cloud/amazon/s3.py diff --git a/lib/ansible/modules/cloud/amazon/s3.py b/lib/ansible/modules/cloud/amazon/s3.py old mode 100644 new mode 100755 index 69a01ac6c5..0a972ae8d9 --- a/lib/ansible/modules/cloud/amazon/s3.py +++ b/lib/ansible/modules/cloud/amazon/s3.py @@ -460,9 +460,10 @@ def main(): s3 = boto.connect_walrus(walrus, **aws_connect_kwargs) else: aws_connect_kwargs['is_secure'] = True - s3 = connect_to_aws(boto.s3, location, **aws_connect_kwargs) - # use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases - if s3 is None: + try: + s3 = connect_to_aws(boto.s3, location, **aws_connect_kwargs) + except AnsibleAWSError: + # use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases s3 = boto.connect_s3(**aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: