Merge pull request #904 from ansible/ec2_vpc-sort
Sort subnets by the order they are specified in the play
This commit is contained in:
commit
d65d04b3f8
1 changed files with 9 additions and 0 deletions
|
@ -506,6 +506,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
|
||||
|
||||
# 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)
|
||||
|
||||
def terminate_vpc(module, vpc_conn, vpc_id=None, cidr=None):
|
||||
|
|
Loading…
Reference in a new issue