Documentation

ovirt_disks - Module to manage Virtual Machine and floating disks in oVirt

New in version 2.2.

Synopsis

  • Module to manage Virtual Machine and floating disks in oVirt.

Requirements (on host that executes module)

  • python >= 2.7
  • ovirt-engine-sdk-python >= 4.0.0

Options

parameter required default choices comments
auth
yes
Dictionary with values needed to create HTTP/HTTPS connection to oVirt:
username[required] - The name of the user, something like admin@internal. Default value is set by OVIRT_USERNAME environment variable.
password[required] - The password of the user. Default value is set by OVIRT_PASSWORD environment variable.
url[required] - A string containing the base URL of the server, usually something like `https://server.example.com/ovirt-engine/api`. Default value is set by OVIRT_URL environment variable.
token - Token to be used instead of login with username/password. Default value is set by OVIRT_TOKEN environment variable.
insecure - A boolean flag that indicates if the server TLS certificate and host name should be checked.
ca_file - A PEM file containing the trusted CA certificates. The certificate presented by the server will be verified using these CA certificates. If `ca_file` parameter is not set, system wide CA certificate store is used. Default value is set by OVIRT_CAFILE environment variable.
kerberos - A boolean flag indicating if Kerberos authentication should be used instead of the default basic authentication.
bootable
no
True if the disk should be bootable. By default when disk is created it isn't bootable.
download_image_path
(added in 2.3)
no
Path on a file system where disk should be downloaded.
Note that you must have an valid oVirt engine CA in your system trust store or you must provide it in ca_file parameter.
Note that the disk is not downloaded when the file already exists, but you can forcibly download the disk when using force I (true).
fetch_nested
(added in 2.3)
no
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 nested_attributes.
force
(added in 2.3)
no
Please take a look at image_path documentation to see the correct usage of this parameter.
format
no
  • raw
  • cow
Specify format of the disk.
If (cow) format is used, disk will by created as sparse, so space will be allocated for the volume as needed, also known as thin provision.
If (raw) format is used, disk storage will be allocated right away, also known as preallocated.
Note that this option isn't idempotent as it's not currently possible to change format of the disk via API.
id
no
ID of the disk to manage. Either id or name is required.
interface
no virtio
  • virtio
  • ide
  • virtio_scsi
Driver of the storage interface.
logical_unit
no
Dictionary which describes LUN to be directly attached to VM:
address - Address of the storage server. Used by iSCSI.
port - Port of the storage server. Used by iSCSI.
target - iSCSI target.
lun_id - LUN id.
username - CHAP Username to be used to access storage server. Used by iSCSI.
password - CHAP Password of the user to be used to access storage server. Used by iSCSI.
storage_type - Storage type either fcp or iscsi.
name
no
Name of the disk to manage. Either id or name/alias is required.

aliases: alias
nested_attributes
(added in 2.3)
no
Specifies list of the attributes which should be fetched from the API.
This parameter apply only when fetch_nested is true.
poll_interval
no 3
Number of the seconds the module waits until another poll request on entity status is sent.
profile
no
Disk profile name to be attached to disk. By default profile is chosen by oVirt engine.
shareable
no
True if the disk should be shareable. By default when disk is created it isn't shareable.
size
no
Size of the disk. Size should be specified using IEC standard units. For example 10GiB, 1024MiB, etc.
Size can be only increased, not decreased.
sparsify
(added in 2.4)
no
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
no present
  • present
  • absent
  • attached
  • detached
Should the Virtual Machine disk be present/absent/attached/detached.
storage_domain
no
Storage domain name where disk should be created. By default storage is chosen by oVirt engine.
storage_domains
(added in 2.3)
no
Storage domain names where disk should be copied.
**IMPORTANT**
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
no 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)
no
Path to disk image, which should be uploaded.
Note that currently we support only compability version 0.10 of the qcow disk.
Note that you must have an valid oVirt engine CA in your system trust store or you must provide it in ca_file parameter.
Note that there is no reliable way to achieve idempotency, so if you want to upload the disk even if the disk with id or name exists, then please use force true. If you will use force false, which is default, then the disk image won't be uploaded.
vm_id
no
ID of the Virtual Machine to manage. Either vm_id or vm_name is required if state is attached or detached.
vm_name
no
Name of the Virtual Machine to manage. Either vm_id or vm_name is required if state is attached or detached.
wait
no
True if the module should wait for the entity to get into desired state.

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_disks:
    name: myvm_disk
    vm_name: rhel7
    size: 10GiB
    format: cow
    interface: virtio

# Attach logical unit to VM rhel7
- ovirt_disks:
    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_disks:
    state: detached
    name: myvm_disk
    vm_name: rhel7
    size: 10GiB
    format: cow
    interface: virtio

# Upload local image to disk and attach it to vm:
# Since Ansible 2.3
- ovirt_disks:
    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_disks:
    id: 7de90f31-222c-436c-a1ca-7e655bd5b60c
    download_image_path: /home/user/mydisk.qcow2

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
disk Dictionary of all the disk attributes. Disk attributes can be found on your oVirt instance at following url: https://ovirt.example.com/ovirt-engine/api/model#types/disk. On success if disk is found and C(vm_id) or C(vm_name) wasn't passed.
id ID of the managed disk On success if disk is found. str 7de90f31-222c-436c-a1ca-7e655bd5b60c
disk_attachment Dictionary of all the disk attachment attributes. Disk attachment attributes can be found on your oVirt instance at following url: https://ovirt.example.com/ovirt-engine/api/model#types/disk_attachment. On success if disk is found and C(vm_id) or C(vm_name) was passed and VM was found.


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.0.0

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Support

This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.