diff options
author | Toshio Kuratomi <toshio@fedoraproject.org> | 2015-03-06 14:55:11 -0800 |
---|---|---|
committer | Toshio Kuratomi <toshio@fedoraproject.org> | 2015-03-06 14:55:11 -0800 |
commit | edf1ac1ea6ffd5d44bb2bb62ad320364baf310a3 (patch) | |
tree | d44200d295b57e5325c78c7668c7760fbf229280 | |
parent | 3da0aa9f08ddc38a49f3129a320501b108ad58b0 (diff) | |
download | ansible-modules-core-ec2_vpc-sort.tar.gz |
Sort subnets by the order they are specified in the playec2_vpc-sort
Fixes #172
-rw-r--r-- | cloud/amazon/ec2_vpc.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cloud/amazon/ec2_vpc.py b/cloud/amazon/ec2_vpc.py index 00528f27..a4f7c0ad 100644 --- a/cloud/amazon/ec2_vpc.py +++ b/cloud/amazon/ec2_vpc.py @@ -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): |