From 27827ce728e46c8c9284fa81fae3d7778cb46a85 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 13 Nov 2018 18:52:32 +0530 Subject: [PATCH] ec2_ami_copy: Fix unreferenced variable error (#47598) Fixes: #47595 Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cloud/amazon/ec2_ami_copy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_ami_copy.py b/lib/ansible/modules/cloud/amazon/ec2_ami_copy.py index f630faabe6..65c42e9917 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_ami_copy.py +++ b/lib/ansible/modules/cloud/amazon/ec2_ami_copy.py @@ -142,6 +142,7 @@ image_id: from ansible.module_utils.aws.core import AnsibleAWSModule from ansible.module_utils.ec2 import ec2_argument_spec from ansible.module_utils.ec2 import camel_dict_to_snake_dict, ansible_dict_to_boto3_tag_list +from ansible.module_utils._text import to_native try: from botocore.exceptions import ClientError, NoCredentialsError, WaiterError, BotoCoreError @@ -189,6 +190,7 @@ def copy_image(module, ec2): if module.params.get('wait'): delay = 15 max_attempts = module.params.get('wait_timeout') // delay + image_id = image.get('ImageId') ec2.get_waiter('image_available').wait( ImageIds=[image_id], WaiterConfig={'Delay': delay, 'MaxAttempts': max_attempts} @@ -200,7 +202,7 @@ def copy_image(module, ec2): except (ClientError, BotoCoreError) as e: module.fail_json_aws(e, msg="Could not copy AMI") except Exception as e: - module.fail_json(msg='Unhandled exception. (%s)' % str(e)) + module.fail_json(msg='Unhandled exception. (%s)' % to_native(e)) def main():