diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf7d29b..8ef58066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ IMPROVEMENTS: +- Add destroy.yml for examples/alicloud_ecs_vpc ([#117](https://github.com/alibaba/ansible-provider/pull/117)) - Improve roles test cases ([#116](https://github.com/alibaba/ansible-provider/pull/116)) - Improve example/alicloud-ecs-vpc ([#114](https://github.com/alibaba/ansible-provider/pull/114), [#115](https://github.com/alibaba/ansible-provider/pull/115)) - Change nested_groups default to False ([#113](https://github.com/alibaba/ansible-provider/pull/113git )) diff --git a/examples/alicloud-ecs-vpc/destroy.yml b/examples/alicloud-ecs-vpc/destroy.yml new file mode 100644 index 00000000..bd19f151 --- /dev/null +++ b/examples/alicloud-ecs-vpc/destroy.yml @@ -0,0 +1,93 @@ +--- +- name: Create an alicloud vpc cluster using ansible-provider-alicloud + hosts: localhost + remote_user: root + + tasks: + - name: Get the existing instances + ali_instance_facts: + alicloud_region: '{{ alicloud_region }}' + alicloud_zone: '{{ alicloud_zone }}' + instance_names: + - '{{ instance_name }}' + register: instances + + - name: Delete the existing instances + ali_instance: + alicloud_region: '{{ alicloud_region }}' + alicloud_zone: '{{ alicloud_zone }}' + instance_ids: + - '{{ instances.instances.0.id }}' + - '{{ instances.instances.1.id }}' + force: true + state: absent + when: instances.instances + + - name: Get the existing disks + ali_disk_facts: + alicloud_region: '{{ alicloud_region }}' + alicloud_zone: '{{ alicloud_zone }}' + disk_names: + - '{{ disk_name }}-0' + - '{{ disk_name }}-1' + register: disks + + - name: Delete the existing disk 0 + ali_disk: + alicloud_region: '{{ alicloud_region }}' + alicloud_zone: '{{ alicloud_zone }}' + disk_id: '{{ disks.disks.0.id }}' + state: absent + when: disks.disks + + - name: Delete the existing disk 1 + ali_disk: + alicloud_region: '{{ alicloud_region }}' + alicloud_zone: '{{ alicloud_zone }}' + disk_id: '{{ disks.disks.1.id}}' + state: absent + when: disks.disks + + - name: Get the existing vpc + ali_vpc_facts: + region: '{{alicloud_region}}' + vpc_name: '{{vpc_name}}' + register: vpcs + + - name: Get the existing groups + ali_security_group_facts: + region: '{{alicloud_region}}' + filters: + vpc_id: '{{vpcs.vpcs.0.id}}' + when: vpcs.vpcs + register: sgs + + - name: Delete the existing security groups + ali_security_group: + alicloud_region: '{{ alicloud_region }}' + group_id: '{{ sgs.groups.0.id}}' + state: absent + when: sgs.groups + + - name: Get the existing vswitches + ali_vswitch_facts: + region: '{{alicloud_region}}' + filters: + vpc_id: '{{vpcs.vpcs.0.id}}' + when: vpcs.vpcs + register: vsws + + - name: Delete the existing vswitch + ali_vswitch: + alicloud_region: '{{ alicloud_region }}' + alicloud_zone: '{{ alicloud_zone }}' + vswitch_id: '{{ vsws.vswitches.0.id }}' + state: absent + when: vsws.vswitches + + - name: Delete the existing vpc + ali_vpc: + alicloud_region: '{{ alicloud_region }}' + vpc_id: '{{ vpcs.vpcs.0.id}}' + state: absent + when: vpcs.vpcs \ No newline at end of file