oVirt Virtual Machine Infrastructure
====================================
The `vm_infra` role manages the virtual machine infrastructure in oVirt.
This role also creates inventory of created virtual machines it defines if
`wait_for_ip` is set to `true` and state of virtual machine is `running`.
All defined virtual machines are part of `ovirt_vm` inventory group.
Role also creates `ovirt_tag_{tag_name}` groups if there are any
tags assigned to a virtual machine and places all virtual machines with that tag
to that inventory group.
Consider the following variable structure:
```yaml
vms:
- name: myvm1
tag: mytag1
profile: myprofile
- name: myvm2
tag: mytag2
profile: myprofile
```
The role will create inventory group `ovirt_vm` with both of the virtual
machines - `myvm1` and `myvm2`. The role also creates inventory group `ovirt_tag_mytag1`
with virtual machine `myvm1` and inventory group `ovirt_tag_mytag2` with virtual
machine `myvm2`.
Limitations
-----------
* Does not support Ansible Check Mode (Dry Run).
Role Variables
--------------
| Name | Default value | |
|--------------------------------|---------------|----------------------------------------------|
| vms | UNDEF | List of dictionaries with virtual machine specifications. |
| affinity_groups | UNDEF | List of dictionaries with affinity groups specifications. |
| wait_for_ip | false | If true, the playbook should wait for the virtual machine IP reported by the guest agent. |
| wait_for_ip_version | v4 | Specify which IP version should be wait for. Either v4 or v6. |
| wait_for_ip_range | 0.0.0.0/0 | Specify CIDR of virutal machine IP which should be reported. Works only for IPv4. |
| debug_vm_create | false | If true, logs the tasks of the virtual machine being created. The log can contain passwords. |
| vm_infra_create_single_timeout | 180 | Time in seconds to wait for VM to be created and started (if state is running). |
| vm_infra_create_poll_interval | 15 | Polling interval. Time in seconds to wait between check of state of VM. |
| vm_infra_create_all_timeout | vm_infra_create_single_timeout * (vms.length) | Total time to wait for all VMs to be created/started. |
| vm_infra_wait_for_ip_retries | 5 | Number of retries to check if VM is reporting it's IP address. |
| vm_infra_wait_for_ip_delay | 5 | Polling interval of IP address. Time in seconds to wait between check if VM reports IP address. |
The `vms` and `profile` variables can contain following attributes, note that if you define same variable in both the value in `vms` has precendence:
| Name | Default value | |
|--------------------|-----------------------|--------------------------------------------|
| name | UNDEF | Name of the virtual machine to create. |
| tag | UNDEF | Name of the tag to assign to the virtual machine. Only administrator users can use this attribute. |
| cloud_init | UNDEF | Dictionary with values for Unix-like Virtual Machine initialization using cloud init. See below cloud_init section for more detailed description. |
| cloud_init_nics | UNDEF | List of dictionaries representing network interafaces to be setup by cloud init. See below cloud_init_nics section for more detailed description. |
| sysprep | UNDEF | Dictionary with values for Windows Virtual Machine initialization using sysprep. See below sysprep section for more detailed description. |
| profile | UNDEF | Dictionary specifying the virtual machine hardware. See the table below. |
| state | present | Should the Virtual Machine be stopped, present or running. Takes precedence before state value in profile. |
| nics | UNDEF | List of dictionaries specifying the NICs of the virtual machine. See below for more detailed description. |
| cluster | UNDEF | Name of the cluster where the virtual machine will be created. |
| clone | No | If yes then the disks of the created virtual machine will be cloned and independent of the template. This parameter is used only when state is running or present and VM didn't exist before. |
| template | Blank | Name of template that the virtual machine should be based on. |
| template_version | UNDEF | Version number of the template to be used for VM. By default the latest available version of the template is used. |
| boot_disk_name | UNDEF | Renames the bootable disk after the VM is created. Useful when creating VMs from templates |
| boot_disk_use_vm_name_prefix | true | Use the name of the virtual machine as prefix when renaming the VM boot disk. The resulting boot disk name would be {{vm_name}}_{{boot_disk_name}}|
| boot_disk_size | UNDEF | Resizes the bootable disk after the VM is created. A suffix that complies to the IEC 60027-2 standard (for example 10GiB, 1024MiB) can be used. |
| memory | UNDEF | Amount of virtual machine memory. |
| memory_max | UNDEF | Upper bound of virtual machine memory up to which memory hot-plug can be performed. |
| memory_guaranteed | UNDEF | Amount of minimal guaranteed memory of the Virtual Machine. Prefix uses IEC 60027-2 standard (for example 1GiB, 1024MiB). memory_guaranteed parameter can't be lower than memory parameter. |
| cores | UNDEF | Number of CPU cores used by the the virtual machine. |
| sockets | UNDEF | Number of virtual CPUs sockets of the Virtual Machine. |
| cpu_shares | UNDEF | Set a CPU shares for this Virtual Machine. |
| cpu_threads | UNDEF | Set a CPU threads for this Virtual Machine. |
| disks | UNDEF | List of dictionaries specifying the additional virtual machine disks. See below for more detailed description. |
| nics | UNDEF | List of dictionaries specifying the NICs of the virtual machine. See below for more detailed description. |
| custom_properties | UNDEF | Properties sent to VDSM to configure various hooks.
Custom properties is a list of dictionary which can have following values:
name - Name of the custom property. For example: hugepages, vhost, sap_agent, etc.
regexp - Regular expression to set for custom property.
value - Value to set for custom property. |
| high_availability | UNDEF | Whether or not the node should be set highly available. |
| high_availability_priority | UNDEF | Indicates the priority of the virtual machine inside the run and migration queues. Virtual machines with higher priorities will be started and migrated before virtual machines with lower priorities. The value is an integer between 0 and 100. The higher the value, the higher the priority. If no value is passed, default value is set by oVirt/RHV engine. |
| io_threads | UNDEF | Number of IO threads used by virtual machine. 0 means IO threading disabled. |
| description | UNDEF | Description of the Virtual Machine. |
| operating_system | UNDEF | Operating system of the Virtual Machine. For example: rhel_7x64 |
| type | UNDEF | Type of the Virtual Machine. Possible values: desktop, server or high_performance |
| graphical_console | UNDEF | Assign graphical console to the virtual machine.
Graphical console is a dictionary which can have following values:
headless_mode - If true disable the graphics console for this virtual machine.
protocol - 'VNC', 'Spice' or both. |
| storage_domain | UNDEF | Name of the storage domain where all virtual machine disks should be created. Considered only when template is provided.|
| state | present | Should the Virtual Machine be stopped, present or running.|
| ssh_key | UNDEF | SSH key to be deployed to the virtual machine. This is parameter is keep for backward compatibility and has precendece before authorized_ssh_keys in cloud_init dictionary. |
| domain | UNDEF | The domain of the virtual machine. This is parameter is keep for backward compatibility and has precendece before host_name in cloud_init or sysprep dictionary.|
| lease | UNDEF | Name of the storage domain this virtual machine lease reside on. |
| root_password | UNDEF | The root password of the virtual machine. This is parameter is keep for backward compatibility and has precendece before root_password in cloud_init or sysprep dictionary.|
| host | UNDEF | If you need to set cpu_mode as host_passthrough, you need to use this param to define host to use along with placement_policy set to pinned. |
| cpu_mode | UNDEF | CPU mode of the virtual machine. It can be some of the following: host_passthrough, host_model or custom. |
| placement_policy | UNDEF | The configuration of the virtual machine's placement policy. |
| boot_devices | UNDEF | List of boot devices which should be used to boot. Valid entries are `cdrom`, `hd`, `network`. |
| serial_console | UNDEF | True enable VirtIO serial console, False to disable it. By default is chosen by oVirt/RHV engine. |
| serial_policy | UNDEF | Specify a serial number policy for the Virtual Machine. Following options are supported.
vm - Sets the Virtual Machine's UUID as its serial number.
host - Sets the host's UUID as the Virtual Machine's serial number.
custom - Allows you to specify a custom serial number in serial_policy_value. |
| serial_policy_value | UNDEF | Allows you to specify a custom serial number. This parameter is used only when serial_policy is custom. |
| comment | UNDEF | Comment of the virtual Machine. |
The item in `disks` list of `profile` dictionary can contain following attributes:
| Name | Default value | |
|--------------------|----------------|----------------------------------------------|
| size | UNDEF | The size of the additional disk. |
| name | UNDEF | The name of the additional disk. |
| id | UNDEF | Id of the disk. If you pass id of the disk and name the disk will be looked up by id and will update name of the disk if it differs from the name passed in name parameter. |
| storage_domain | UNDEF | The name of storage domain where disk should be created. |
| interface | UNDEF | The interface of the disk. |
| name_prefix | True | If true the name of the vm will be used as prefix of disk name. If false only the name of disk will be used as disk name - could be useful when creating vm from template with custom disk size. |
| format | UNDEF | Specify format of the disk.