ovirt_disk – Module to manage Virtual Machine and floating disks in oVirt/RHV
ovirt_disk – Module to manage Virtual Machine and floating disks in oVirt/RHV
New in version 2.2.
Synopsis
- Module to manage Virtual Machine and floating disks in oVirt/RHV.
Aliases: ovirt_disks
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.7
- ovirt-engine-sdk-python >= 4.2.4
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
auth - / required |
Dictionary with values needed to create HTTP/HTTPS connection to oVirt:
| |
bootable - |
True if the disk should be bootable. By default when disk is created it isn't bootable. | |
description - added in 2.5 |
Description of the disk image to manage. | |
download_image_path - added in 2.3 |
Path on a file system where disk should be downloaded. Note that you must have an valid oVirt/RHV engine CA in your system trust store or you must provide it in Note that the disk is not downloaded when the file already exists, but you can forcibly download the disk when using | |
fetch_nested boolean added in 2.3 |
|
If True the module will fetch additional data from the API. It will fetch IDs of the VMs disks, snapshots, etc. User can configure to fetch other attributes of the nested entities by specifying |
force - added in 2.3 |
Please take a look at | |
format - |
|
Specify format of the disk. Note that this option isn't idempotent as it's not currently possible to change format of the disk via API. |
id - |
ID of the disk to manage. Either | |
image_provider - added in 2.4 |
When
There is no reliable way to achieve idempotency, so every time you specify this parameter the disk is exported, so please handle your playbook accordingly to not export the disk all the time. This option is valid only for template disks. | |
interface - |
|
Driver of the storage interface. It's required parameter when creating the new disk. |
logical_unit - |
Dictionary which describes LUN to be directly attached to VM:
| |
name - |
Name of the disk to manage. Either
| |
nested_attributes - added in 2.3 |
Specifies list of the attributes which should be fetched from the API. This parameter apply only when | |
openstack_volume_type - added in 2.4 |
Name of the openstack volume type. This is valid when working with cinder. | |
poll_interval - |
Default: 3 |
Number of the seconds the module waits until another poll request on entity status is sent. |
profile - |
Disk profile name to be attached to disk. By default profile is chosen by oVirt/RHV engine. | |
quota_id - added in 2.5 |
Disk quota ID to be used for disk. By default quota is chosen by oVirt/RHV engine. | |
shareable - |
True if the disk should be shareable. By default when disk is created it isn't shareable. | |
size - |
Size of the disk. Size should be specified using IEC standard units. For example 10GiB, 1024MiB, etc. Size can be only increased, not decreased. | |
sparse - added in 2.5 |
True if the disk should be sparse (also known as thin provision). If the parameter is omitted, cow disks will be created as sparse and raw disks as preallocated Note that this option isn't idempotent as it's not currently possible to change sparseness of the disk via API. | |
sparsify - added in 2.4 |
True if the disk should be sparsified. Sparsification frees space in the disk image that is not used by its filesystem. As a result, the image will occupy less space on the storage. Note that this parameter isn't idempotent, as it's not possible to check if the disk should be or should not be sparsified. | |
state - |
|
Should the Virtual Machine disk be present/absent/attached/detached. |
storage_domain - |
Storage domain name where disk should be created. By default storage is chosen by oVirt/RHV engine. | |
storage_domains - added in 2.3 |
Storage domain names where disk should be copied.
There is no reliable way to achieve idempotency, so every time you specify this parameter the disks are copied, so please handle your playbook accordingly to not copy the disks all the time. This is valid only for VM and floating disks, template disks works as expected. | |
timeout - |
Default: 180 |
The amount of time in seconds the module should wait for the instance to get into desired state. |
upload_image_path - added in 2.3 |
Path to disk image, which should be uploaded. Note that currently we support only compatibility version 0.10 of the qcow disk. Note that you must have an valid oVirt/RHV engine CA in your system trust store or you must provide it in Note that there is no reliable way to achieve idempotency, so if you want to upload the disk even if the disk with | |
vm_id - |
ID of the Virtual Machine to manage. Either | |
vm_name - |
Name of the Virtual Machine to manage. Either | |
wait boolean |
|
True if the module should wait for the entity to get into desired state. |
Notes
Note
- In order to use this module you have to install oVirt Python SDK. To ensure it’s installed with correct version you can create the following task: pip: name=ovirt-engine-sdk-python version=4.2.4
Examples
# Examples don't contain auth parameter for simplicity,
# look at ovirt_auth module to see how to reuse authentication:
# Create and attach new disk to VM
- ovirt_disk:
name: myvm_disk
vm_name: rhel7
size: 10GiB
format: cow
interface: virtio
storage_domain: data
# Attach logical unit to VM rhel7
- ovirt_disk:
vm_name: rhel7
logical_unit:
target: iqn.2016-08-09.brq.str-01:omachace
id: 1IET_000d0001
address: 10.34.63.204
interface: virtio
# Detach disk from VM
- ovirt_disk:
state: detached
name: myvm_disk
vm_name: rhel7
size: 10GiB
format: cow
interface: virtio
# Change Disk Name
- ovirt_disk:
id: 00000000-0000-0000-0000-000000000000
storage_domain: data
name: "new disk name"
vm_name: rhel7
# Upload local image to disk and attach it to vm:
# Since Ansible 2.3
- ovirt_disk:
name: mydisk
vm_name: myvm
interface: virtio
size: 10GiB
format: cow
image_path: /path/to/mydisk.qcow2
storage_domain: data
# Download disk to local file system:
# Since Ansible 2.3
- ovirt_disk:
id: 7de90f31-222c-436c-a1ca-7e655bd5b60c
download_image_path: /home/user/mydisk.qcow2
# Export disk as image to Glance domain
# Since Ansible 2.4
- ovirt_disks:
id: 7de90f31-222c-436c-a1ca-7e655bd5b60c
image_provider: myglance
state: exported
# Defining a specific quota while creating a disk image:
# Since Ansible 2.5
- ovirt_quotas_facts:
data_center: Default
name: myquota
- ovirt_disk:
name: mydisk
size: 10GiB
storage_domain: data
description: somedescriptionhere
quota_id: "{{ ovirt_quotas[0]['id'] }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
disk dictionary |
On success if disk is found and vm_id or vm_name wasn't passed.
|
Dictionary of all the disk attributes. Disk attributes can be found on your oVirt/RHV instance at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/disk.
|
disk_attachment dictionary |
On success if disk is found and vm_id or vm_name was passed and VM was found.
|
Dictionary of all the disk attachment attributes. Disk attachment attributes can be found on your oVirt/RHV instance at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/disk_attachment.
|
id string |
On success if disk is found. |
ID of the managed disk
Sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Ondra Machacek (@machacekondra)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/ovirt_disk_module.html