Skip to content

Commit

Permalink
Move tests to using module_defaults (ansible-collections#368)
Browse files Browse the repository at this point in the history
* Bulk migration to module_defaults
* Tests for missing creds/region
* Move dms_identifier and dms_sg_identifier into defaults

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@365b6ef
  • Loading branch information
tremble authored and alinabuzachis committed Oct 23, 2024
1 parent bdad5b0 commit 01dc54c
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions tests/integration/targets/ec2_vpc_vgw/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
---
- name: ec2_vpc_net tests
- name: 'ec2_vpc_vgw integration tests'
collections:
- amazon.aws
module_defaults:
group/aws:
aws_access_key: '{{ aws_access_key }}'
aws_secret_key: '{{ aws_secret_key }}'
security_token: '{{ security_token | default(omit) }}'
region: '{{ aws_region }}'
block:

# ============================================================
- name: set up aws connection info
set_fact:
aws_connection_info: &aws_connection_info
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token }}"
region: "{{ aws_region }}"
no_log: yes

# ============================================================
- debug: msg="Setting up test dependencies"

Expand All @@ -22,7 +18,6 @@
name: "{{ resource_prefix }}-vpc-{{ item }}"
state: present
cidr_block: "10.0.0.0/26"
<<: *aws_connection_info
tags:
Name: "{{ resource_prefix }}-vpc-{{ item }}"
Description: "Created by ansible-test"
Expand All @@ -42,7 +37,6 @@
state: present
vpc_id: '{{ vpc_id_1 }}'
name: "{{ resource_prefix }}-vgw"
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -56,7 +50,6 @@
state: present
vpc_id: '{{ vpc_id_1 }}'
name: "{{ resource_prefix }}-vgw"
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -69,7 +62,6 @@
state: present
vpc_id: '{{ vpc_id_2 }}'
name: "{{ resource_prefix }}-vgw"
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -85,7 +77,6 @@
name: "{{ resource_prefix }}-vgw"
tags:
created_by: ec2_vpc_vgw integration tests
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -101,7 +92,6 @@
name: "{{ resource_prefix }}-vgw"
tags:
created_by: ec2_vpc_vgw integration tests
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -114,7 +104,6 @@
state: present
vpc_id: '{{ vpc_id_2 }}'
name: "{{ resource_prefix }}-vgw"
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -128,7 +117,6 @@
ec2_vpc_vgw:
state: present
name: "{{ resource_prefix }}-vgw"
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -140,7 +128,6 @@
ec2_vpc_vgw:
state: present
name: "{{ resource_prefix }}-vgw"
<<: *aws_connection_info
register: vgw

- assert:
Expand All @@ -157,15 +144,13 @@
ec2_vpc_vgw:
state: absent
vpn_gateway_id: '{{ vgw.vgw.id }}'
<<: *aws_connection_info
ignore_errors: yes

- name: delete vpc
ec2_vpc_net:
name: "{{ resource_prefix }}-vpc-{{ item }}"
state: absent
cidr_block: "10.0.0.0/26"
<<: *aws_connection_info
loop: [1, 2]
register: result
retries: 10
Expand Down

0 comments on commit 01dc54c

Please sign in to comment.