forked from ansible-collections/community.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
289 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,3 @@ | |
unstable | ||
|
||
cloud/aws | ||
|
||
elasticache_subnet_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cloud/aws |
42 changes: 42 additions & 0 deletions
42
tests/integration/targets/elasticache_subnet_group/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
availability_zone: '{{ ec2_availability_zone_names[0] }}' | ||
|
||
vpc_name: '{{ resource_prefix }}' | ||
subnet_name_a: '{{ resource_prefix }}-a' | ||
subnet_name_b: '{{ resource_prefix }}-b' | ||
subnet_name_c: '{{ resource_prefix }}-c' | ||
subnet_name_d: '{{ resource_prefix }}-d' | ||
|
||
vpc_cidr: '10.{{ 256 | random(seed=resource_prefix) }}.0.0/16' | ||
subnet_cidr_a: '10.{{ 256 | random(seed=resource_prefix) }}.1.0/24' | ||
subnet_cidr_b: '10.{{ 256 | random(seed=resource_prefix) }}.2.0/24' | ||
subnet_cidr_c: '10.{{ 256 | random(seed=resource_prefix) }}.3.0/24' | ||
subnet_cidr_d: '10.{{ 256 | random(seed=resource_prefix) }}.4.0/24' | ||
|
||
subnet_zone_a: '{{ ec2_availability_zone_names[0] }}' | ||
subnet_zone_b: '{{ ec2_availability_zone_names[1] }}' | ||
subnet_zone_c: '{{ ec2_availability_zone_names[0] }}' | ||
subnet_zone_d: '{{ ec2_availability_zone_names[1] }}' | ||
|
||
group_name: '{{ resource_prefix }}' | ||
description_default: 'Subnet Description' | ||
description_updated: 'updated subnet description' | ||
|
||
# Tagging not currently supported, planned with boto3 upgrade | ||
tags_default: | ||
snake_case_key: snake_case_value | ||
camelCaseKey: camelCaseValue | ||
PascalCaseKey: PascalCaseValue | ||
'key with spaces': value with spaces | ||
'Upper With Spaces': Upper With Spaces | ||
|
||
partial_tags: | ||
snake_case_key: snake_case_value | ||
camelCaseKey: camelCaseValue | ||
|
||
updated_tags: | ||
updated_snake_case_key: updated_snake_case_value | ||
updatedCamelCaseKey: updatedCamelCaseValue | ||
UpdatedPascalCaseKey: UpdatedPascalCaseValue | ||
'updated key with spaces': updated value with spaces | ||
'updated Upper With Spaces': Updated Upper With Spaces |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/elasticache_subnet_group/meta/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies: | ||
- prepare_tests | ||
- setup_ec2_facts |
243 changes: 243 additions & 0 deletions
243
tests/integration/targets/elasticache_subnet_group/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
--- | ||
# elasticache_subnet_group integration tests | ||
# | ||
# Current module limitations: | ||
# - check_mode not supported | ||
# - Tagging not supported | ||
# - Returned values *very* limited (almost none) | ||
# | ||
- 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: | ||
# ============================================================ | ||
# Setup infra needed for tests | ||
- name: create a VPC | ||
ec2_vpc_net: | ||
state: present | ||
name: '{{ vpc_name }}' | ||
cidr_block: '{{ vpc_cidr }}' | ||
tags: | ||
TestPrefix: '{{ resource_prefix }}' | ||
register: vpc_result | ||
|
||
- name: create subnets | ||
ec2_vpc_subnet: | ||
state: present | ||
cidr: '{{ item.cidr }}' | ||
az: '{{ item.zone }}' | ||
vpc_id: '{{ vpc_result.vpc.id }}' | ||
tags: | ||
Name: '{{ item.name }}' | ||
TestPrefix: '{{ resource_prefix }}' | ||
register: vpc_subnet_create | ||
loop: | ||
- name: '{{ subnet_name_a }}' | ||
cidr: '{{ subnet_cidr_a }}' | ||
zone: '{{ subnet_zone_a }}' | ||
- name: '{{ subnet_name_b }}' | ||
cidr: '{{ subnet_cidr_b }}' | ||
zone: '{{ subnet_zone_b }}' | ||
- name: '{{ subnet_name_c }}' | ||
cidr: '{{ subnet_cidr_c }}' | ||
zone: '{{ subnet_zone_c }}' | ||
- name: '{{ subnet_name_d }}' | ||
cidr: '{{ subnet_cidr_d }}' | ||
zone: '{{ subnet_zone_d }}' | ||
|
||
- name: Store IDs of subnets and VPC | ||
set_fact: | ||
vpc_id: '{{ vpc_result.vpc.id }}' | ||
subnet_id_a: '{{ vpc_subnet_create.results[0].subnet.id }}' | ||
subnet_id_b: '{{ vpc_subnet_create.results[1].subnet.id }}' | ||
subnet_id_c: '{{ vpc_subnet_create.results[2].subnet.id }}' | ||
subnet_id_d: '{{ vpc_subnet_create.results[3].subnet.id }}' | ||
# ============================================================ | ||
|
||
- name: Create Subnet Group | ||
elasticache_subnet_group: | ||
state: present | ||
name: '{{ group_name }}' | ||
description: '{{ description_default }}' | ||
subnets: | ||
- '{{ subnet_id_a }}' | ||
- '{{ subnet_id_b }}' | ||
register: create_group | ||
|
||
- name: Check result - Create Subnet Group | ||
assert: | ||
that: | ||
- create_group is successful | ||
- create_group is changed | ||
#- '"group" in create_group' | ||
#- '"name" in create_group.group' | ||
#- '"vpc_id" in create_group.group' | ||
#- create_group.group.name == group_name | ||
#- create_group.group.vpc_id == vpc_id | ||
|
||
- name: Create Subnet Group - idempotency | ||
elasticache_subnet_group: | ||
state: present | ||
name: '{{ group_name }}' | ||
description: '{{ description_default }}' | ||
subnets: | ||
- '{{ subnet_id_a }}' | ||
- '{{ subnet_id_b }}' | ||
register: create_group | ||
|
||
- name: Check result - Create Subnet Group - idempotency | ||
assert: | ||
that: | ||
- create_group is successful | ||
- create_group is not changed | ||
#- '"group" in create_group' | ||
#- '"name" in create_group.group' | ||
#- '"vpc_id" in create_group.group' | ||
#- create_group.group.name == group_name | ||
#- create_group.group.vpc_id == vpc_id | ||
|
||
# ============================================================ | ||
|
||
- name: Update Subnet Group Description | ||
elasticache_subnet_group: | ||
state: present | ||
name: '{{ group_name }}' | ||
description: '{{ description_updated }}' | ||
subnets: | ||
- '{{ subnet_id_a }}' | ||
- '{{ subnet_id_b }}' | ||
register: update_description | ||
|
||
- name: Check result - Update Subnet Group Description | ||
assert: | ||
that: | ||
- update_description is successful | ||
- update_description is changed | ||
#- '"group" in update_description' | ||
#- '"name" in update_description.group' | ||
#- '"vpc_id" in update_description.group' | ||
#- update_description.group.name == group_name | ||
#- update_description.group.vpc_id == vpc_id | ||
|
||
- name: Update Subnet Group Description - idempotency | ||
elasticache_subnet_group: | ||
state: present | ||
name: '{{ group_name }}' | ||
description: '{{ description_updated }}' | ||
subnets: | ||
- '{{ subnet_id_a }}' | ||
- '{{ subnet_id_b }}' | ||
register: update_description | ||
|
||
- name: Check result - Update Subnet Group Description - idempotency | ||
assert: | ||
that: | ||
- update_description is successful | ||
- update_description is not changed | ||
#- '"group" in update_description' | ||
#- '"name" in update_description.group' | ||
#- '"vpc_id" in update_description.group' | ||
#- update_description.group.name == group_name | ||
#- update_description.group.vpc_id == vpc_id | ||
|
||
# ============================================================ | ||
|
||
- name: Update Subnet Group subnets | ||
elasticache_subnet_group: | ||
state: present | ||
name: '{{ group_name }}' | ||
description: '{{ description_updated }}' | ||
subnets: | ||
- '{{ subnet_id_c }}' | ||
- '{{ subnet_id_d }}' | ||
register: update_subnets | ||
|
||
- name: Check result - Update Subnet Group subnets | ||
assert: | ||
that: | ||
- update_subnets is successful | ||
- update_subnets is changed | ||
#- '"group" in update_subnets' | ||
#- '"name" in update_subnets.group' | ||
#- '"vpc_id" in update_subnets.group' | ||
#- update_subnets.group.name == group_name | ||
#- update_subnets.group.vpc_id == vpc_id | ||
|
||
- name: Update Subnet Group subnets - idempotency | ||
elasticache_subnet_group: | ||
state: present | ||
name: '{{ group_name }}' | ||
description: '{{ description_updated }}' | ||
subnets: | ||
- '{{ subnet_id_c }}' | ||
- '{{ subnet_id_d }}' | ||
register: update_subnets | ||
|
||
- name: Check result - Update Subnet Group subnets - idempotency | ||
assert: | ||
that: | ||
- update_subnets is successful | ||
- update_subnets is not changed | ||
#- '"group" in update_subnets' | ||
#- '"name" in update_subnets.group' | ||
#- '"vpc_id" in update_subnets.group' | ||
#- update_subnets.group.name == group_name | ||
#- update_subnets.group.vpc_id == vpc_id | ||
|
||
# ============================================================ | ||
|
||
- name: Delete Subnet Group | ||
elasticache_subnet_group: | ||
state: absent | ||
name: '{{ group_name }}' | ||
register: delete_group | ||
|
||
- name: Check result - Delete Subnet Group | ||
assert: | ||
that: | ||
- delete_group is changed | ||
|
||
- name: Delete Subnet Group - idempotency | ||
elasticache_subnet_group: | ||
state: absent | ||
name: '{{ group_name }}' | ||
register: delete_group | ||
|
||
- name: Check result - Delete Subnet Group - idempotency | ||
assert: | ||
that: | ||
- delete_group is not changed | ||
|
||
always: | ||
|
||
################################################ | ||
# TEARDOWN STARTS HERE | ||
################################################ | ||
|
||
- name: Delete Subnet Group | ||
elasticache_subnet_group: | ||
state: absent | ||
name: '{{ group_name }}' | ||
ignore_errors: True | ||
|
||
- name: tidy up subnet | ||
ec2_vpc_subnet: | ||
state: absent | ||
cidr: '{{ item }}' | ||
vpc_id: '{{ vpc_result.vpc.id }}' | ||
loop: | ||
- '{{ subnet_cidr_a }}' | ||
- '{{ subnet_cidr_b }}' | ||
- '{{ subnet_cidr_c }}' | ||
- '{{ subnet_cidr_d }}' | ||
ignore_errors: True | ||
|
||
- name: tidy up VPC | ||
ec2_vpc_net: | ||
state: absent | ||
name: '{{ vpc_name }}' | ||
cidr_block: '{{ vpc_cidr }}' | ||
ignore_errors: True |