65 lines
1.9 KiB
YAML
65 lines
1.9 KiB
YAML
# Tear down the virtual environment that was created by the
|
|
# `environment/setup` role.
|
|
#
|
|
# NB: We use `virsh` here instead of the `virt_net` module because
|
|
# these tasks may be called before the dependencies of the `virt_net`
|
|
# module are satisfied.
|
|
|
|
- name: Check if libvirt is available
|
|
command: >
|
|
virsh uri
|
|
ignore_errors: true
|
|
register: libvirt_check
|
|
changed_when: false
|
|
|
|
# If libvirt is not available, we can skip the rest of the tasks.
|
|
- when: libvirt_check is success
|
|
block:
|
|
|
|
# Check to see if the networks exist.
|
|
- name: Check libvirt networks
|
|
command: >
|
|
virsh net-uuid "{{ item.name }}"
|
|
with_items: "{{ networks }}"
|
|
register: network_check
|
|
ignore_errors: true
|
|
become: true
|
|
|
|
# If the networks exist, stop them, undefine them, and remove the
|
|
# bridges devices from the qemu whitelist.
|
|
- name: Stop libvirt networks
|
|
command: >
|
|
virsh net-destroy "{{ item.item.name }}"
|
|
when: libvirt_check is success and item is success
|
|
with_items: "{{ network_check.results }}"
|
|
ignore_errors: true
|
|
become: true
|
|
|
|
- name: Undefine libvirt networks
|
|
command: >
|
|
virsh net-undefine "{{ item.item.name }}"
|
|
when: libvirt_check is success and item is success
|
|
with_items: "{{ network_check.results }}"
|
|
ignore_errors: true
|
|
become: true
|
|
|
|
- name: Remove bridge whitelisting from qemu bridge helper
|
|
lineinfile:
|
|
dest: "{{ qemu_bridge_conf }}"
|
|
line: "allow {{item.bridge}}"
|
|
state: absent
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
|
|
- name: Delete any existing dstat log file
|
|
file: dest=/var/log/extra/dstat-csv.log state=absent
|
|
become: true
|
|
|
|
- name: Delete OVS Bridges
|
|
openvswitch_bridge:
|
|
bridge: "{{ item.bridge }}"
|
|
state: absent
|
|
when: item.virtualport_type is defined and item.virtualport_type == "openvswitch"
|
|
with_items: "{{ networks }}"
|
|
become: true
|