New in version 2.3.
The below requirements are needed on the host that executes this module.
Parameter |
Choices/Defaults |
Comments |
---|---|---|
align
|
|
Set alignment for newly created partitions.
|
device
required |
|
The block device (disk) where to operate.
|
flags
|
|
A list of the flags that has to be set on the partition.
|
label
|
|
Creates a new disk label.
|
name
|
|
Sets the name for the partition number (GPT, Mac, MIPS and PC98 only).
|
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
|
Default:
100%
|
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% . |
part_start
|
Default:
0%
|
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% . |
part_type
|
|
Is one of 'primary', 'extended' or 'logical' and may be specified only with 'msdos' or 'dvh' partition tables. A name must be specified for a 'gpt' partition table. Neither part-type nor name may be used with a 'sun' partition table.
|
state
|
|
If to create or delete a partition. If set to
info the module will only return the device information. |
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.
|
Note
# Create a new primary partition
- parted:
device: /dev/sdb
number: 1
state: present
# Remove partition number 1
- parted:
device: /dev/sdb
number: 1
state: absent
# Create a new primary partition with a size of 1GiB
- parted:
device: /dev/sdb
number: 1
state: present
part_end: 1GiB
# Create a new primary partition for LVM
- parted:
device: /dev/sdb
number: 2
flags: [ lvm ]
state: present
part_start: 1GiB
# Read device information (always use unit when probing)
- parted: device=/dev/sdb unit=MiB
register: sdb_info
# Remove all partitions from disk
- parted:
device: /dev/sdb
number: "{{ item.num }}"
state: absent
with_items:
- "{{ sdb_info.partitions }}"
Common return values are documented here, the following are the fields unique to this module:
Key |
Returned |
Description |
---|---|---|
partition_info
complex
|
success |
Current partition information
|
device
dict
|
Generic device information.
|
|
sample
|
|
|
partitions
list
|
List of device partitions.
|
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Hint
If you notice any issues in this documentation you can edit this document to improve it.