diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index 77f0a6d48d..a08914e0fa 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py @@ -588,6 +588,7 @@ def create_autoscaling_group(connection, module): def delete_autoscaling_group(connection, module): group_name = module.params.get('name') notification_topic = module.params.get('notification_topic') + wait_for_instances = module.params.get('wait_for_instances') if notification_topic: ag.delete_notification_configuration(notification_topic) @@ -595,6 +596,11 @@ def delete_autoscaling_group(connection, module): groups = connection.get_all_groups(names=[group_name]) if groups: group = groups[0] + + if not wait_for_instances: + group.delete(True) + return True + group.max_size = 0 group.min_size = 0 group.desired_capacity = 0 @@ -611,11 +617,9 @@ def delete_autoscaling_group(connection, module): group.delete() while len(connection.get_all_groups(names=[group_name])): time.sleep(5) - changed=True - return changed - else: - changed=False - return changed + return True + + return False def get_chunks(l, n): for i in xrange(0, len(l), n):