community.general.lvg (6.6.8) — module

Configure LVM volume groups

Authors: Alexander Bulimov (@abulimov)

Install collection

Install with ansible-galaxy collection install community.general:==6.6.8


Add to requirements.yml

  collections:
    - name: community.general
      version: 6.6.8

Description

This module creates, removes or resizes volume groups.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a volume group with name vg.services
  community.general.lvg:
    vg: vg.services
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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: true

Inputs

    
vg:
    description:
    - The name of the volume group.
    required: true
    type: str

pvs:
    description:
    - 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.
    elements: str
    type: list

force:
    default: false
    description:
    - If C(true), allows to remove volume group with logical volumes.
    type: bool

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Control if the volume group exists.
    type: str

pesize:
    default: '4'
    description:
    - The size of the physical extent. I(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.
    type: str

pvresize:
    default: false
    description:
    - If C(true), resize the physical volume to the maximum available size.
    type: bool
    version_added: 0.2.0
    version_added_collection: community.general

pv_options:
    default: ''
    description:
    - Additional options to pass to C(pvcreate) when creating the volume group.
    type: str

vg_options:
    default: ''
    description:
    - Additional options to pass to C(vgcreate) when creating the volume group.
    type: str

See also