From 706bdbf2845cf7650eb0848a2a2657121ba885aa Mon Sep 17 00:00:00 2001 From: jjshoe Date: Sat, 8 Oct 2016 07:09:44 -0500 Subject: [PATCH] Catch the rare condition where ami creation failed, this is critical when you have a 10-15 minute wait on ami creation. This rarely happens, and is tough to reproduce, but it does happen. (#5106) --- lib/ansible/modules/cloud/amazon/ec2_ami.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/modules/cloud/amazon/ec2_ami.py b/lib/ansible/modules/cloud/amazon/ec2_ami.py index 12794d8e13..20981f9ce5 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_ami.py +++ b/lib/ansible/modules/cloud/amazon/ec2_ami.py @@ -399,6 +399,8 @@ def create_image(module, ec2): if img.state == 'available': break + elif img.state == 'failed': + module.fail_json(msg="AMI creation failed, please see the AWS console for more details") except boto.exception.EC2ResponseError as e: if ('InvalidAMIID.NotFound' not in e.error_code and 'InvalidAMIID.Unavailable' not in e.error_code) and wait and i == wait_timeout - 1: module.fail_json(msg="Error while trying to find the new image. Using wait=yes and/or a longer wait_timeout may help. %s: %s" % (e.error_code, e.error_message))