Skip to content

Commit

Permalink
ec2_vpc_route_table - Test idempotency with adding a route (ansible-c…
Browse files Browse the repository at this point in the history
…ollections#496)

* Test idempotency with adding a route
* tweak changelog to include bugfix link
  • Loading branch information
tremble authored Mar 25, 2021
1 parent e7520a1 commit da87de5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelogs/fragments/359-fix-ec2_vpc_route_table.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bugfixes:
- ec2_vpc_route_table - catch RouteAlreadyExists error when rerunning same task twice to make module idempotent
- ec2_vpc_route_table - catch RouteAlreadyExists error when rerunning same task twice to make module idempotent (https://github.com/ansible-collections/community.aws/issues/357).
36 changes: 35 additions & 1 deletion tests/integration/targets/ec2_vpc_route_table/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
state: present
register: vpc

- name: create public subnet
- name: create subnets
ec2_vpc_subnet:
cidr: "{{ item.cidr }}"
az: "{{ aws_region}}{{ item.az }}"
Expand Down Expand Up @@ -170,6 +170,40 @@
- add_routes.route_table.vpc_id == "{{ vpc.vpc.id }}"
- add_routes.route_table.propagating_vgws|length == 0

- name: CHECK MODE - re-add route to public route table
ec2_vpc_route_table:
vpc_id: "{{ vpc.vpc.id }}"
tags:
Public: "true"
Name: "Public route table"
routes:
- dest: 0.0.0.0/0
gateway_id: igw
check_mode: True
register: check_mode_results

- name: assert a route would not be added
assert:
that:
- check_mode_results is not changed

- name: re-add a route to public route table
ec2_vpc_route_table:
vpc_id: "{{ vpc.vpc.id }}"
tags:
Public: "true"
Name: "Public route table"
routes:
- dest: 0.0.0.0/0
gateway_id: igw
register: add_routes

- name: assert route table contains route
assert:
that:
- add_routes is not changed
- add_routes.route_table.routes|length == 2

- name: CHECK MODE - add subnets to public route table
ec2_vpc_route_table:
vpc_id: "{{ vpc.vpc.id }}"
Expand Down

0 comments on commit da87de5

Please sign in to comment.