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 16, 2024
1 parent 7a75f8c commit d61f3a9
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions tests/integration/targets/ec2_vpc_vpn_info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
---
- name: ec2_vpc_vpn_info tests
- name: 'ec2_vpc_vpn_info 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

# ============================================================
- name: create a VPC
ec2_vpc_net:
name: "{{ resource_prefix }}-vpc"
state: present
cidr_block: "10.0.0.0/26"
<<: *aws_connection_info
tags:
Name: "{{ resource_prefix }}-vpc"
Description: "Created by ansible-test"
Expand All @@ -31,29 +26,25 @@
state: present
vpc_id: '{{ vpc_result.vpc.id }}'
name: "{{ resource_prefix }}-vgw"
<<: *aws_connection_info
register: vgw

- name: create customer gateway
ec2_customer_gateway:
bgp_asn: 12345
ip_address: 1.2.3.4
name: testcgw
<<: *aws_connection_info
register: cgw

- name: create vpn connection, with customer gateway
ec2_vpc_vpn:
customer_gateway_id: '{{ cgw.gateway.customer_gateway.customer_gateway_id }}'
vpn_gateway_id: '{{ vgw.vgw.id }}'
state: present
<<: *aws_connection_info
register: vpn

# ============================================================
- name: test success with no parameters
ec2_vpc_vpn_info:
<<: *aws_connection_info
register: result

- name: assert success with no parameters
Expand All @@ -67,7 +58,6 @@
filters:
customer-gateway-id: '{{ cgw.gateway.customer_gateway.customer_gateway_id }}'
vpn-connection-id: '{{ vpn.vpn_connection_id }}'
<<: *aws_connection_info
register: result

- name: assert success with customer gateway id as filter
Expand All @@ -83,7 +73,6 @@
ec2_vpc_vpn:
state: absent
vpn_connection_id: '{{ vpn.vpn_connection_id }}'
<<: *aws_connection_info
register: result
retries: 10
delay: 3
Expand All @@ -96,7 +85,6 @@
ip_address: 1.2.3.4
name: testcgw
bgp_asn: 12345
<<: *aws_connection_info
register: result
retries: 10
delay: 3
Expand All @@ -107,7 +95,6 @@
ec2_vpc_vgw:
state: absent
vpn_gateway_id: '{{ vgw.vgw.id }}'
<<: *aws_connection_info
register: result
retries: 10
delay: 3
Expand All @@ -119,7 +106,6 @@
name: "{{ resource_prefix }}-vpc"
state: absent
cidr_block: "10.0.0.0/26"
<<: *aws_connection_info
register: result
retries: 10
delay: 3
Expand Down

0 comments on commit d61f3a9

Please sign in to comment.