From 3324765fdd9f5d5cec50410e19edcf40d59491b8 Mon Sep 17 00:00:00 2001 From: Sachidananda Urs Date: Mon, 7 May 2018 11:20:58 +0530 Subject: [PATCH] lvg: Allow unit to be specified for pesize (#39666) --- lib/ansible/modules/system/lvg.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/system/lvg.py b/lib/ansible/modules/system/lvg.py index 9d8eef10ab0..8b52e48629e 100644 --- a/lib/ansible/modules/system/lvg.py +++ b/lib/ansible/modules/system/lvg.py @@ -32,7 +32,9 @@ options: - The module will take care of running pvcreate if needed. pesize: description: - - The size of the physical extent in megabytes. Must be a power of 2. + - The size of the physical extent. pesize must be a power of 2, or + multiple of 128KiB. Since version 2.6, pesize can be optionally suffixed + by a UNIT (k/K/m/M/g/G), default unit is megabyte. default: 4 pv_options: description: @@ -63,6 +65,12 @@ EXAMPLES = ''' pvs: /dev/sda1 pesize: 32 +- name: Create a volume group on top of /dev/sdb with physical extent size = 128KiB + lvg: + vg: vg.services + pvs: /dev/sdb + pesize: 128K + # If, for example, we already have VG vg.services on top of /dev/sdb1, # this VG will be extended by /dev/sdc5. Or if vg.services was created on # top of /dev/sda5, we first extend it with /dev/sdb1 and /dev/sdc5, @@ -124,7 +132,7 @@ def main(): argument_spec=dict( vg=dict(type='str', required=True), pvs=dict(type='list'), - pesize=dict(type='int', default=4), + pesize=dict(type='str', default=4), pv_options=dict(type='str', default=''), vg_options=dict(type='str', default=''), state=dict(type='str', default='present', choices=['absent', 'present']), @@ -205,7 +213,7 @@ def main(): else: module.fail_json(msg="Creating physical volume '%s' failed" % current_dev, rc=rc, err=err) vgcreate_cmd = module.get_bin_path('vgcreate') - rc, _, err = module.run_command([vgcreate_cmd] + vgoptions + ['-s', str(pesize), vg] + dev_list) + rc, _, err = module.run_command([vgcreate_cmd] + vgoptions + ['-s', pesize, vg] + dev_list) if rc == 0: changed = True else: