--- - name: "Restart libvirt service" service: name="{{libvirt_service_name}}" state=restarted # NOTE(Shrews) We need to enable ip forwarding for the libvirt bridge to # operate properly with dnsmasq. This should be done before starting dnsmasq. - name: "Enable IP forwarding in sysctl" sysctl: name: "net.ipv4.ip_forward" value: 1 sysctl_set: yes state: present reload: yes # NOTE(Shrews) Ubuntu packaging+apparmor issue prevents libvirt from loading # the ROM from /usr/share/misc. - name: "Look for sgabios in {{ sgabios_dir }}" stat: path={{ sgabios_dir }}/sgabios.bin register: test_sgabios_qemu - name: "Look for sgabios in /usr/share/misc" stat: path=/usr/share/misc/sgabios.bin register: test_sgabios_misc - name: "Place sgabios.bin" command: cp /usr/share/misc/sgabios.bin /usr/share/qemu/sgabios.bin when: > test_sgabios_qemu == false and test_sgabios_misc == true # NOTE(TheJulia): In order to prevent conflicts, stop # dnsmasq to prevent conflicts with libvirt restarting. # TODO(TheJulia): We shouldn't need to do this, but the # libvirt dhcp instance conflicts withour specific config # and taking this path allows us to not refactor dhcp at # this moment. Our DHCP serving should be refactored # so we don't need to do this. - name: "Stop default dnsmasq service" service: name: dnsmasq state: stopped ignore_errors: true # NOTE(TheJulia): Seems if you test in a VM, this might # be helpful if your installed your host originally # with the default 192.168.122/0/24 network - name: destroy libvirt network virt_net: name: "{{ item }}" state: absent uri: "{{ vm_libvirt_uri }}" # Ubuntu creates a default network when installing libvirt. # This network uses the 192.168.122.0/24 range and thus # conflicts with our admin network - name: destroy libvirt network virt_net: name: "default" state: absent uri: "{{ vm_libvirt_uri }}" - name: ensure libvirt network is present virt_net: name: "{{ item }}" state: present xml: "{{ lookup('template', 'net-'+item+'.xml.j2') }}" uri: "{{ vm_libvirt_uri }}" - name: find facts on libvirt networks virt_net: command: facts uri: "{{ vm_libvirt_uri }}" - name: "Delete network interface if virtual network is not active" command: ip link del {{ ansible_libvirt_networks[item].bridge }} when: - ansible_libvirt_networks[item].state != 'active' - vm_libvirt_uri == 'qemu:///system' ignore_errors: yes - name: set libvirt network to autostart virt_net: name: "{{ item }}" autostart: yes uri: "{{ vm_libvirt_uri }}" - name: ensure libvirt network is running virt_net: name: "{{ item }}" state: active uri: "{{ vm_libvirt_uri }}" - name: get libvirt network status virt_net: name: "{{ item }}" command: status uri: "{{ vm_libvirt_uri }}" register: test_vm_net_status - name: fail if libvirt network is not active assert: that: test_vm_net_status.status == 'active' - name: define a libvirt pool if not set virt_pool: name: "{{ node_storage_pool }}" state: present uri: "{{ vm_libvirt_uri }}" xml: "{{ lookup('template', 'pool_dir.xml.j2') }}" - name: ensure libvirt pool is running virt_pool: name: "{{ node_storage_pool }}" state: active autostart: yes uri: "{{ vm_libvirt_uri }}" - name: create dir for bm logs file: state: directory path: "{{ node_logdir }}" recurse: yes mode: "0755" - name: install virtualbmc pip: name: virtualbmc version: 1.3 # >1.3 needs zmq dependency. virtualenv: "{{ lookup('env', 'XCI_VENV') }}"