diff --git a/ec2_asg_wait_for_lifecycle_hooks.yaml b/ec2_asg_wait_for_lifecycle_hooks.yaml new file mode 100644 index 00000000000..23fed95dce4 --- /dev/null +++ b/ec2_asg_wait_for_lifecycle_hooks.yaml @@ -0,0 +1,2 @@ +bugfixes: +- ec2_asg - wait for lifecycle hooks to complete (https://github.com/ansible/ansible/issues/37281) diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index 6184083fd79..38bfc3df3cf 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py @@ -1344,7 +1344,7 @@ def wait_for_term_inst(connection, term_instances): lifecycle = instance_facts[i]['lifecycle_state'] health = instance_facts[i]['health_status'] module.debug("Instance %s has state of %s,%s" % (i, lifecycle, health)) - if lifecycle == 'Terminating' or health == 'Unhealthy': + if lifecycle.startswith('Terminating') or health == 'Unhealthy': count += 1 time.sleep(10)