community.general.lvm_pv module – Manage LVM Physical Volumes

Note

This module is part of the community.general collection (version 11.2.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.lvm_pv.

New in community.general 11.0.0

Synopsis

  • Creates, resizes or removes LVM Physical Volumes.

Parameters

Parameter

Comments

device

path / required

Path to the block device to manage.

force

boolean

Force the operation.

When state=present (creating a PV), this uses pvcreate -f to force creation.

When state=absent (removing a PV), this uses pvremove -ff to force removal even if part of a volume group.

Choices:

  • false ← (default)

  • true

resize

boolean

Resize PV to device size when state=present.

Choices:

  • false ← (default)

  • true

state

string

Control if the physical volume exists.

Choices:

  • "present" ← (default)

  • "absent"

Notes

Note

  • Requires LVM2 utilities installed on the target system.

  • Device path must exist when creating a PV.

Examples

- name: Creating physical volume on /dev/sdb
  community.general.lvm_pv:
    device: /dev/sdb

- name: Creating and resizing (if needed) physical volume
  community.general.lvm_pv:
    device: /dev/sdb
    resize: true

- name: Removing physical volume that is not part of any volume group
  community.general.lvm_pv:
    device: /dev/sdb
    state: absent

- name: Force removing physical volume that is already part of a volume group
  community.general.lvm_pv:
    device: /dev/sdb
    force: true
    state: absent

Authors

  • Klention Mali (@klention)