ec2_ami_copy.py: Fix WaiterError handling. (#27416)

* ec2_ami_copy.py: Fix WaiterError handling.

Change suggested by Adam Johnson at https://github.com/ansible/ansible/issues/26971

* ec2_ami_copy.py: WaiterError: fail_json: add exception parameter.

* ec2_ami_copy.py: import traceback
pull/23574/merge
piotrkarbowski-ciklum 7 years ago committed by Sloane Hertel
parent e992e4f436
commit a260d99f74

@ -133,6 +133,8 @@ EXAMPLES = '''
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import (boto3_conn, ec2_argument_spec, get_aws_connection_info)
import traceback
try:
import boto
import boto.ec2
@ -180,7 +182,7 @@ def copy_image(module, ec2):
module.exit_json(changed=True, image_id=image_id)
except WaiterError as we:
module.fail_json(msg='An error occurred waiting for the image to become available. (%s)' % we.reason)
module.fail_json(msg='An error occurred waiting for the image to become available. (%s)' % str(we), exception=traceback.format_exc())
except ClientError as ce:
module.fail_json(msg=ce.message)
except NoCredentialsError:

Loading…
Cancel
Save