ansible lvol模块详解

概述

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
	
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值