1 # Copyright (c) 2017-2018 Intel Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 - name: Destroy old networks created by virt
17 name: "{{ network_item }}"
19 when: clean_up | bool or network_item in deploy_nets
21 # Ignoring errors as network can be created without being defined.
22 # This can happen if a user manually creates a network using the virsh command.
23 # If the network is not defined the undefine code will throw an error.
24 - name: Undefine old networks defined by virt
26 name: "{{ network_item }}"
28 when: clean_up | bool or network_item in deploy_nets
31 - name: Check if "ovs-vsctl" command is present
32 command: which ovs-vsctl
33 register: ovs_vsctl_present
36 - name: Destroy OVS bridge if it exists
37 command: ovs-vsctl --if-exists -- del-br "{{ network_item }}"
39 - ovs_vsctl_present.rc == 0
40 - clean_up | bool or network_item in deploy_nets
43 - name: Check if linux bridge is present
44 stat: path="{{ '/sys/class/net/' + network_item + '/brif/' }}"
45 register: check_linux_bridge
47 - name: Remove linux bridge if it exists
49 ifconfig "{{ network_item }}" down
50 brctl delbr "{{ network_item }}"
52 - check_linux_bridge.stat.exists
53 - clean_up | bool or network_item in deploy_nets