[cloud] make ec2_asg honor 'wait_for_instances' on delete

This commit is contained in:
Ralph Rodkey 2017-02-04 14:33:51 -05:00 committed by Ryan S. Brown
parent 5f29117e59
commit b1f06f6555

View file

@ -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):