From 04fcfdad2cce04c8cd3b90889144755b8d4fef45 Mon Sep 17 00:00:00 2001 From: Rowan Wookey Date: Tue, 17 Mar 2015 12:59:47 +0000 Subject: [PATCH] Fixed group name not being passed to wait_for_new_instances when replacing instances Fixed group_name not being passed to wait_for_elb Minor code clean up --- lib/ansible/modules/cloud/amazon/ec2_asg.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index 7602efdd7bd..d7be8bb8120 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py @@ -493,7 +493,7 @@ def replace(connection, module): replace_instances = module.params.get('replace_instances') as_group = connection.get_all_groups(names=[group_name])[0] - wait_for_new_instances(module, connection, as_group, wait_timeout, as_group.min_size, 'viable_instances') + wait_for_new_instances(module, connection, group_name, wait_timeout, as_group.min_size, 'viable_instances') props = get_properties(as_group) instances = props['instances'] replaceable = 0 @@ -513,8 +513,8 @@ def replace(connection, module): as_group.min_size = min_size + batch_size as_group.desired_capacity = desired_capacity + batch_size as_group.update() - wait_for_new_instances(module, connection, as_group, wait_timeout, as_group.min_size, 'viable_instances') - wait_for_elb(connection, module, as_group) + wait_for_new_instances(module, connection, group_name, wait_timeout, as_group.min_size, 'viable_instances') + wait_for_elb(connection, module, group_name) as_group = connection.get_all_groups(names=[group_name])[0] props = get_properties(as_group) instances = props['instances'] @@ -522,7 +522,7 @@ def replace(connection, module): instances = replace_instances for i in get_chunks(instances, batch_size): terminate_batch(connection, module, i) - wait_for_new_instances(module, connection, as_group, wait_timeout, as_group.min_size, 'viable_instances') + wait_for_new_instances(module, connection, group_name, wait_timeout, as_group.min_size, 'viable_instances') wait_for_elb(connection, module, group_name) as_group = connection.get_all_groups(names=[group_name])[0] # return settings to normal @@ -589,8 +589,7 @@ def wait_for_new_instances(module, connection, group_name, wait_timeout, desired wait_timeout = time.time() + wait_timeout while wait_timeout > time.time() and desired_size > props[prop]: time.sleep(10) - as_groups = connection.get_all_groups(names=[group_name]) - as_group = as_groups[0] + as_group = connection.get_all_groups(names=[group_name])[0] props = get_properties(as_group) if wait_timeout <= time.time(): # waiting took too long