From e197a94f2b89935417003d67f555d21bcccffc71 Mon Sep 17 00:00:00 2001 From: Tim Rightnour Date: Sat, 25 Nov 2017 00:12:58 -0700 Subject: [PATCH] Add resizefs param in lvol (#31132) This fix allows user to specify resizefs in logical volume extension. Fix placement of new option, document. Signed-off-by: Tim Rightnour Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/system/lvol.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/system/lvol.py b/lib/ansible/modules/system/lvol.py index d994d87bff1..fbe112f5c1c 100644 --- a/lib/ansible/modules/system/lvol.py +++ b/lib/ansible/modules/system/lvol.py @@ -58,7 +58,7 @@ options: version_added: "1.5" opts: description: - - Free-form options to be passed to the lvcreate command + - Free-form options to be passed to the lvcreate command. version_added: "2.0" snapshot: description: @@ -66,16 +66,20 @@ options: version_added: "2.1" pvs: description: - - Comma separated list of physical volumes e.g. /dev/sda,/dev/sdb + - Comma separated list of physical volumes (e.g. /dev/sda,/dev/sdb). version_added: "2.2" shrink: description: - - shrink if current size is higher than size requested + - Shrink if current size is higher than size requested. type: bool default: 'yes' version_added: "2.2" -notes: - - Filesystems on top of the volume are not resized. + resizefs: + description: + - Resize the underlying filesystem together with the logical volume. + type: bool + default: 'yes' + version_added: "2.5" ''' EXAMPLES = ''' @@ -135,6 +139,7 @@ EXAMPLES = ''' vg: firefly lv: test size: 100%PVS + resizefs: true - name: Resize the logical volume to % of VG lvol: @@ -244,7 +249,8 @@ def main(): shrink=dict(type='bool', default=True), active=dict(type='bool', default=True), snapshot=dict(type='str'), - pvs=dict(type='str') + pvs=dict(type='str'), + resizefs=dict(type='bool', default=False), ), supports_check_mode=True, ) @@ -267,6 +273,7 @@ def main(): force = module.boolean(module.params['force']) shrink = module.boolean(module.params['shrink']) active = module.boolean(module.params['active']) + resizefs = module.boolean(module.params['resizefs']) size_opt = 'L' size_unit = 'm' snapshot = module.params['snapshot'] @@ -421,6 +428,8 @@ def main(): tool = '%s %s' % (tool, '--force') if tool: + if resizefs: + tool = '%s %s' % (tool, '--resizefs') cmd = "%s %s -%s %s%s %s/%s %s" % (tool, test_opt, size_opt, size, size_unit, vg, this_lv['name'], pvs) rc, out, err = module.run_command(cmd) if "Reached maximum COW size" in out: @@ -450,6 +459,8 @@ def main(): tool = '%s %s' % (tool, '--force') if tool: + if resizefs: + tool = '%s %s' % (tool, '--resizefs') cmd = "%s %s -%s %s%s %s/%s %s" % (tool, test_opt, size_opt, size, size_unit, vg, this_lv['name'], pvs) rc, out, err = module.run_command(cmd) if "Reached maximum COW size" in out: