mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
AWS: add ec2_transit_gateway_info module (#54460)
* AWS: add ec2_transit_gateway_info module * move info module test to main module and ensure unique description for parallel tests * add type designators to module options in documentation * assign results and return instead of exit. Add elements directive available with ansible 2.8 * assign results and return instead of exit * get() method superfluous for module.params * correct return type in documentation for ASN and format the sample for Tag correctly * added random uid to test description - removing unstable alias * change random uuid to resource_prefix to improve source of object identification in testing
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
cloud/aws
|
||||
shippable/aws/group2
|
||||
unstable # sometimes tries to delete while in state pending
|
||||
ec2_transit_gateway_info
|
||||
|
||||
@@ -10,10 +10,14 @@
|
||||
region: "{{ aws_region }}"
|
||||
no_log: yes
|
||||
|
||||
- name: generate unique value for testing
|
||||
set_fact:
|
||||
tgw_description: "{{ resource_prefix }}-tgw"
|
||||
|
||||
- block:
|
||||
- name: test create transit gateway without permissions
|
||||
ec2_transit_gateway:
|
||||
description: integration-testing
|
||||
description: "{{ tgw_description }}"
|
||||
region: "{{ aws_region }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
@@ -26,11 +30,11 @@
|
||||
|
||||
- name: test create transit gateway without region
|
||||
ec2_transit_gateway:
|
||||
description: integration-testing
|
||||
description: "{{ tgw_description }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert failure when called with with minimal parameters but no region
|
||||
- name: assert failure when called with minimal parameters but no region
|
||||
assert:
|
||||
that:
|
||||
- 'result.failed'
|
||||
@@ -38,7 +42,7 @@
|
||||
|
||||
- name: test create transit gateway without tags
|
||||
ec2_transit_gateway:
|
||||
description: integration-testing
|
||||
description: "{{ tgw_description }}"
|
||||
<<: *aws_connection_info
|
||||
register: create_result
|
||||
- name: assert changed is True
|
||||
@@ -48,7 +52,7 @@
|
||||
|
||||
- name: test update transit gateway with tags by description
|
||||
ec2_transit_gateway:
|
||||
description: integration-testing
|
||||
description: "{{ tgw_description }}"
|
||||
tags:
|
||||
Name: Ansible Test TGW
|
||||
<<: *aws_connection_info
|
||||
@@ -92,7 +96,7 @@
|
||||
|
||||
- name: test idempotence
|
||||
ec2_transit_gateway:
|
||||
description: integration-testing
|
||||
description: "{{ tgw_description }}"
|
||||
purge_tags: True
|
||||
tags:
|
||||
status: ok to delete
|
||||
@@ -103,11 +107,69 @@
|
||||
that:
|
||||
- result.changed == False
|
||||
|
||||
# ==== Combine ec2_transit_gateway_info ======================
|
||||
- name: test success with no parameters
|
||||
ec2_transit_gateway_info:
|
||||
<<: *aws_connection_info
|
||||
register: result
|
||||
- name: assert success with no parameters
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.transit_gateways != []'
|
||||
|
||||
- name: test success with single filter
|
||||
ec2_transit_gateway_info:
|
||||
filters:
|
||||
transit-gateway-id: "{{ create_result.transit_gateway.transit_gateway_id }}"
|
||||
<<: *aws_connection_info
|
||||
register: result
|
||||
- name: assert success with transit_gateway_id filter
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.transit_gateways != []'
|
||||
|
||||
- name: test empty result set for non-existent tgw id via filter
|
||||
ec2_transit_gateway_info:
|
||||
filters:
|
||||
transit-gateway-id: tgw-00000011111111122
|
||||
<<: *aws_connection_info
|
||||
register: result
|
||||
- name: assert success with transit_gateway_id filter
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.transit_gateways == []'
|
||||
|
||||
- name: test NotFound exception caught and returned empty result set
|
||||
ec2_transit_gateway_info:
|
||||
transit_gateway_id: tgw-00000011111111122
|
||||
<<: *aws_connection_info
|
||||
register: result
|
||||
- name: assert success with transit_gateway_id filter
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.transit_gateways == []'
|
||||
|
||||
- name: test success with multiple filters
|
||||
ec2_transit_gateway_info:
|
||||
filters:
|
||||
options.dns-support: enable
|
||||
options.vpn-ecmp-support: enable
|
||||
<<: *aws_connection_info
|
||||
register: result
|
||||
- name: assert success with transit_gateway_id filter
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.transit_gateways != []'
|
||||
always:
|
||||
###### TEARDOWN STARTS HERE ######
|
||||
- name: delete transit gateway
|
||||
ec2_transit_gateway:
|
||||
description: integration-testing
|
||||
description: "{{ tgw_description }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
ignore_errors: yes
|
||||
|
||||
Reference in New Issue
Block a user