ansible常用模块之 -- lvol模块 – 配置LVM逻辑卷

ansible常用模块之 -- lvol模块 – 配置LVM逻辑卷

lvol模块 – 配置LVM逻辑卷

一、摘要

  • 该模块创建、删除或调整逻辑卷的大小。

二、参数

参数选项/默认值描述
active
boolean
· yes ←
· no
卷是否处于激活状态且对主机可见。
force
boolean
· no ←
· yes
卷的收缩或删除操作需要此开关。确保文件系统不会被错误损坏/破坏
lv逻辑卷的名称。
opts传递给lvcreate命令的自由形式选项。
pvs物理卷的逗号分隔列表(例如/dev/sda,/dev/sdb)。
resizefs
boolean
· no ←
· yes
与逻辑卷一起调整底层文件系统的大小
shrink
boolean
· yes ←
· no
如果当前尺寸大于要求的尺寸,则收缩。
size逻辑卷的大小,根据lvcreate(8) --size,默认情况下以兆为单位,或可选使用[bBsSkKmMgGtTpPeE]单位之一;或者根据lvcreate(8) --extent作为[VG
snapshot快照卷的名称
state· present ←
· absent
控件是否存在逻辑卷。如果 present 且卷不存在,则需要使用 size 选项。
thinpool精简池卷名称。创建精简卷时,需要指定精简池卷名称。
vg逻辑卷所在的卷组。

三、示例

# 创建512m的逻辑卷
- name: Create a logical volume of 512m
  lvol:
    vg: firefly
    lv: test
    size: 512

# 使用/dev/sda和/dev/sdb创建512m的逻辑卷
- name: 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

# 创建缓存池逻辑卷
- name: Create cache pool logical volume
  lvol:
    vg: firefly
    lv: lvcache
    size: 512m
    opts: --type cache-pool

# 创建512g的逻辑卷。
- name: Create a logical volume of 512g.
  lvol:
    vg: firefly
    lv: test
    size: 512g

# 创建一个逻辑卷,大小为卷组中所有剩余空间的大小
- name: Create a logical volume the size of all remaining space in the volume group
  lvol:
    vg: firefly
    lv: test
    size: 100%FREE

# 创建具有特殊选项的逻辑卷
- name: Create a logical volume with special options
  lvol:
    vg: firefly
    lv: test
    size: 512g
    opts: -r 16

# 将逻辑卷扩展到1024m。
- name: Extend the logical volume to 1024m.
  lvol:
    vg: firefly
    lv: test
    size: 1024

# 扩展逻辑卷以占用卷组中所有剩余空间
- name: Extend the logical volume to consume all remaining space in the volume group
  lvol:
    vg: firefly
    lv: test
    size: +100%FREE

# 扩展逻辑卷以占用pv的所有剩余空间,并调整底层文件系统的大小
- name: Extend the logical volume to take all remaining space of the PVs and resize the underlying filesystem
  lvol:
    vg: firefly
    lv: test
    size: 100%PVS
    resizefs: true

# 将逻辑卷大小调整为VG的%
- name: Resize the logical volume to % of VG
  lvol:
    vg: firefly
    lv: test
    size: 80%VG
    force: yes

# 将逻辑卷缩小到512m
- name: Reduce the logical volume to 512m
  lvol:
    vg: firefly
    lv: test
    size: 512
    force: yes

# 将逻辑卷设置为512m,如果小于当前大小,请不要尝试收缩
- name: 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

# 删除逻辑卷。
- name: Remove the logical volume.
  lvol:
    vg: firefly
    lv: test
    state: absent
    force: yes

# 为测试逻辑卷创建快照卷。
- name: Create a snapshot volume of the test logical volume.
  lvol:
    vg: firefly
    lv: test
    snapshot: snap1
    size: 100m

# 取消激活逻辑卷
- name: Deactivate a logical volume
  lvol:
    vg: firefly
    lv: test
    active: false

# 创建去激活的逻辑卷
- name: Create a deactivated logical volume
  lvol:
    vg: firefly
    lv: test
    size: 512g
    active: false

# 创建512g的精简池
- name: Create a thin pool of 512g
  lvol:
    vg: firefly
    thinpool: testpool
    size: 512g

# 创建128g的精简卷
- name: Create a thin volume of 128g
  lvol:
    vg: firefly
    lv: test
    thinpool: testpool
    size: 128g

官方文档:https://docs.ansible.com/ansible/2.9/modules/lvol_module.html#lvol-module

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值