From cd14b8115b27d716905f5e2777f2bd0de9d0368a Mon Sep 17 00:00:00 2001 From: Bobby Calderwood Date: Tue, 21 Apr 2015 14:56:46 -0400 Subject: [PATCH] Fixes regression introduced by edf1ac1ea6ffd5d44bb2bb62ad320364baf310a3 --- lib/ansible/modules/cloud/amazon/ec2_vpc.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc.py b/lib/ansible/modules/cloud/amazon/ec2_vpc.py index 23c25c27a87..3af74e94964 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc.py @@ -486,14 +486,15 @@ def create_vpc(module, vpc_conn): 'id': sn.id, }) - # Sort subnets by the order they were listed in the play - order = {} - for idx, val in enumerate(subnets): - order[val['cidr']] = idx + if subnets is not None: + # Sort subnets by the order they were listed in the play + order = {} + for idx, val in enumerate(subnets): + order[val['cidr']] = idx - # Number of subnets in the play - subnets_in_play = len(subnets) - returned_subnets.sort(key=lambda x: order.get(x['cidr'], subnets_in_play)) + # Number of subnets in the play + subnets_in_play = len(subnets) + returned_subnets.sort(key=lambda x: order.get(x['cidr'], subnets_in_play)) return (vpc_dict, created_vpc_id, returned_subnets, changed)