Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ec2_vpc_nat_gateway integration test. #18271

Merged
merged 2 commits into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions test/integration/amazon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#- { role: test_ec2_ami, tags: test_ec2_ami }
#- { role: test_ec2, tags: test_ec2 }
- { role: test_ec2_asg, tags: test_ec2_asg }
- { role: test_ec2_vpc_nat_gateway, tags: test_ec2_vpc_nat_gateway }

# complex test for ec2_elb, split up over multiple plays
# since there is a setup component as well as the test which
Expand Down
76 changes: 76 additions & 0 deletions test/integration/roles/test_ec2_vpc_nat_gateway/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
- name: Launching NAT Gateway and allocate a new eip.
ec2_vpc_nat_gateway:
region: us-west-2
state: present
subnet_id: "{{ test_subnet_id }}"
wait: yes
wait_timeout: 600
register: nat

- debug:
var: nat
- fail:
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.
ec2_vpc_nat_gateway:
region: us-west-2
state: present
subnet_id: "{{ test_subnet_id }}"
wait: yes
wait_timeout: 600
register: new_nat

- debug:
var: new_nat
- fail:
msg: "Failed to create"
when: '"{{ new_nat["changed"] }}" != "True"'

- name: Launching NAT Gateway with allocation id, this call is idempotent and will not create anything.
ec2_vpc_nat_gateway:
allocation_id: eipalloc-1234567
region: us-west-2
state: present
subnet_id: "{{ test_subnet_id }}"
wait: yes
wait_timeout: 600
register: nat_with_eipalloc

- debug:
var: nat_with_eipalloc
- fail:
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 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: 600
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test_subnet_id: 'subnet-123456789'