ansible.builtin.lvol (v2.3.2.0-1) — module

Configure LVM logical volumes

| "added in version" 1.1 of ansible.builtin"

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

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.3.2.0.post1

Description

This module creates, removes or resizes logical volumes.

Usage examples

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

Inputs

    
lv:
    description:
    - The name of the logical volume.
    required: true

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

pvs:
    description:
    - Comma separated list of physical volumes e.g. /dev/sda,/dev/sdb
    required: false
    version_added: '2.2'
    version_added_collection: ansible.builtin

opts:
    description:
    - Free-form options to be passed to the lvcreate command
    version_added: '2.0'
    version_added_collection: ansible.builtin

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.

force:
    choices:
    - 'yes'
    - 'no'
    default: 'no'
    description:
    - Shrink or remove operations of volumes requires this switch. Ensures that that filesystems
      get never corrupted/destroyed by mistake.
    required: false
    version_added: '1.5'
    version_added_collection: ansible.builtin

state:
    choices:
    - present
    - absent
    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.
    required: false

active:
    choices:
    - 'yes'
    - 'no'
    default: 'yes'
    description:
    - Whether the volume is activate and visible to the host.
    required: false
    version_added: '2.2'
    version_added_collection: ansible.builtin

shrink:
    default: true
    description:
    - shrink if current size is higher than size requested
    required: false
    version_added: '2.2'
    version_added_collection: ansible.builtin

snapshot:
    description:
    - The name of the snapshot volume
    required: false
    version_added: '2.1'
    version_added_collection: ansible.builtin