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.