2019-10-21 14:55:44 +02:00
|
|
|
- name: remove Instances
|
2019-05-10 20:43:15 +02:00
|
|
|
ec2_instance:
|
|
|
|
state: absent
|
2019-10-21 14:55:44 +02:00
|
|
|
filters:
|
|
|
|
vpc-id: "{{ testing_vpc.vpc.id }}"
|
|
|
|
wait: yes
|
2019-05-10 20:43:15 +02:00
|
|
|
ignore_errors: yes
|
|
|
|
retries: 10
|
|
|
|
|
|
|
|
- name: remove ENIs
|
|
|
|
ec2_eni_info:
|
|
|
|
filters:
|
|
|
|
vpc-id: "{{ testing_vpc.vpc.id }}"
|
|
|
|
register: enis
|
|
|
|
|
|
|
|
- name: delete all ENIs
|
|
|
|
ec2_eni:
|
|
|
|
eni_id: "{{ item.id }}"
|
|
|
|
state: absent
|
|
|
|
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
|
|
|
|
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 }}"
|
|
|
|
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
|
|
|
|
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 }}"
|
2019-10-21 14:55:44 +02:00
|
|
|
cidr: "{{ subnet_a_cidr }}"
|
2019-05-10 20:43:15 +02:00
|
|
|
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 }}"
|
2019-10-21 14:55:44 +02:00
|
|
|
cidr: "{{ subnet_b_cidr }}"
|
2019-05-10 20:43:15 +02:00
|
|
|
register: removed
|
|
|
|
until: removed is not failed
|
|
|
|
ignore_errors: yes
|
|
|
|
retries: 10
|
|
|
|
|
|
|
|
- name: remove the VPC
|
|
|
|
ec2_vpc_net:
|
2019-10-21 14:55:44 +02:00
|
|
|
name: "{{ vpc_name }}"
|
|
|
|
cidr_block: "{{ vpc_cidr }}"
|
2019-05-10 20:43:15 +02:00
|
|
|
state: absent
|
|
|
|
tags:
|
|
|
|
Name: Ansible Testing VPC
|
|
|
|
tenancy: default
|
|
|
|
register: removed
|
|
|
|
until: removed is not failed
|
|
|
|
ignore_errors: yes
|
|
|
|
retries: 10
|