community.general.lvg (8.5.0) — module

Configure LVM volume groups

Authors: Alexander Bulimov (@abulimov)

Install collection

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


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deactivate a volume group
  community.general.lvg:
    state: inactive
    vg: vg.services
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Activate a volume group
  community.general.lvg:
    state: active
    vg: vg.services
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reset a volume group UUID
  community.general.lvg:
    state: inactive
    vg: vg.services
    reset_vg_uuid: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reset both volume group and pv UUID
  community.general.lvg:
    state: inactive
    vg: vg.services
    pvs: /dev/sdb1,/dev/sdc5
    reset_vg_uuid: true
    reset_pv_uuid: 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 V(true), allows to remove volume group with logical volumes.
    type: bool

state:
    choices:
    - absent
    - present
    - active
    - inactive
    default: present
    description:
    - Control if the volume group exists and it's state.
    - The states V(active) and V(inactive) implies V(present) state. Added in 7.1.0
    - If V(active) or V(inactive), the module manages the VG's logical volumes current
      state. The module also handles the VG's autoactivation state if supported unless
      when creating a volume group and the autoactivation option specified in O(vg_options).
    type: str

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

reset_pv_uuid:
    default: false
    description:
    - Whether the volume group's physical volumes' UUIDs are regenerated.
    - This is B(not idempotent). Specifying this parameter always results in a change.
    type: bool
    version_added: 7.1.0
    version_added_collection: community.general

reset_vg_uuid:
    default: false
    description:
    - Whether the volume group's UUID is regenerated.
    - This is B(not idempotent). Specifying this parameter always results in a change.
    type: bool
    version_added: 7.1.0
    version_added_collection: community.general

See also