概述
This module creates, removes or resizes logical volumes.
创建、删除逻辑卷以及动态改变逻辑卷大小。
常用模块
vg : The volume group this logical volume is part of.
在哪个卷组上创建lv
lv : The name of the logical volume
逻辑卷名
size : The size of the logical volume, according to lvcreate(8) --size, by default in megabytes or optionally with one of [bBsSkKmMgGtTpPeE] units; or according to lvcreate(8) --extents as a percentage of [VG|PVS|FREE]; Float values must begin with a digit. Resizing using percentage values was not supported prior to 2.1.
逻辑卷大小,默认单位是M。
pvs : Comma separated list of physical volumes (e.g. /dev/sda,/dev/sdb)
指定物理卷
force : Shrink or remove operations of volumes requires this switch. Ensures that that filesystems get never corrupted/destroyed by mistake.[Default: no]
默认不允许缩小和删除lv操作,如果一定要执行就force=yes
state : Control if the logical volume exists. If present’ and the volume does not already exist then the size’ option is required. (Choices: absent, present)[Default: present]
模块状态,absent代表删除,present代表新建,默认是present。
active : Whether the volume is activate and visible to the host
卷是否已激活并且对主机可见
示例
案例1:新建一个512m的逻辑卷
- name: Create a logical volume of 512m
lvol:
vg: firefly
lv: test
size: 512
[root@control ~]# ansible classroom -m lvol -a 'vg=firefly lv=test size=512'
classroom | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"msg": ""
}
[root@control ~]# ansible classroom -a 'lvscan'
classroom | CHANGED | rc=0 >>
ACTIVE '/dev/firefly/test' [512.00 MiB] inherit
ACTIVE '/dev/rhel/root' [<297.00 GiB] inherit
ACTIVE '/dev/rhel/swap' [2.00 GiB] inherit
案例2:用物理卷sdb1和sdb2新建一个512m的逻辑卷
- name: Create a logical volume of 512m with disks /dev/sdb1 and /dev/sdb2
lvol:
vg: firefly
lv: test
size: 512
pvs: /dev/sdb1,/dev/sdb2
[root@control ~]# ansible classroom -m lvol -a 'vg=firefly lv=test size=512 pvs=/dev/sdb1,/dev/sdb2'
classroom | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"msg": ""
}
案例3:新建一个512k的逻辑卷
- name: Create a logical volume of 512g.
lvol:
vg: firefly
lv: test