001451bf93
When logs were under a directory without read permissions, bifrost was not able to create the vm log files for centos/suse and were not published. Change-Id: Ifcc31c611edd34acb4fc3c1bb67bbe2a528d93cc
128 lines
3.9 KiB
YAML
128 lines
3.9 KiB
YAML
# Copyright (c) 2017 Mirantis Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Setup libvirt - ensure network and storage pool are defined and active,
|
|
# prepare dir for vm logs
|
|
---
|
|
- 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
|
|
|
|
- name: ensure libvirt network is present
|
|
virt_net:
|
|
name: "{{ test_vm_network }}"
|
|
state: present
|
|
xml: "{{ lookup('template', 'net.xml.j2') }}"
|
|
uri: "{{ test_vm_libvirt_uri }}"
|
|
|
|
- name: find facts on libvirt networks
|
|
virt_net:
|
|
command: facts
|
|
uri: "{{ test_vm_libvirt_uri }}"
|
|
|
|
# NOTE(pas-ha) yet another place where non-local libvirt will not work
|
|
- name: "Delete network interface if virtual network is not active"
|
|
command: ip link del {{ ansible_libvirt_networks[test_vm_network].bridge }}
|
|
when:
|
|
- ansible_libvirt_networks[test_vm_network].state != 'active'
|
|
- test_vm_libvirt_uri == 'qemu:///system'
|
|
ignore_errors: yes
|
|
|
|
- name: set libvirt network to autostart
|
|
virt_net:
|
|
name: "{{ test_vm_network }}"
|
|
autostart: yes
|
|
uri: "{{ test_vm_libvirt_uri }}"
|
|
|
|
- name: ensure libvirt network is running
|
|
virt_net:
|
|
name: "{{ test_vm_network }}"
|
|
state: active
|
|
uri: "{{ test_vm_libvirt_uri }}"
|
|
|
|
- name: get libvirt network status
|
|
virt_net:
|
|
name: "{{ test_vm_network }}"
|
|
command: status
|
|
uri: "{{ test_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: "{{ test_vm_storage_pool }}"
|
|
state: present
|
|
uri: "{{ test_vm_libvirt_uri }}"
|
|
xml: "{{ lookup('template', 'pool_dir.xml.j2') }}"
|
|
|
|
- name: ensure libvirt pool is running
|
|
virt_pool:
|
|
name: "{{ test_vm_storage_pool }}"
|
|
state: active
|
|
autostart: yes
|
|
uri: "{{ test_vm_libvirt_uri }}"
|
|
|
|
- name: create dir for bm logs
|
|
file:
|
|
state: directory
|
|
path: "{{ test_vm_logdir }}"
|
|
|
|
- name: Add read/execute perms for the whole directory path
|
|
shell: f="{{ test_vm_logdir }}" ; while [[ $f != "/" ]]; do chmod 0755 $f; f=$(dirname $f); done;
|
|
|
|
- name: install virtualbmc
|
|
pip:
|
|
name: virtualbmc
|