From d3cdb9f2f85495baa6b2b7843a645967df51ad46 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 10 Feb 2021 12:32:15 +0100 Subject: [PATCH] Move tests to using module_defaults (#368) * 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: https://github.com/ansible-collections/community.aws/commit/365b6ef9a7a5e78e1bcf0d190ab66957bed5e3dd --- .../targets/ec2_vpc_egress_igw/tasks/main.yml | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml b/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml index b9ce40cd968..91a54d81d7a 100644 --- a/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml @@ -1,8 +1,13 @@ --- -- name: ec2_vpc_egress_igw tests +- name: 'ec2_vpc_egress_igw 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: # ============================================================ @@ -17,22 +22,11 @@ - 'result.failed' - 'result.msg == "missing required arguments: vpc_id"' - # ============================================================ - - 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: test failure with non-existent VPC ID ec2_vpc_egress_igw: state: present vpc_id: vpc-012345678 - <<: *aws_connection_info register: result ignore_errors: true @@ -49,7 +43,6 @@ name: "{{ resource_prefix }}-vpc" state: present cidr_block: "10.232.232.128/26" - <<: *aws_connection_info tags: Name: "{{ resource_prefix }}-vpc" Description: "Created by ansible-test" @@ -60,7 +53,6 @@ ec2_vpc_egress_igw: state: present vpc_id: "{{ vpc_result.vpc.id }}" - <<: *aws_connection_info register: vpc_eigw_create - name: assert creation happened (expected changed=true) @@ -75,7 +67,6 @@ ec2_vpc_egress_igw: state: present vpc_id: "{{ vpc_result.vpc.id }}" - <<: *aws_connection_info register: vpc_eigw_recreate - name: assert recreation did nothing (expected changed=false) @@ -90,7 +81,6 @@ ec2_vpc_egress_igw: state: absent vpc_id: "{{ vpc_result.vpc.id }}" - <<: *aws_connection_info register: vpc_eigw_delete - name: assert state=absent (expected changed=true) @@ -104,7 +94,6 @@ ec2_vpc_egress_igw: state: absent vpc_id: "{{ vpc_result.vpc.id }}" - <<: *aws_connection_info ignore_errors: true - name: tidy up VPC @@ -112,5 +101,4 @@ name: "{{ resource_prefix }}-vpc" state: absent cidr_block: "10.232.232.128/26" - <<: *aws_connection_info ignore_errors: true