airshipctl/roles/libvirt-domain/defaults/main.yaml
Alexander Hughes d5e28362f2 [#62] Standardize yaml file extensions
Currently we have mixed extensions of .yml and .yaml, this patch is
an effort to standardize all yaml documents as .yaml

Change-Id: I7eb815584de5856bbdac9a828ccad8518e8c1729
2020-02-24 14:50:32 +00:00

174 lines
6.1 KiB
YAML

---
# 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 <clock sync="localtime">
# to configure the instances clock synchronisation. Change to a timezone to make
# configuration use <clock offset="specified offset">
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: |
<domain type='{{ libvirt_vm_engine }}'>
<name>{{ libvirt_domain.name }}</name>
<memory>{{ libvirt_domain.memory_mb | int * 1024 }}</memory>
<vcpu>{{ libvirt_domain.vcpus }}</vcpu>
{% if libvirt_domain.clock_offset |default( libvirt_vm_clock_offset ) %}
<clock offset="{{ libvirt_domain.clock_offset }}"/>
{% else %}
<clock sync="localtime"/>
{% endif %}
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<os>
<type arch='{{ libvirt_vm_arch }}'{% if machine is not none %} machine='{{ machine }}'{% endif %}>hvm</type>
<bootmenu enable='no'/>
<boot dev='hd'/>
<boot dev='cdrom'/>
<boot dev='network'/>
<bios useserial='yes'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
{% if cpu_mode %}
<cpu mode='{{ cpu_mode }}'>
<model fallback='allow'/>
</cpu>
{% endif %}
<devices>
<emulator>{{ libvirt_vm_emulator }}</emulator>
{% for volume in volumes %}
<disk type='{{ volume.type | default(libvirt_volume_default_type) }}' device='{{ volume.device | default(libvirt_volume_default_device) }}'>
<driver name='qemu' type='{{ volume.format | default(libvirt_volume_default_format) }}'/>
{% if volume.type | default(libvirt_volume_default_type) == 'file' %}
<source file='{{ volume.file_path |default(libvirt_volume_default_images_path) }}/{{ volume.name}}'/>
{% else %}
<source pool='{{ volume.pool }}' volume='{{ volume.name }}'/>
{% endif %}
{% if volume.target is undefined %}
<target dev='vd{{ 'abcdefghijklmnopqrstuvwxyz'[loop.index - 1] }}'/>
{% else %}
<target dev='{{ volume.target }}' />
{% endif %}
</disk>
{% endfor %}
{% for interface in interfaces %}
{% if interface.type is defined and interface.type == 'direct' %}
<interface type='direct'>
<source dev='{{ interface.source.dev }}' mode='{{ interface.source.mode | default('vepa') }}'/>
{% elif interface.type is defined and interface.type == 'bridge' %}
<interface type='bridge'>
<source bridge='{{ interface.source.dev }}'/>
{% elif interface.type is not defined or interface.type == 'network' %}
<interface type='network'>
<source network='{{ interface.network }}'/>
{% endif %}
{% if interface.mac is defined %}
<mac address='{{ interface.mac }}'/>
{% endif %}
{# if the network configuration is invalid this can still appear in the xml #}
{# (say you enter 'bond' instead of 'bridge' in your variables) #}
<model type='virtio'/>
</interface>
{% endfor %}
{% if console_log_enabled | bool %}
<serial type='file'>
<source path='{{ console_log_path }}'/>
</serial>
<serial type='pty'/>
<console type='file'>
<source path='{{ console_log_path }}'/>
<target type='serial'/>
</console>
{% else %}
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
{% endif %}
{% if enable_vnc |bool %}
<graphics type='vnc' autoport='yes' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
{% endif %}
<rng model="virtio"><backend model="random">/dev/urandom</backend></rng>
</devices>
</domain>