community.general.lvg 模块 – 配置 LVM 卷组

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了这个集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general

要在 playbook 中使用它,请指定:community.general.lvg

概要

  • 此模块创建、删除或调整卷组的大小。

参数

参数

注释

force

布尔值

如果为 true,则允许删除包含逻辑卷的卷组。

选项

  • false ← (默认)

  • true

pesize

字符串

物理扩展的大小。 pesize 必须是至少 1 个扇区(其中扇区大小是 VG 中当前使用的 PV 的最大扇区大小)的 2 的幂,或者至少 128KiB。

pesize 可以选择性地附加一个单位 (k/K/m/M/g/G),默认单位是兆字节。

默认值: "4"

pv_options

字符串

创建卷组时传递给 pvcreate 的其他选项。

默认值: ""

pvresize

布尔值

在 community.general 0.2.0 中添加

如果为 true,则将物理卷调整到最大可用大小。

选项

  • false ← (默认)

  • true

pvs

列表 / 元素=字符串

用作此卷组中物理设备的逗号分隔设备列表。

创建或调整卷组大小时是必需的。

如果需要,该模块将负责运行 pvcreate。

reset_pv_uuid

布尔值

在 community.general 7.1.0 中添加

是否重新生成卷组的物理卷的 UUID。

这 **不是幂等的**。指定此参数总是会导致更改。

选项

  • false ← (默认)

  • true

reset_vg_uuid

布尔值

在 community.general 7.1.0 中添加

是否重新生成卷组的 UUID。

这 **不是幂等的**。指定此参数总是会导致更改。

选项

  • false ← (默认)

  • true

state

字符串

控制卷组是否存在及其状态。

状态 activeinactive 意味着 present 状态。在 7.1.0 中添加

如果为 activeinactive,则该模块管理 VG 的逻辑卷的当前状态。除非在创建卷组时和 vg_options 中指定的自动激活选项,否则该模块还会处理 VG 的自动激活状态(如果支持)。

选项

  • "absent"

  • "present" ← (默认)

  • "active"

  • "inactive"

vg

字符串 / 必需

卷组的名称。

vg_options

字符串

创建卷组时传递给 vgcreate 的其他选项。

默认值: ""

属性

属性

支持

描述

check_mode

支持: 完整

可以在 check_mode 中运行并返回已更改状态的预测,而无需修改目标。

diff_mode

支持:

当处于差异模式时,将返回有关已更改内容(或可能需要在 check_mode 中更改的内容)的详细信息。

说明

注意

  • 此模块不会修改已存在的卷组的 PE 大小。

另请参阅

另请参阅

community.general.filesystem

创建文件系统。

community.general.lvol

配置 LVM 逻辑卷。

community.general.parted

配置块设备分区。

示例

- name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
  community.general.lvg:
    vg: vg.services
    pvs: /dev/sda1
    pesize: 32

- name: Create a volume group on top of /dev/sdb with physical extent size = 128KiB
  community.general.lvg:
    vg: vg.services
    pvs: /dev/sdb
    pesize: 128K

# If, for example, we already have VG vg.services on top of /dev/sdb1,
# this VG will be extended by /dev/sdc5.  Or if vg.services was created on
# top of /dev/sda5, we first extend it with /dev/sdb1 and /dev/sdc5,
# and then reduce by /dev/sda5.
- name: Create or resize a volume group on top of /dev/sdb1 and /dev/sdc5.
  community.general.lvg:
    vg: vg.services
    pvs: /dev/sdb1,/dev/sdc5

- name: Remove a volume group with name vg.services
  community.general.lvg:
    vg: vg.services
    state: absent

- name: Create a volume group on top of /dev/sda3 and resize the volume group /dev/sda3 to the maximum possible
  community.general.lvg:
    vg: resizableVG
    pvs: /dev/sda3
    pvresize: true

- name: Deactivate a volume group
  community.general.lvg:
    state: inactive
    vg: vg.services

- name: Activate a volume group
  community.general.lvg:
    state: active
    vg: vg.services

- name: Reset a volume group UUID
  community.general.lvg:
    state: inactive
    vg: vg.services
    reset_vg_uuid: true

- name: Reset both volume group and pv UUID
  community.general.lvg:
    state: inactive
    vg: vg.services
    pvs: /dev/sdb1,/dev/sdc5
    reset_vg_uuid: true
    reset_pv_uuid: true

作者

  • Alexander Bulimov (@abulimov)