community.general.lvol (1.3.11) — module

Configure LVM logical volumes

Authors: Jeroen Hoekx (@jhoekx), Alexander Bulimov (@abulimov)

Install collection

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


Add to requirements.yml

  collections:
    - name: community.general
      version: 1.3.11

Description

This module creates, removes or resizes logical volumes.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a logical volume of 512m
  community.general.lvol:
    vg: firefly
    lv: test
    size: 512
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a logical volume of 512m with disks /dev/sda and /dev/sdb
  community.general.lvol:
    vg: firefly
    lv: test
    size: 512
    pvs: /dev/sda,/dev/sdb
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create cache pool logical volume
  community.general.lvol:
    vg: firefly
    lv: lvcache
    size: 512m
    opts: --type cache-pool
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a logical volume of 512g.
  community.general.lvol:
    vg: firefly
    lv: test
    size: 512g
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a logical volume the size of all remaining space in the volume group
  community.general.lvol:
    vg: firefly
    lv: test
    size: 100%FREE
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a logical volume with special options
  community.general.lvol:
    vg: firefly
    lv: test
    size: 512g
    opts: -r 16
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Extend the logical volume to 1024m.
  community.general.lvol:
    vg: firefly
    lv: test
    size: 1024
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Extend the logical volume to consume all remaining space in the volume group
  community.general.lvol:
    vg: firefly
    lv: test
    size: +100%FREE
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Extend the logical volume to take all remaining space of the PVs and resize the underlying filesystem
  community.general.lvol:
    vg: firefly
    lv: test
    size: 100%PVS
    resizefs: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Resize the logical volume to % of VG
  community.general.lvol:
    vg: firefly
    lv: test
    size: 80%VG
    force: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reduce the logical volume to 512m
  community.general.lvol:
    vg: firefly
    lv: test
    size: 512
    force: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Set the logical volume to 512m and do not try to shrink if size is lower than current one
  community.general.lvol:
    vg: firefly
    lv: test
    size: 512
    shrink: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove the logical volume.
  community.general.lvol:
    vg: firefly
    lv: test
    state: absent
    force: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a snapshot volume of the test logical volume.
  community.general.lvol:
    vg: firefly
    lv: test
    snapshot: snap1
    size: 100m
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deactivate a logical volume
  community.general.lvol:
    vg: firefly
    lv: test
    active: false
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a deactivated logical volume
  community.general.lvol:
    vg: firefly
    lv: test
    size: 512g
    active: false
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a thin pool of 512g
  community.general.lvol:
    vg: firefly
    thinpool: testpool
    size: 512g
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a thin volume of 128g
  community.general.lvol:
    vg: firefly
    lv: test
    thinpool: testpool
    size: 128g

Inputs

    
lv:
    description:
    - The name of the logical volume.
    type: str

vg:
    description:
    - The volume group this logical volume is part of.
    required: true
    type: str

pvs:
    description:
    - Comma separated list of physical volumes (e.g. /dev/sda,/dev/sdb).
    type: str

opts:
    description:
    - Free-form options to be passed to the lvcreate command.
    type: str

size:
    description:
    - The size of the logical volume, according to lvcreate(8) --size, by default in megabytes
      or optionally with one of [bBsSkKmMgGtTpPeE] units; or according to lvcreate(8)
      --extents as a percentage of [VG|PVS|FREE]; Float values must begin with a digit.
      Resizing using percentage values was not supported prior to 2.1.
    type: str

force:
    default: 'no'
    description:
    - Shrink or remove operations of volumes requires this switch. Ensures that that filesystems
      get never corrupted/destroyed by mistake.
    type: bool

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Control if the logical volume exists. If C(present) and the volume does not already
      exist then the C(size) option is required.
    type: str

active:
    default: 'yes'
    description:
    - Whether the volume is active and visible to the host.
    type: bool

shrink:
    default: 'yes'
    description:
    - Shrink if current size is higher than size requested.
    type: bool

resizefs:
    default: 'no'
    description:
    - Resize the underlying filesystem together with the logical volume.
    - Supported for C(ext2), C(ext3), C(ext4), C(reiserfs) and C(XFS) filesystems. Attempts
      to resize other filesystem types will fail.
    type: bool

snapshot:
    description:
    - The name of the snapshot volume
    type: str

thinpool:
    description:
    - The thin pool volume name. When you want to create a thin provisioned volume, specify
      a thin pool volume name.
    type: str