diff --git a/lib/ansible/module_utils/aws/core.py b/lib/ansible/module_utils/aws/core.py index 3fb9a6c331..91267cc724 100644 --- a/lib/ansible/module_utils/aws/core.py +++ b/lib/ansible/module_utils/aws/core.py @@ -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):