da1a621bd9
Also moved environment setup and environment cleanup to separate task files Added CI group Updated c4.large instances to t3.nano, use ENA enabled AMI Updated AMIs with Amazon Linux AMI Updated us-east-1 AMI id Specify EBS size typo, volume_size Removed 'state: running', updated AMI with amz ami Also added several wait: false to speed things up Check for instance state, correctly Accept pending as valid state tags_and_vpc_settings do not wait for instance to complete wait for termination protected instance Updated IAM role name to match with policy Skip env cleanup when in CI Do not wait instance in external_resource_attach ENI remove is done in env_cleanup/CI wait some time for instance_profile instnace to be up Updated ebs_optimized_images Corrected task name Added aws_cleanup var in cloud-config-aws typo in runme default aws_cleanup to true
112 lines
2.6 KiB
YAML
112 lines
2.6 KiB
YAML
- 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: remove any instances in the test VPC
|
|
ec2_instance:
|
|
filters:
|
|
vpc_id: "{{ testing_vpc.vpc.id }}"
|
|
state: absent
|
|
<<: *aws_connection_info
|
|
register: removed
|
|
until: removed is not failed
|
|
ignore_errors: yes
|
|
retries: 10
|
|
|
|
- name: remove ENIs
|
|
ec2_eni_info:
|
|
filters:
|
|
vpc-id: "{{ testing_vpc.vpc.id }}"
|
|
<<: *aws_connection_info
|
|
register: enis
|
|
|
|
- name: delete all ENIs
|
|
ec2_eni:
|
|
eni_id: "{{ item.id }}"
|
|
state: absent
|
|
<<: *aws_connection_info
|
|
until: removed is not failed
|
|
with_items: "{{ enis.network_interfaces }}"
|
|
ignore_errors: yes
|
|
retries: 10
|
|
|
|
- name: remove the security group
|
|
ec2_group:
|
|
name: "{{ resource_prefix }}-sg"
|
|
description: a security group for ansible tests
|
|
vpc_id: "{{ testing_vpc.vpc.id }}"
|
|
state: absent
|
|
<<: *aws_connection_info
|
|
register: removed
|
|
until: removed is not failed
|
|
ignore_errors: yes
|
|
retries: 10
|
|
|
|
- name: remove routing rules
|
|
ec2_vpc_route_table:
|
|
state: absent
|
|
vpc_id: "{{ testing_vpc.vpc.id }}"
|
|
tags:
|
|
created: "{{ resource_prefix }}-route"
|
|
routes:
|
|
- dest: 0.0.0.0/0
|
|
gateway_id: "{{ igw.gateway_id }}"
|
|
subnets:
|
|
- "{{ testing_subnet_a.subnet.id }}"
|
|
- "{{ testing_subnet_b.subnet.id }}"
|
|
<<: *aws_connection_info
|
|
register: removed
|
|
until: removed is not failed
|
|
ignore_errors: yes
|
|
retries: 10
|
|
|
|
- name: remove internet gateway
|
|
ec2_vpc_igw:
|
|
vpc_id: "{{ testing_vpc.vpc.id }}"
|
|
state: absent
|
|
<<: *aws_connection_info
|
|
register: removed
|
|
until: removed is not failed
|
|
ignore_errors: yes
|
|
retries: 10
|
|
|
|
- name: remove subnet A
|
|
ec2_vpc_subnet:
|
|
state: absent
|
|
vpc_id: "{{ testing_vpc.vpc.id }}"
|
|
cidr: 10.22.32.0/24
|
|
<<: *aws_connection_info
|
|
register: removed
|
|
until: removed is not failed
|
|
ignore_errors: yes
|
|
retries: 10
|
|
|
|
- name: remove subnet B
|
|
ec2_vpc_subnet:
|
|
state: absent
|
|
vpc_id: "{{ testing_vpc.vpc.id }}"
|
|
cidr: 10.22.33.0/24
|
|
<<: *aws_connection_info
|
|
register: removed
|
|
until: removed is not failed
|
|
ignore_errors: yes
|
|
retries: 10
|
|
|
|
- name: remove the VPC
|
|
ec2_vpc_net:
|
|
name: "{{ resource_prefix }}-vpc"
|
|
cidr_block: 10.22.32.0/23
|
|
state: absent
|
|
tags:
|
|
Name: Ansible Testing VPC
|
|
tenancy: default
|
|
<<: *aws_connection_info
|
|
register: removed
|
|
until: removed is not failed
|
|
ignore_errors: yes
|
|
retries: 10
|