From 7f61b8bebd2929940495204f1a98d660a55985d8 Mon Sep 17 00:00:00 2001 From: "Joshua C. Randall" Date: Mon, 6 Mar 2017 15:27:11 +0000 Subject: [PATCH] Fix get_s3_connection (fixes #22317) Override aws_connect_kwargs rather than prepending to them. Should fix an issue in which `calling_format` is set twice in the kwargs passed to `boto.connect_s3` or `S3Connection` if a bucket name contains a `.` --- lib/ansible/modules/cloud/amazon/s3.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/s3.py b/lib/ansible/modules/cloud/amazon/s3.py index cacbccdbfd4..a4267cb42a1 100644 --- a/lib/ansible/modules/cloud/amazon/s3.py +++ b/lib/ansible/modules/cloud/amazon/s3.py @@ -713,22 +713,18 @@ def main(): def get_s3_connection(aws_connect_kwargs, location, rgw, s3_url): if s3_url and rgw: rgw = urlparse(s3_url) - s3 = boto.connect_s3( - is_secure=rgw.scheme == 'https', - host=rgw.hostname, - port=rgw.port, - calling_format=OrdinaryCallingFormat(), - **aws_connect_kwargs - ) + aws_connect_kwargs['is_secure'] = rgw.scheme == 'https' + aws_connect_kwargs['host'] = rgw.hostname + aws_connect_kwargs['port'] = rgw.port + aws_connect_kwargs['calling_format'] = OrdinaryCallingFormat() + s3 = boto.connect_s3(**aws_connect_kwargs) elif is_fakes3(s3_url): fakes3 = urlparse(s3_url) - s3 = S3Connection( - is_secure=fakes3.scheme == 'fakes3s', - host=fakes3.hostname, - port=fakes3.port, - calling_format=OrdinaryCallingFormat(), - **aws_connect_kwargs - ) + aws_connect_kwargs['is_secure'] = fakes3.scheme == 'fakes3s' + aws_connect_kwargs['host'] = fakes3.hostname + aws_connect_kwargs['port'] = fakes3.port + aws_connect_kwargs['calling_format'] = OrdinaryCallingFormat() + s3 = S3Connection(**aws_connect_kwargs) elif is_walrus(s3_url): walrus = urlparse(s3_url).hostname s3 = boto.connect_walrus(walrus, **aws_connect_kwargs)