diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index 7602efdd7b..d7be8bb812 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