Ansible for Openstack

Hi All,
I am trying to create complete stack of Openstack as below snippet:
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”

  • name: Create Networks
    os_network:
    name: “{{ item.name }}”
    state: present
    external: false
    wait: yes
    with_items: “{{ networks }}”

I am trying to understand , how I can make dependencies of one task to another. For example in above example:
If network does not exist (with the specfified ID item.nics ), then create the one using 2nd task ? And since its mutlinetworks and multiserver mode, how we ensure that particular server is attached to particular network, does this needs to be taken care while defining those variables or anything else in playbook we can do?

Rahul