Thanks much Sebastien, Good inputs. I tried same playbook by making state = absent and got error as expected as below: fatal: [localhost]: FAILED! => {"changed": false, "msg": "ConflictException: 409: Client Error for url: https://<IP>:<Port>/v2.0/networks/c4e67037-e32d-4e06-b0ba-7c07f6e1ec63.json, Unable to complete operation on network c4e67037-e32d-4e06-b0ba-7c07f6e1ec63. There are one or more ports still in use on the network."}
So again some questions: 1. Do we need to write different playbook for deleting resources or either flip the order in the playbook as needed and make state=absent? 2. I tried this just to create 1 nova instnace . Assume we have multiple resources and we need to make sure right resource is attached to particular one. For example: Assume 2 resources: - name: Create Networks os_network: name: "{{ item.name }}" state: present external: false wait: yes with_items: "{{ networks }}" os_server: name: "{{ prefix }}-{{ item.name }}" state: present key_name: "{{ item.key }}" availability_zone: "{{ item.availability_zone }}" nics: "{{ item.nics }}" image: "{{ item.image }}" flavor: "{{ item.flavor }}" with_items: "{{ servers }}" register: "os_hosts" Assume network is need to provision instance . Now say we have multiple instances and multiple networks .Which we can define using networks and servers variables as shown in above snippet. How do i ensure that one particular network is assigned to particular instance? do we need to manage this at variables side defination only or is there any better way to handle same in playbook code? Its just scaling use case when we have multiple resources and we want that expected resource is attached to right one. On Thu, 1 Aug 2019 at 16:06, Sebastian Meyer <me...@b1-systems.de> wrote: > Hi Rahul, > > On 01.08.19 12:19, Rahul Kumar wrote: > > 1. whatever resources(net,subnet,sg,router etc) are provisioned as part > of > > this single instance creation , lets say i want to clear all those > > resources in one shot , how can i do this ? > > Each module (os_server, os_network ...) should only create the specified > resource. For deprovisioning set the state to absent. One exception > would be e.g. a floating IP automatically assigned to the instance. That > IP isn't assigned anymore afterwards, but still created. > > > 2. Does order of tasks matter in playbook. For example: To create > instance > > , we need network , so first we will provision network and then other > > dependent resources. > > Order matters, yes. Playbooks are run from top down, so the first task > in the list is executed first. Beware that you need a different order > for creation and destruction, afaik you cant remove a network, if theres > still an instance on it. > > -- > Sebastian Meyer > Linux Consultant & Trainer > Mail: me...@b1-systems.de > > 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 ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/15c36db1-d2bb-536a-3416-5c62b209b96d%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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGH8rEyuAfc06%2ByxEGpDZpSQKzsz%2BBor7UoV6e2vQCCj2%3DxHsw%40mail.gmail.com.