ansible parted模块详解

概述

This module allows configuring block device partition using the `parted’ command line tool. For a
full description of the fields and the options check the GNU parted manual.
磁盘分区和分区大小调整工具

常用模块

device : The block device (disk) where to operate
指定分区的介质

number : The number of the partition to work with or the number of the partition that will be created. Required when performing any action on the disk, except fetching information.
分区编号

part_end : Where the partition will end as offset from the beginning of the disk, that is, the “distance” from the start of the disk. The distance can be specified with all the units supported by parted (except compat) and it is case sensitive, e.g. 10GiB',15%’. [Default: 100%]
划分分区大小,指定分区结束位置。单位可以用百分制(%),也可以用传统的存储单位,默认结束位置是100%。

part_start : Where the partition will start as offset from the beginning of the disk, that is, the “distance” from the start of the disk. The distance can be specified with all the units supported by parted (except compat) and it is case sensitive, e.g. 10GiB',15%’. [Default: 0%]
划分分区大小,指定分区起始位置。单位可以用百分制(%),也可以用传统的存储单位,默认结束位置是0%。

state : Whether to create or delete a partition. If set to `info’ the module will only return the device information. (Choices: absent, present, info)[Default: info]
模块状态,absent代表删除分区,present代表新建分区,info代表查看信息,默认值是info。

unit : Selects the current default unit that Parted will use to display locations and capacities on the disk and to interpret those given by the user if they are not suffixed by an unit. When fetching information about a disk, it is always recommended to specify a unit. (Choices: s, B, KB, KiB, MB, MiB, GB, GiB, TB, TiB, %, cyl, chs, compact)[Default: KiB]
选择显示信息的存储单位,可以用s, B, KB, KiB, MB, MiB, GB, GiB, TB, TiB, %, cyl, chs, compact,KiB是默认单位。

flags : A list of the flags that has to be set on the partition
分区标记

示例

案例1:创建一个分区

- name: Create a new primary partition
  parted:
    device: /dev/sdb
    number: 1
    state: present
[root@control ~]# ansible classroom -m parted -a 'device=/dev/sdb number=1 state=present'
classroom | CHANGED => {
   
    "ansible_facts": {
   
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "disk": {
   
        "dev": "/dev/sdb",
        "logical_block": 512,
        "model": "VMware, VMware Virtual S",
        "physical_block": 512,
        "size": 10485760.0,
        "table": "msdos",
        "unit": "kib"
    },
    "partitions": [
        {
   
            "begin": 1024.0,
            "end": 10485760.0,
            "flags": [],
            "fstype": "",
            "name": "",
            "num": 1,
            "size": 10484736.0,
            "unit": "kib"
        }
    ],
    "script":
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值