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
This commit is contained in:
Jesse Pretorius 2018-09-06 13:02:49 +01:00
parent 7a9f3ef7f4
commit f437430212

View File

@ -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: >