76d8716968
Ansible documentation recommends to use yes/no as boolean value, the last mention of possible using true/yes related to version 2.4 [1]. Starting from version 2.5 only become: yes specified in docs [2][3]. Since we have both variations, this patch aligns become statement to use only yes value. [1] https://docs.ansible.com/ansible/2.4/become.html [2] https://docs.ansible.com/ansible/2.5/user_guide/become.html [3] https://docs.ansible.com/ansible/latest/user_guide/become.html Change-Id: I706e6e1b9d706d6bfcc38c1a3d0d7304575946ce Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
77 lines
2.7 KiB
YAML
77 lines
2.7 KiB
YAML
# 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.
|
|
|
|
---
|
|
- name: Detect the virtualisation engine
|
|
block:
|
|
- name: Load the kvm kernel module
|
|
modprobe:
|
|
name: kvm
|
|
become: yes
|
|
failed_when: false
|
|
|
|
- name: Check for the KVM device
|
|
stat:
|
|
path: /dev/kvm
|
|
register: stat_kvm
|
|
|
|
- name: Set a fact containing the virtualisation engine
|
|
set_fact:
|
|
libvirt_vm_engine: >-
|
|
{%- if ansible_architecture != libvirt_vm_arch -%}
|
|
{# Virtualisation instructions are generally available only for the host
|
|
architecture. Ideally we would test for virtualisation instructions, eg. vt-d
|
|
as it is possible that another architecture could support these even
|
|
if the emulated cpu architecture is not the same. #}
|
|
qemu
|
|
{%- elif stat_kvm.stat.exists -%}
|
|
kvm
|
|
{%- else -%}
|
|
qemu
|
|
{%- endif -%}
|
|
when: libvirt_vm_engine is none or libvirt_vm_engine | length == 0
|
|
|
|
- name: Detect the virtualisation emulator
|
|
block:
|
|
- block:
|
|
- name: Detect the KVM emulator binary path
|
|
stat:
|
|
path: "{{ item }}"
|
|
register: kvm_emulator_result
|
|
with_items:
|
|
- /usr/bin/kvm
|
|
- /usr/bin/qemu-kvm
|
|
- /usr/libexec/qemu-kvm
|
|
|
|
- name: Set a fact containing the KVM emulator binary path
|
|
set_fact:
|
|
libvirt_vm_emulator: "{{ item.item }}"
|
|
with_items: "{{ kvm_emulator_result.results }}"
|
|
when: item.stat.exists
|
|
when: libvirt_vm_engine == 'kvm'
|
|
|
|
- block:
|
|
- name: Detect the QEMU emulator binary path
|
|
shell: which qemu-system-{{ libvirt_vm_arch }}
|
|
register: qemu_emulator_result
|
|
changed_when: false
|
|
|
|
- name: Set a fact containing the QEMU emulator binary path
|
|
set_fact:
|
|
libvirt_vm_emulator: "{{ qemu_emulator_result.stdout }}"
|
|
when: libvirt_vm_engine == 'qemu'
|
|
|
|
- name: Fail if unable to detect the emulator
|
|
fail:
|
|
msg: Unable to detect emulator for engine {{ libvirt_vm_engine }}.
|
|
when: libvirt_vm_emulator is none
|
|
when: libvirt_vm_emulator is none or libvirt_vm_emulator | length == 0 |