1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-10 18:15:39 +00:00

lvol: resize filesystem when LV already has the requested size

When resizefs=true but the logical volume is already at the requested
size, run fsadm resize to ensure the filesystem fills the device.
Previously resizefs only took effect when the LV size changed
This commit is contained in:
shreyash bhosale 2026-06-09 17:06:42 +05:30
parent 3774ca20d2
commit da4337b44b
2 changed files with 16 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- lvol - ``resizefs`` now resizes the filesystem even when the logical volume already has the requested size (https://github.com/ansible-collections/community.general/issues/11620).

View file

@ -90,6 +90,8 @@ options:
- Resize the underlying filesystem together with the logical volume.
- Supported for C(ext2), C(ext3), C(ext4), C(reiserfs) and C(XFS) filesystems. Attempts to resize other filesystem types
result in failure.
- When the logical volume already has the requested size, the filesystem will still be resized to fill the logical volume
if needed.
type: bool
default: false
notes:
@ -662,6 +664,18 @@ def main():
else:
module.fail_json(msg=f"Unable to resize {lv} to {size}{size_unit}", rc=rc, err=err)
if resizefs and not changed and size:
lv_path = f"/dev/{vg}/{this_lv['name']}"
if module.check_mode:
changed = True
else:
fsadm = module.get_bin_path("fsadm", required=True)
rc, out, err = module.run_command([fsadm, "resize", lv_path])
if rc == 0:
changed = True
else:
module.fail_json(msg=f"Failed to resize filesystem on {lv_path}", rc=rc, err=err, out=out)
if this_lv is not None:
if active:
with lvchange("active lv") as ctx: