ansible/test/integration/targets/ec2_transit_gateway/tasks/main.yml

114 lines
3.4 KiB
YAML
Raw Normal View History

---
# tasks file for test_ec2_transit_gateway
- 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
- block:
- name: test create transit gateway without permissions
ec2_transit_gateway:
description: integration-testing
region: "{{ aws_region }}"
register: result
ignore_errors: yes
- name: assert nice message returned
assert:
that:
- result is failed
- "result.msg != 'MODULE FAILURE'"
- name: test create transit gateway without region
ec2_transit_gateway:
description: integration-testing
register: result
ignore_errors: yes
- name: assert failure when called with with minimal parameters but no region
assert:
that:
- 'result.failed'
- 'result.msg.startswith("The ec2_transit_gateway module requires a region")'
- name: test create transit gateway without tags
ec2_transit_gateway:
description: integration-testing
<<: *aws_connection_info
register: create_result
- name: assert changed is True
assert:
that:
- create_result.changed == True
- name: test update transit gateway with tags by description
ec2_transit_gateway:
description: integration-testing
tags:
Name: Ansible Test TGW
<<: *aws_connection_info
register: result
- name: assert changed is True
assert:
that:
- result.changed == True
- result.transit_gateway.tags | length == 1
- "'Name' in result.transit_gateway.tags"
- name: test update transit gateway with new tag and purge_tags false
ec2_transit_gateway:
transit_gateway_id: '{{ create_result.transit_gateway.transit_gateway_id }}'
purge_tags: False
tags:
status: ok to delete
<<: *aws_connection_info
register: result
- name: assert changed is True and have 2 tags
assert:
that:
- result.changed == True
- result.transit_gateway.tags | length == 2
- "'Name' in result.transit_gateway.tags"
- name: test update transit gateway with purge_tags true
ec2_transit_gateway:
transit_gateway_id: '{{ create_result.transit_gateway.transit_gateway_id }}'
purge_tags: True
tags:
status: ok to delete
<<: *aws_connection_info
register: result
- name: assert changed is True and TGW tag is absent
assert:
that:
- result.changed == True
- result.transit_gateway.tags | length == 1
- "'Name' not in result.transit_gateway.tags"
- name: test idempotence
ec2_transit_gateway:
description: integration-testing
purge_tags: True
tags:
status: ok to delete
<<: *aws_connection_info
register: result
- name: assert changed is False
assert:
that:
- result.changed == False
always:
###### TEARDOWN STARTS HERE ######
- name: delete transit gateway
ec2_transit_gateway:
description: integration-testing
state: absent
<<: *aws_connection_info
ignore_errors: yes