Fix wipe-disks role to work on util-linux >= 2.37

On newer versions of util-linux, the ``wipe_disks`` role was not
properly configured due to the fact that ``lsblk -J`` returns a slightly
different output than what was previously returned. Previously the
output would contain a key called ``mountpoint``, however this has been
changed to ``mountpoints``. This has now been fixed by looking at the
new key as well as the old key.

Closes-bug: #2051859
Change-Id: I2a59f4eb3ae27f37fda38e05924315887cb04c41
This commit is contained in:
Dawud 2024-01-29 17:32:31 +00:00
parent 395bd34f64
commit 3942d29448
No known key found for this signature in database
2 changed files with 16 additions and 3 deletions

View File

@ -28,8 +28,14 @@ import json
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
def _has_mounts(device): def _has_mounts(device):
try:
if device["mountpoint"]: if device["mountpoint"]:
return True return True
# If unmounted, the JSON output contains "mountpoints": [null] so we handle
# the KeyError here.
except KeyError:
if device["mountpoints"][0]:
return True
for child in device.get("children", []): for child in device.get("children", []):
if _has_mounts(child): if _has_mounts(child):
return True return True

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes the ``wipe-disks`` role which was failing on supported host operating
systems due to a change in the output format of ``lsblk -J`` in
``util-linux`` version ``2.37``. LP#2051859
<https://bugs.launchpad.net/kayobe/+bug/2051859>__