From 3ca006ecbbc96be70064dd852e5577747c02c995 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Thu, 1 Jun 2017 22:53:31 +1000 Subject: [PATCH] Allow removal of target groups from ASGs (#25126) An empty `target_group_arns` list represents no target groups. This is different to not passing a `target_group_arns` list at all which can signify no change. Remove unnecessary empty list construction, as it must already be an empty list to get to that point. --- lib/ansible/modules/cloud/amazon/ec2_asg.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index 6837523c598..ff98b2638ad 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py @@ -694,10 +694,8 @@ def create_autoscaling_group(connection, module): module.fail_json(msg="Failed to update Autoscaling Group.", exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response)) # Update target groups if they are specified and one or more already exists - elif target_group_arns and as_group['TargetGroupARNs']: + elif target_group_arns is not None and as_group['TargetGroupARNs']: # Get differences - if not target_group_arns: - target_group_arns = list() wanted_tgs = set(target_group_arns) has_tgs = set(as_group['TargetGroupARNs']) # check if all requested are already existing