Repository: ansible/ansible

Issue:
oVirt Ansible module - ovirt_disk - sparse is supported with raw disks as well
See 
https://github.com/ansible/ansible/blob/663f8464ee7ab2cb086857f04393e643407fba0f/lib/ansible/modules/cloud/ovirt/ovirt_disk.py#L441

file based storage supports raw-sparse as well, I'm not sure the check is correct.


Discussion:
cc @machacekondra 
@mykaul Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. 

Here are the items we could not find in your description:
- issue type
- ansible version
- component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_missing_data --->
!component =lib/ansible/modules/cloud/ovirt/ovirt_disk

Right, we need to introduce new `sparse` parameter and have this as default behavior if `sparse` parameters isn't found.
!component lib/ansible/modules/cloud/ovirt/ovirt_disk

Resolving patch:
diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_disk.py b/lib/ansible/modules/cloud/ovirt/ovirt_disk.py
--- a/lib/ansible/modules/cloud/ovirt/ovirt_disk.py
+++ b/lib/ansible/modules/cloud/ovirt/ovirt_disk.py
@@ -87,10 +87,15 @@
     format:
         description:
             - 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 I(thin provision).
-            - If (raw) format is used, disk storage will be allocated right away, also known as I(preallocated).
             - Note that this option isn't idempotent as it's not currently possible to change format of the disk via API.
         choices: ['raw', 'cow']
+    sparse:
+        required: False
+        version_added: "2.5"
+        description:
+            - "I(True) if the disk should be sparse (also known as I(thin provision)).
+              If the parameter is omitted, cow disks will be created as sparse and raw disks as I(preallocated)"
+            - Note that this option isn't idempotent as it's not currently possible to change sparseness of the disk via API.
     storage_domain:
         description:
             - "Storage domain name where disk should be created. By default storage is chosen by oVirt/RHV engine."
@@ -438,7 +443,11 @@ def build_entity(self):
             format=otypes.DiskFormat(
                 self._module.params.get('format')
             ) if self._module.params.get('format') else None,
-            sparse=self._module.params.get('format') != 'raw',
+            sparse=self._module.params.get(
+                'sparse'
+            ) if self._module.params.get(
+                'sparse'
+            ) is not None else self._module.params.get('format') != 'raw',
             openstack_volume_type=otypes.OpenStackVolumeType(
                 name=self.param('openstack_volume_type')
             ) if self.param('openstack_volume_type') else None,
@@ -563,6 +572,7 @@ def main():
         profile=dict(default=None),
         quota_id=dict(default=None),
         format=dict(default='cow', choices=['raw', 'cow']),
+        sparse=dict(default=None, type='bool'),
         bootable=dict(default=None, type='bool'),
         shareable=dict(default=None, type='bool'),
         logical_unit=dict(default=None, type='dict'),


Test patch: