[AWS] report boto3/botocore versions during `fail_json_aws` (#39298)

* [AWS] report boto3/botocore versions during `fail_json_aws`

When modules call `fail_json_aws` and boto3 is installed, gather the
boto3 and botocore versions so that any new AWS module issues will
include the user's boto3 installation info. This will make debugging
issues where features aren't available yet easier.

* PEP8

* Switch to `dict` rather than tuple returns
pull/39404/head
Ryan Brown 7 years ago committed by Will Thames
parent 61bcf4740f
commit 86db62c0e9

@ -169,11 +169,29 @@ class AnsibleAWSModule(object):
except AttributeError: except AttributeError:
response = None response = None
if response is None: failure = dict(
self._module.fail_json(msg=message, exception=last_traceback) msg=message,
else: exception=last_traceback,
self._module.fail_json(msg=message, exception=last_traceback, **self._gather_versions()
**camel_dict_to_snake_dict(response)) )
if response is not None:
failure.update(**camel_dict_to_snake_dict(response))
self._module.fail_json(**failure)
def _gather_versions(self):
"""Gather AWS SDK (boto3 and botocore) dependency versions
Returns {'boto3_version': str, 'botocore_version': str}
Returns {} if neither are installed
"""
if not HAS_BOTO3:
return {}
import boto3
import botocore
return dict(boto3_version=boto3.__version__,
botocore_version=botocore.__version__)
class _RetryingBotoClientWrapper(object): class _RetryingBotoClientWrapper(object):

Loading…
Cancel
Save