On this page
community.general.lvg – Configure LVM volume groups
Note
This plugin is part of the community.general collection (version 3.8.1).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.lvg.
Synopsis
- This module creates, removes or resizes volume groups.
 
Parameters
| Parameter | Choices/Defaults | Comments | 
|---|---|---|
| force
        
        boolean
         | 
      
       
  | 
      
        
        If  yes, allows to remove volume group with logical volumes.
        | 
     
| pesize
        
        string
         | 
      Default: 
        "4"
         | 
      
        
        The size of the physical extent. pesize must be a power of 2 of at least 1 sector (where the sector size is the largest sector size of the PVs currently used in the VG), or at least 128KiB.
        
       
        Since Ansible 2.6, pesize can be optionally suffixed by a UNIT (k/K/m/M/g/G), default unit is megabyte.
         | 
     
| pv_options
        
        string
         | 
      
        
        Additional options to pass to  pvcreate when creating the volume group.
        | 
     |
| pvresize
        
        boolean
        
       
        added in 0.2.0 of community.general
         | 
      
       
  | 
      
        
        If  yes, resize the physical volume to the maximum available size.
        | 
     
| pvs
        
        list / elements=string
         | 
      
        
        List of comma-separated devices to use as physical devices in this volume group.
        
       
        Required when creating or resizing volume group.
        
       
        The module will take care of running pvcreate if needed.
         | 
     |
| state
        
        string
         | 
      
       
  | 
      
        
        Control if the volume group exists.
         | 
     
| vg
        
        string / required
         | 
      
        
        The name of the volume group.
         | 
     |
| vg_options
        
        string
         | 
      
        
        Additional options to pass to  vgcreate when creating the volume group.
        | 
     
Notes
Note
- This module does not modify PE size for already present volume group.
 
See Also
See also
- community.general.filesystem
 - 
     
The official documentation on the community.general.filesystem module.
 - community.general.lvol
 - 
     
The official documentation on the community.general.lvol module.
 - community.general.parted
 - 
     
The official documentation on the community.general.parted module.
 
Examples
- name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
  community.general.lvg:
    vg: vg.services
    pvs: /dev/sda1
    pesize: 32
- name: Create a volume group on top of /dev/sdb with physical extent size = 128KiB
  community.general.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,
# and then reduce by /dev/sda5.
- name: Create or resize a volume group on top of /dev/sdb1 and /dev/sdc5.
  community.general.lvg:
    vg: vg.services
    pvs: /dev/sdb1,/dev/sdc5
- name: Remove a volume group with name vg.services
  community.general.lvg:
    vg: vg.services
    state: absent
- name: Create a volume group on top of /dev/sda3 and resize the volume group /dev/sda3 to the maximum possible
  community.general.lvg:
    vg: resizableVG
    pvs: /dev/sda3
    pvresize: yes
  Authors
- Alexander Bulimov (@abulimov)
 
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
 https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html