# 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. --- # The default directory in which to store VM console logs, if a VM-specific log # file path is not given. libvirt_vm_default_console_log_dir: "/var/log/libvirt-consoles" # The default location for libvirt images libvirt_volume_default_images_path: '/var/lib/libvirt/images' # Default type for Libvirt volumes libvirt_volume_default_type: volume # The default format for Libvirt volumes. libvirt_volume_default_format: qcow2 # The default device for Libvirt volumes. libvirt_volume_default_device: disk # CPU architecture. libvirt_vm_arch: x86_64 # Virtualisation engine. If not set, the role will attempt to auto-detect the # optimal engine to use. libvirt_vm_engine: # Path to emulator binary. If not set, the role will attempt to auto-detect the # correct emulator to use. libvirt_vm_emulator: # Default value for clock syncing. The default (false) uses # to configure the instances clock synchronisation. Change to a timezone to make # configuration use libvirt_vm_clock_offset: False # A list of specifications of VMs to be created. # For backwards compatibility, libvirt_vms defaults to a singleton list using # the values of the deprecated variables below. # See README.md or tasks/main.yaml for these attributes' defaults. libvirt_domain: # State of the VM. May be 'present' or 'absent'. state: "{{ libvirt_vm_state }}" # Name of the VM. name: "{{ libvirt_vm_name }}" # Memory in MB. memory_mb: "{{ libvirt_vm_memory_mb }}" # Number of vCPUs. vcpus: "{{ libvirt_vm_vcpus }}" # Virtual machine type. machine: "{{ libvirt_vm_machine }}" # Virtual machine CPU mode. cpu_mode: "{{ libvirt_vm_cpu_mode | default(libvirt_cpu_mode_default, true) }}" # List of volumes. volumes: "{{ libvirt_vm_volumes }}" # What time should the clock be synced to on boot (utc/localtime/timezone/variable) clock_offset: "localtime" # List of network interfaces. interfaces: "{{ libvirt_vm_interfaces }}" # Path to console log file. console_log_path: "{{ libvirt_vm_console_log_path }}" # XML template file to source domain definition xml_file: vm.xml.j2 # Variables to add to the enviroment that is used to execute virsh commands libvirt_vm_virsh_default_env: "{{ { 'LIBVIRT_DEFAULT_URI': libvirt_vm_uri } if libvirt_vm_uri else {} }}" # Override for the libvirt connection uri. Leave unset to use the default. libvirt_vm_uri: "" # Default CPU mode if libvirt_vm_cpu_mode or vm.cpu_mode is undefined libvirt_cpu_mode_default: "{{ 'host-passthrough' if libvirt_vm_engine == 'kvm' else 'host-model' }}" libvirt_domain_template_default: | {{ libvirt_domain.name }} {{ libvirt_domain.memory_mb | int * 1024 }} {{ libvirt_domain.vcpus }} {% if libvirt_domain.clock_offset |default( libvirt_vm_clock_offset ) %} {% else %} {% endif %} destroy restart destroy hvm {% if libvirt_domain.boot_mode is defined and libvirt_domain.boot_mode == 'UEFI' %} /usr/share/OVMF/OVMF_CODE.fd {% endif %} {% if cpu_mode %} {% endif %} {{ libvirt_vm_emulator }} {% for volume in volumes %} {% if volume.type | default(libvirt_volume_default_type) == 'file' %} {% else %} {% endif %} {% if volume.target is undefined %} {% else %} {% endif %} {% endfor %} {% for controller in controllers | default([]) %}
{% endfor %} {% for interface in interfaces %} {% if interface.type is defined and interface.type == 'direct' %} {% elif interface.type is defined and interface.type == 'bridge' %} {% elif interface.type is not defined or interface.type == 'network' %} {% endif %} {% if interface.mac | default("") != "" %} {% endif %} {# if the network configuration is invalid this can still appear in the xml #} {# (say you enter 'bond' instead of 'bridge' in your variables) #} {% endfor %} {% if console_log_enabled | bool %} {% else %} {% endif %} {% if enable_vnc |bool %} {% endif %} /dev/urandom