1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Sort subnets by the order they are specified in the play

Fixes #172
This commit is contained in:
Toshio Kuratomi 2015-03-06 14:55:11 -08:00 committed by Matt Clay
parent 650a7365f9
commit bba322a10e

View file

@ -506,6 +506,15 @@ def create_vpc(module, vpc_conn):
'id': sn.id, '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) return (vpc_dict, created_vpc_id, returned_subnets, changed)
def terminate_vpc(module, vpc_conn, vpc_id=None, cidr=None): def terminate_vpc(module, vpc_conn, vpc_id=None, cidr=None):