From f4374302129da83376514bd134ac3223e4ae38c5 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 6 Sep 2018 13:02:49 +0100 Subject: [PATCH] MNAIO: Ensure that virt-networks are properly setup Due to the rather terrible virt_net module, only one action can be done on the virt networks at any one time. This means that the current action of setting them to autostart has no effect, because the module does not do it. Also, the current action of disabling the default network and disabling it from autostarting also does not take full effect. As such, after a host reboot, the default network autostarts, and the other networks are not started and the VM's cannot start. When trying to resolve this by re-running the host setup, the play ignores any existing virt networks - so the issue cannot be fixed. This patch does the following: 1. Ensures that the default network does not autostart. This is done by splitting the disabling of the network, and the disabling of autostart into two tasks. 2. Changes the define/create action into a single action which will not change the network configuration if it is defined. 3. Implements the setting of the network as active, and the setting of it to autostart as two seperate tasks. This ensures that both actions are actually implemented. Change-Id: I608f2607824fac649f4e018d89094d57047134b3 --- multi-node-aio/playbooks/setup-host.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/multi-node-aio/playbooks/setup-host.yml b/multi-node-aio/playbooks/setup-host.yml index 487e79a7..5db7a8d5 100644 --- a/multi-node-aio/playbooks/setup-host.yml +++ b/multi-node-aio/playbooks/setup-host.yml @@ -237,28 +237,30 @@ virt_net: name: "default" state: inactive - autostart: no - - name: List virt network(s) + - name: Prevent default virt network autostart virt_net: - command: list_nets - register: vm_networks + name: "default" + autostart: no - name: Define virt network(s) virt_net: - command: define name: "{{ item.value.iface }}" + state: present xml: "{{ lookup('template', 'kvm/libvirt-network-template.xml.j2') }}" with_dict: "{{ mnaio_host_networks }}" - when: "item.value.iface not in vm_networks.list_nets" - - name: Create virt network(s) + - name: Set virt network(s) to active virt_net: - command: create name: "{{ item.value.iface }}" - autostart: true + state: active + with_dict: "{{ mnaio_host_networks }}" + + - name: Set virt network(s) to autostart + virt_net: + name: "{{ item.value.iface }}" + autostart: yes with_dict: "{{ mnaio_host_networks }}" - when: "item.value.iface not in vm_networks.list_nets" - name: Locate the largest writable data disk if mnaio_data_disk is not set shell: >