mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
[cloud] make ec2_asg honor 'wait_for_instances' on delete
This commit is contained in:
parent
5f29117e59
commit
b1f06f6555
1 changed files with 9 additions and 5 deletions
|
@ -588,6 +588,7 @@ def create_autoscaling_group(connection, module):
|
||||||
def delete_autoscaling_group(connection, module):
|
def delete_autoscaling_group(connection, module):
|
||||||
group_name = module.params.get('name')
|
group_name = module.params.get('name')
|
||||||
notification_topic = module.params.get('notification_topic')
|
notification_topic = module.params.get('notification_topic')
|
||||||
|
wait_for_instances = module.params.get('wait_for_instances')
|
||||||
|
|
||||||
if notification_topic:
|
if notification_topic:
|
||||||
ag.delete_notification_configuration(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])
|
groups = connection.get_all_groups(names=[group_name])
|
||||||
if groups:
|
if groups:
|
||||||
group = groups[0]
|
group = groups[0]
|
||||||
|
|
||||||
|
if not wait_for_instances:
|
||||||
|
group.delete(True)
|
||||||
|
return True
|
||||||
|
|
||||||
group.max_size = 0
|
group.max_size = 0
|
||||||
group.min_size = 0
|
group.min_size = 0
|
||||||
group.desired_capacity = 0
|
group.desired_capacity = 0
|
||||||
|
@ -611,11 +617,9 @@ def delete_autoscaling_group(connection, module):
|
||||||
group.delete()
|
group.delete()
|
||||||
while len(connection.get_all_groups(names=[group_name])):
|
while len(connection.get_all_groups(names=[group_name])):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
changed=True
|
return True
|
||||||
return changed
|
|
||||||
else:
|
return False
|
||||||
changed=False
|
|
||||||
return changed
|
|
||||||
|
|
||||||
def get_chunks(l, n):
|
def get_chunks(l, n):
|
||||||
for i in xrange(0, len(l), n):
|
for i in xrange(0, len(l), n):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue