community.general.lvol 模块 – 配置 LVM 逻辑卷
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。
要在 playbook 中使用它,请指定:community.general.lvol
。
概要
此模块创建、删除或调整逻辑卷的大小。
参数
参数 |
注释 |
---|---|
卷是否处于活动状态且对主机可见。 选择
|
|
卷的收缩或删除操作需要此开关。确保文件系统永远不会因错误而损坏/销毁。 选择
|
|
逻辑卷的名称。 |
|
要传递给 lvcreate 命令的自由格式选项。 |
|
物理卷列表(例如 |
|
调整底层文件系统以及逻辑卷的大小。 支持 选择
|
|
如果当前大小高于请求的大小,则缩小。 选择
|
|
逻辑卷的大小,根据 lvcreate(8) –size,默认单位为兆字节,或者可以选择使用 [bBsSkKmMgGtTpPeE] 单位之一;或者根据 lvcreate(8) –extents,以 [VG|PVS|FREE|ORIGIN] 的百分比表示;浮点值必须以数字开头。 调整大小时,除了指定绝对大小外,您还可以根据 lvextend(8)|lvreduce(8) 在 community.general 3.0.0 之前不支持使用 请注意,当使用 |
|
要配置的快照卷的名称。创建快照卷时, |
|
精简池卷名称。当您要创建精简配置卷时,请指定精简池卷名称。 |
|
此逻辑卷所属的卷组。 |
属性
属性 |
支持 |
描述 |
---|---|---|
支持: 完整 |
可以在 |
|
支持: 无 |
在 diff 模式下,将返回有关已更改(或可能需要在 |
注释
注意
您必须指定 lv(当管理逻辑卷的状态时)或 thinpool(当管理精简配置卷时)。
示例
- name: Create a logical volume of 512m
community.general.lvol:
vg: firefly
lv: test
size: 512
- 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
- name: Create cache pool logical volume
community.general.lvol:
vg: firefly
lv: lvcache
size: 512m
opts: --type cache-pool
- name: Create a logical volume of 512g.
community.general.lvol:
vg: firefly
lv: test
size: 512g
- 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
- name: Create a logical volume with special options
community.general.lvol:
vg: firefly
lv: test
size: 512g
opts: -r 16
- name: Extend the logical volume to 1024m.
community.general.lvol:
vg: firefly
lv: test
size: 1024
- name: Extend the logical volume to consume all remaining space in the volume group
community.general.lvol:
vg: firefly
lv: test
size: +100%FREE
- name: Extend the logical volume by given space
community.general.lvol:
vg: firefly
lv: test
size: +512M
- 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
- name: Resize the logical volume to % of VG
community.general.lvol:
vg: firefly
lv: test
size: 80%VG
force: true
- name: Reduce the logical volume to 512m
community.general.lvol:
vg: firefly
lv: test
size: 512
force: true
- name: Reduce the logical volume by given space
community.general.lvol:
vg: firefly
lv: test
size: -512M
force: true
- 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: false
- name: Remove the logical volume.
community.general.lvol:
vg: firefly
lv: test
state: absent
force: true
- name: Create a snapshot volume of the test logical volume.
community.general.lvol:
vg: firefly
lv: test
snapshot: snap1
size: 100m
- name: Deactivate a logical volume
community.general.lvol:
vg: firefly
lv: test
active: false
- name: Create a deactivated logical volume
community.general.lvol:
vg: firefly
lv: test
size: 512g
active: false
- name: Create a thin pool of 512g
community.general.lvol:
vg: firefly
thinpool: testpool
size: 512g
- name: Create a thin volume of 128g
community.general.lvol:
vg: firefly
lv: test
thinpool: testpool
size: 128g