community.general.lvm_pv module – Manage LVM Physical Volumes
Note
This module is part of the community.general collection (version 14.0.0).
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 |
|---|---|
Whether the PV can be used for allocation of physical extents. Managed using Choices:
|
|
Align the start of the PV data area to a multiple of this value, for example Only applied when creating a new PV; cannot be changed afterwards. |
|
Path to the block device to manage. |
|
Force the operation. When When Choices:
|
|
Whether metadata areas on the PV are ignored, meaning LVM does not store VG metadata on it. Applied when creating a new PV, and enforced on existing PVs using Choices:
|
|
Approximate amount of space to reserve for VG metadata on the PV, for example Only applied when creating a new PV; the metadata area size cannot be changed afterwards. |
|
Number of metadata areas to reserve on the PV for storing VG metadata. Only applied when creating a new PV; cannot be changed afterwards. Choices:
|
|
Control if the physical volume exists. Choices:
|
|
List of tags that must be set on the PV. Tags present on the PV but not listed here are removed; tags listed here but not yet present are added. Managed using |
|
Control whether the first 4 sectors of the device are wiped when creating the PV. Only applied when creating a new PV; has no effect on a PV that already exists. Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in |
|
Support: none |
Returns details on what has changed (or possibly needs changing in |
Notes
Note
Requires LVM2 utilities installed on the target system.
Device path must exist when creating a PV.
zero,metadatasize,dataalignment, andpvmetadatacopiesonly take effect when the PV is created; they are ignored for a PV that already exists.metadataignoredetection on an existing PV relies on comparing the number of metadata areas on the PV with the number in use, so it is only meaningful when the PV has at least one metadata area.
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
- name: Creating a physical volume with custom metadata layout
community.general.lvm_pv:
device: /dev/sdb
metadatasize: 128m
dataalignment: 1m
pvmetadatacopies: 2
- name: Creating a physical volume without wiping existing signatures and with no metadata areas
community.general.lvm_pv:
device: /dev/sdb
zero: false
pvmetadatacopies: 0
- name: Setting tags and excluding a physical volume from allocation (PV must already be part of a VG)
community.general.lvm_pv:
device: /dev/sdb
allocatable: false
tags:
- fast_disks
- site_a