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 goneri committed Sep 21, 2022
1 parent 02c37c0 commit cda0b0b
Showing 1 changed file with 7 additions and 36 deletions.
43 changes: 7 additions & 36 deletions tests/integration/targets/route53_zone/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
---
- name: route53_zone tests
- name: 'route53_zone 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 connection information for all tasks
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: true

- name: Create VPC for use in testing
ec2_vpc_net:
Expand All @@ -21,7 +19,6 @@
tags:
Name: Ansible ec2_instance Testing VPC
tenancy: default
<<: *aws_connection_info
register: testing_vpc

# ============================================================
Expand All @@ -30,7 +27,6 @@
zone: "{{ resource_prefix }}.public"
comment: original comment
state: present
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -46,7 +42,6 @@
zone: "{{ resource_prefix }}.check.public"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -63,7 +58,6 @@
zone: "{{ resource_prefix }}.public"
comment: original comment
state: present
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -78,7 +72,6 @@
zone: "{{ resource_prefix }}.public"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -95,7 +88,6 @@
zone: "{{ resource_prefix }}.public"
comment: updated comment
state: present
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -108,7 +100,6 @@
zone: "{{ resource_prefix }}.public"
comment: updated comment for check
state: present
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -122,7 +113,6 @@
route53_zone:
zone: "{{ resource_prefix }}.public"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -135,7 +125,6 @@
route53_zone:
zone: "{{ resource_prefix }}.public"
state: absent
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -151,7 +140,6 @@
zone: "{{ resource_prefix }}.private"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -166,7 +154,6 @@
zone: "{{ resource_prefix }}.private"
comment: original comment
state: present
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -180,7 +167,6 @@
zone: "{{ resource_prefix }}.private"
comment: original comment
state: present
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -195,7 +181,6 @@
zone: "{{ resource_prefix }}.private"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -212,7 +197,6 @@
zone: "{{ resource_prefix }}.private"
comment: updated_comment
state: present
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -227,7 +211,6 @@
zone: "{{ resource_prefix }}.private"
comment: updated_comment check
state: present
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -241,7 +224,6 @@
route53_zone:
zone: "{{ resource_prefix }}.private"
state: absent
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -253,7 +235,6 @@
route53_zone:
zone: "{{ resource_prefix }}.private"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -268,7 +249,6 @@
zone: "{{ resource_prefix }}.publicfake"
comment: original comment
state: absent
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -281,7 +261,6 @@
zone: "{{ resource_prefix }}.publicfake"
comment: original comment
state: absent
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -297,7 +276,6 @@
vpc_region: "{{ aws_region }}"
zone: "{{ resource_prefix }}.private"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -312,7 +290,6 @@
vpc_region: "{{ aws_region }}"
zone: "{{ resource_prefix }}.private"
state: absent
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -326,7 +303,6 @@
zone: "{{ resource_prefix }}.public2"
comment: this is an example
state: present
<<: *aws_connection_info
register: new_zone

# Delete zone using its id
Expand All @@ -335,7 +311,6 @@
zone: "{{ resource_prefix }}.public2"
hosted_zone_id: "{{new_zone.zone_id}}"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes

Expand All @@ -349,7 +324,6 @@
zone: "{{ resource_prefix }}.public2"
hosted_zone_id: "{{new_zone.zone_id}}"
state: absent
<<: *aws_connection_info
register: output

- assert:
Expand All @@ -363,7 +337,6 @@
route53_zone:
zone: "{{ item }}"
state: absent
<<: *aws_connection_info
register: removed
until: removed is not failed
ignore_errors: yes
Expand All @@ -378,7 +351,6 @@
vpc_region: "{{ aws_region }}"
zone: "{{ resource_prefix }}.private"
state: absent
<<: *aws_connection_info
register: removed
until: removed is not failed
ignore_errors: yes
Expand All @@ -389,7 +361,6 @@
name: "{{ resource_prefix }}-vpc"
cidr_block: 10.22.32.0/23
state: absent
<<: *aws_connection_info
register: removed
until: removed is not failed
ignore_errors: yes
Expand Down

0 comments on commit cda0b0b

Please sign in to comment.