Files
vino/vino-builder/assets/playbooks/roles/libvirt/tasks/create-network.yaml
Kostiantyn Kalynovskyi 34d1398e92 Correct node count and dont fail on network plugin
Change-Id: I012b3509eafc69e6f1e16b4d7e5c9e58596b5c37
2021-06-12 17:49:40 +00:00

43 lines
1.4 KiB
YAML

# Facts will be available as 'ansible_libvirt_networks'
- name: initially gather facts on existing virsh networks
virt_net:
command: facts
name: "" # this attribute is not needed but required
uri: "{{ libvirt_uri }}"
ignore_errors: true
- name: Print value of ansible networks
debug:
msg: "Value of ansible_libvirt_networks is {{ ansible_libvirt_networks }}"
# TODO(alanmeadows): deal with updates as once its defined we will
# never re-define it
- name: add networks defined if they do not already exist
virt_net:
state: present
# looks like setting name here is a redundant, the name is anyways taken from the template xml file, but should set it to make virt_pool module happy.
name: "{{ network.name }}"
xml: "{{ libvirtNetworks[network.libvirtTemplate].libvirtTemplate }}"
uri: "{{ libvirt_uri }}"
when: "network.name not in ansible_libvirt_networks"
- name: activate the network
virt_net:
state: active
name: "{{ network.name }}"
uri: "{{ libvirt_uri }}"
# these are idempotent so require no conditional checks
- name: autostart the network
virt_net:
autostart: yes
name: "{{ network.name }}"
uri: "{{ libvirt_uri }}"
# these are idempotent so require no conditional checks
- name: plug network into physical interface
shell: |
brctl addif vm-infra-bridge "{{ network.physicalInterface }}"
when: "network.physicalInterface is defined"
ignore_errors: True