Thanks Sebastien . I removed instance. but rest of all resources , i am not able to predict order, below is my playbook:
---
- name: Create a test environment
hosts: localhost
vars:
cert_auth:
ca_cert: /root/cabs12.crt
tasks:
- name: Remove security group rule for ping
os_security_group_rule:
cloud: mycloud
ca_cert: "{{ cert_auth.ca_cert }}"
security_group: test-security-group
protocol: icmp
state: absent
remote_ip_prefix:
0.0.0.0/0 - name: Remove security group rule for SSH
os_security_group_rule:
cloud: mycloud
ca_cert: "{{ cert_auth.ca_cert }}"
security_group: test-security-group
protocol: tcp
state: absent
port_range_min: 22
port_range_max: 22
remote_ip_prefix:
0.0.0.0/0 - name: Remove instance
os_server:
state: absent
ca_cert: "{{ cert_auth.ca_cert }}"
cloud: mycloud
name: test-instance
image: myimage
key_name: dump_key
timeout: 200
flavor: v8.m4
network: test-network
auto_ip: yes
security_groups:
- test-security-group
register:
my_instance
- name: Remove subnet
os_subnet:
cloud: mycloud
state: absent
ca_cert: "{{ cert_auth.ca_cert }}"
network_name: test-network
name: test-subnet
- name: Remove security group
os_security_group:
cloud: mycloud
state: absent
ca_cert: "{{ cert_auth.ca_cert }}"
name: test-security-group
description: Security group for our test instances
- name: Remove a router
os_router:
cloud: mycloud
state: absent
ca_cert: "{{ cert_auth.ca_cert }}"
name: test-router
network: ext-net
interfaces:
- test-subnet
- name: Remove network
os_network:
cloud: mycloud
state: absent
ca_cert: "{{ cert_auth.ca_cert }}"
name: test-network
external: false
wait: yes
- name: Remove new keypair from current user's default SSH key
os_keypair:
state: absent
ca_cert: "{{ cert_auth.ca_cert }}"
name: dump_key
public_key_file: "{{ '~' | expanduser }}/.ssh/id_rsa.pub"
- name: Remove Cloud Image from Openstack
os_image:
name: myimage
container_format: bare
cloud: mycloud
ca_cert: "{{ cert_auth.ca_cert }}"
disk_format: qcow2
state: absent
is_public: no
filename: /root/tas/cirros-0.3.4-x86_64-disk.img
- name: Remove security group
os_security_group:
cloud: mycloud
state: absent
ca_cert: "{{ cert_auth.ca_cert }}"
name: test-security-group
description: Security group for our test instances