From d6f62694e25b09c075972421e595a9c050fb096d Mon Sep 17 00:00:00 2001 From: George Christou Date: Mon, 15 Aug 2016 08:02:21 +0100 Subject: [PATCH] Fix bug in counting subnets by Name tag (#1643) Fixes #1551 --- .../modules/extras/cloud/amazon/ec2_vpc_route_table.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py index cec8b6f6123..c0cfaf42781 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py @@ -186,11 +186,11 @@ def find_subnets(vpc_conn, vpc_id, identified_subnets): filters={'vpc_id': vpc_id, 'tag:Name': subnet_names}) for name in subnet_names: - matching = [s.tags.get('Name') == name for s in subnets_by_name] - if len(matching) == 0: + matching_count = len([1 for s in subnets_by_name if s.tags.get('Name') == name]) + if matching_count == 0: raise AnsibleSubnetSearchException( 'Subnet named "{0}" does not exist'.format(name)) - elif len(matching) > 1: + elif matching_count > 1: raise AnsibleSubnetSearchException( 'Multiple subnets named "{0}"'.format(name))