From cc4854fdadd200e9f08727961678a1c9e60c5bbe Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Thu, 6 Sep 2018 13:22:10 -0400 Subject: [PATCH] =?UTF-8?q?ec2=5Fvpc=5Froute=5Ftable=20-=20allow=20routes?= =?UTF-8?q?=20to=20be=20created=20if=20the=20CIDR=20already=20=E2=80=A6=20?= =?UTF-8?q?(#45178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ec2_vpc_route_table - allow routes to be created if the CIDR already exists but its 'Origin' is 'EnableVgwRoutePropagation' (which cannot be replaced). (#43417) Fixes #43415 (cherry picked from commit a6c97f22435924860a02130f976232ae7f891275) --- .../fragments/ec2_vpc_route_table_replace_route_fix.yaml | 4 ++++ lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ec2_vpc_route_table_replace_route_fix.yaml diff --git a/changelogs/fragments/ec2_vpc_route_table_replace_route_fix.yaml b/changelogs/fragments/ec2_vpc_route_table_replace_route_fix.yaml new file mode 100644 index 00000000000..143a9e86fb1 --- /dev/null +++ b/changelogs/fragments/ec2_vpc_route_table_replace_route_fix.yaml @@ -0,0 +1,4 @@ +--- +bugfixes: +- ec2_vpc_route_table - check the origin before replacing routes. + Routes with the origin 'EnableVgwRoutePropagation' may not be replaced. diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py index 64657eac08c..1567aef29a7 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py @@ -432,8 +432,9 @@ def index_of_matching_route(route_spec, routes_to_match): for i, route in enumerate(routes_to_match): if route_spec_matches_route(route_spec, route): return "exact", i - elif route_spec_matches_route_cidr(route_spec, route): - return "replace", i + elif 'Origin' in route_spec and route_spec['Origin'] != 'EnableVgwRoutePropagation': + if route_spec_matches_route_cidr(route_spec, route): + return "replace", i def ensure_routes(connection=None, module=None, route_table=None, route_specs=None,