ec2_asg: fix desired_capacity not optional (#34194)

1# Please enter the commit message for your changes. Lines starting
pull/34397/head
René Moser 7 years ago committed by ansibot
parent a323521e46
commit 798aa8a2d2

@ -1145,6 +1145,9 @@ def replace(connection):
replace_instances = module.params.get('replace_instances') replace_instances = module.params.get('replace_instances')
as_group = describe_autoscaling_groups(connection, group_name)[0] as_group = describe_autoscaling_groups(connection, group_name)[0]
if desired_capacity is None:
desired_capacity = as_group['DesiredCapacity']
wait_for_new_inst(connection, group_name, wait_timeout, as_group['MinSize'], 'viable_instances') wait_for_new_inst(connection, group_name, wait_timeout, as_group['MinSize'], 'viable_instances')
props = get_properties(as_group) props = get_properties(as_group)
instances = props['instances'] instances = props['instances']
@ -1178,8 +1181,7 @@ def replace(connection):
min_size = as_group['MinSize'] min_size = as_group['MinSize']
if max_size is None: if max_size is None:
max_size = as_group['MaxSize'] max_size = as_group['MaxSize']
if desired_capacity is None:
desired_capacity = as_group['DesiredCapacity']
# set temporary settings and wait for them to be reached # set temporary settings and wait for them to be reached
# This should get overwritten if the number of instances left is less than the batch size. # This should get overwritten if the number of instances left is less than the batch size.
@ -1265,6 +1267,9 @@ def terminate_batch(connection, replace_instances, initial_instances, leftovers=
break_loop = False break_loop = False
as_group = describe_autoscaling_groups(connection, group_name)[0] as_group = describe_autoscaling_groups(connection, group_name)[0]
if desired_capacity is None:
desired_capacity = as_group['DesiredCapacity']
props = get_properties(as_group) props = get_properties(as_group)
desired_size = as_group['MinSize'] desired_size = as_group['MinSize']
@ -1434,5 +1439,6 @@ def main():
changed = True changed = True
module.exit_json(changed=changed, **asg_properties) module.exit_json(changed=changed, **asg_properties)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

Loading…
Cancel
Save