概述
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":