mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
[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
This commit is contained in:
@@ -169,11 +169,29 @@ class AnsibleAWSModule(object):
|
||||
except AttributeError:
|
||||
response = None
|
||||
|
||||
if response is None:
|
||||
self._module.fail_json(msg=message, exception=last_traceback)
|
||||
else:
|
||||
self._module.fail_json(msg=message, exception=last_traceback,
|
||||
**camel_dict_to_snake_dict(response))
|
||||
failure = dict(
|
||||
msg=message,
|
||||
exception=last_traceback,
|
||||
**self._gather_versions()
|
||||
)
|
||||
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user