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

On Mon, 5 Aug 2019 at 13:09, Sebastian Meyer <[email protected]> wrote:

> Hi Rahul,
>
> everything is connected to the instance, no? You can't deprovision sec
> groups, network stuff or key_pairs while they are in use.
>
> You'll have to remove the instance first.
>
> Regards
> Sebastian
>
> On 05.08.19 09:19, Rahul Kumar wrote:
> > Hi All,
> > I have provisoned one instance with following order in openstack using
> > Ansible:
> > 1. Download cloud image
> > 2. upload cloud image in Openstack
> > 3. created key pair
> > 4. created network
> > 5. created subnet
> > 6. created router
> > 7. created security group
> > 8. created SG rule
> > 9. created instance
> >
> > and it went successfully. Now i want to remove the resources what order i
> > should follow:
> > I tried 1 task and it is success
> > 1. delete SG rule
> >
> > after that i am getting stuck because anything i try to delete , it has
> > association with some other resource.
> >
> > Help me
> >
>
> --
> Sebastian Meyer
> Linux Consultant & Trainer
> Mail: [email protected]
>
> B1 Systems GmbH
> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
>
>
> -- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis ----
> ------------------------ https://openstack-tage.de (Code DOST-B1) ----
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3c5f570b-09ee-0344-0b26-d9bd0d588bc3%40b1-systems.de
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGH8rEys2%2B0xc4w3knDQMp2Kg_-FCJToUUd0pMo3St_raBEpfw%40mail.gmail.com.

Reply via email to