-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests are now completed for ec2_vpc_nat_gateway module
- Loading branch information
1 parent
32156a5
commit ed09414
Showing
4 changed files
with
72 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test_subnet_id: 'subnet-123456789' |
54 changes: 35 additions & 19 deletions
54
test/integrations/roles/ec2_vpc_nat_gateway/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,76 @@ | ||
- name: Launching NAT Gateway and allocate a new eip, but not if one already exists | ||
- name: Launching NAT Gateway and allocate a new eip. | ||
ec2_vpc_nat_gateway: | ||
region: us-west-2 | ||
state: present | ||
subnet_id: subnet-123456789 | ||
if_exist_do_not_create: yes | ||
subnet_id: "{{ test_subnet_id }}" | ||
wait: yes | ||
wait_timeout: 10 | ||
wait_timeout: 600 | ||
register: nat | ||
|
||
- debug: | ||
var: nat | ||
- fail: | ||
msg: "Changed is true" | ||
when: '"{{ nat["changed"] }}" == "True"' | ||
msg: "Failed to create" | ||
when: '"{{ nat["changed"] }}" != "True"' | ||
|
||
- name: Launch a new gateway only if one does not exist already in this subnet. | ||
ec2_vpc_nat_gateway: | ||
if_exist_do_not_create: yes | ||
region: us-west-2 | ||
state: present | ||
subnet_id: "{{ test_subnet_id }}" | ||
wait: yes | ||
wait_timeout: 600 | ||
register: nat_idempotent | ||
|
||
- debug: | ||
var: nat_idempotent | ||
- fail: | ||
msg: "Failed to be idempotent" | ||
when: '"{{ nat_idempotent["changed"] }}" == "True"' | ||
|
||
- name: Launching NAT Gateway and allocate a new eip even if one already exists in the subnet | ||
- name: Launching NAT Gateway and allocate a new eip even if one already exists in the subnet. | ||
ec2_vpc_nat_gateway: | ||
region: us-west-2 | ||
state: present | ||
subnet_id: subnet-123456789 | ||
subnet_id: "{{ test_subnet_id }}" | ||
wait: yes | ||
wait_timeout: 10 | ||
wait_timeout: 600 | ||
register: new_nat | ||
|
||
- debug: | ||
var: new_nat | ||
- fail: | ||
msg: "Changed is false" | ||
when: '"{{ new_nat["changed"] }}" == "False"' | ||
msg: "Failed to create" | ||
when: '"{{ new_nat["changed"] }}" != "True"' | ||
|
||
- name: Launching NAT Gateway with allocation id | ||
- name: Launching NAT Gateway with allocation id, this call is idempotent and will not create anything. | ||
ec2_vpc_nat_gateway: | ||
allocation_id: eipalloc-123456789 | ||
allocation_id: eipalloc-1234567 | ||
region: us-west-2 | ||
state: present | ||
subnet_id: subnet-123456789 | ||
subnet_id: "{{ test_subnet_id }}" | ||
wait: yes | ||
wait_timeout: 10 | ||
wait_timeout: 600 | ||
register: nat_with_eipalloc | ||
|
||
- debug: | ||
var: nat_with_eipalloc | ||
- fail: | ||
msg: 'Failed, the eipalloc-123456789 != {{ nat_with_eipalloc["nat_gateway_addresses"][0]["allocation_id"] }}' | ||
when: '"{{ nat_with_eipalloc["nat_gateway_addresses"][0]["allocation_id"] }}" != "eipalloc-123456789"' | ||
msg: 'Failed to be idempotent.' | ||
when: '"{{ nat_with_eipalloc["changed"] }}" == "True"' | ||
|
||
- name: Delete the 1st nat gateway and do not wait for it to finish | ||
ec2_vpc_nat_gateway: | ||
region: us-west-2 | ||
nat_gateway_id: "{{ nat.nat_gateway_id }}" | ||
state: absent | ||
|
||
- name: Delete the previous nat gateway | ||
- name: Delete the nat_with_eipalloc and release the eip | ||
ec2_vpc_nat_gateway: | ||
region: us-west-2 | ||
nat_gateway_id: "{{ new_nat.nat_gateway_id }}" | ||
release_eip: yes | ||
state: absent | ||
wait: yes | ||
wait_timeout: 10 | ||
wait_timeout: 600 |