diff --git a/changelogs/fragments/229_lvol_percentage_fix.yml b/changelogs/fragments/229_lvol_percentage_fix.yml new file mode 100644 index 00000000000..aaf98454ed4 --- /dev/null +++ b/changelogs/fragments/229_lvol_percentage_fix.yml @@ -0,0 +1,2 @@ +minor_changes: + - lvol - fix idempotency issue when using lvol with ``%VG`` or ``%PVS`` size options and VG is fully allocated (https://github.com/ansible-collections/community.general/pull/229). diff --git a/plugins/modules/system/lvol.py b/plugins/modules/system/lvol.py index 26ea7dc24ef..2e9ad9189ac 100644 --- a/plugins/modules/system/lvol.py +++ b/plugins/modules/system/lvol.py @@ -468,6 +468,10 @@ def main(): size_requested = size_percent * this_vg['size'] / 100 else: # size_whole == 'FREE': size_requested = size_percent * this_vg['free'] / 100 + + # Round down to the next lowest whole physical extent + size_requested -= (size_requested % this_vg['ext_size']) + if '+' in size: size_requested += this_lv['size'] if this_lv['size'] < size_requested: