parted – Configure block device partitions¶
Synopsis¶
- 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.
Requirements¶
The below requirements are needed on the host that executes this module.
- This module requires parted version 1.8.3 and above.
- If the version of parted is below 3.1, it requires a Linux version running the sysfs file system
/sys/
.
Parameters¶
Notes¶
Note
- When fetching information about a new disk and when the version of parted installed on the system is before version 3.1, the module queries the kernel through
/sys/
to obtain disk information. In this case the units CHS and CYL are not supported.
Examples¶
- name: Create a new primary partition
parted:
device: /dev/sdb
number: 1
state: present
- name: Remove partition number 1
parted:
device: /dev/sdb
number: 1
state: absent
- name: Create a new primary partition with a size of 1GiB
parted:
device: /dev/sdb
number: 1
state: present
part_end: 1GiB
- name: Create a new primary partition for LVM
parted:
device: /dev/sdb
number: 2
flags: [ lvm ]
state: present
part_start: 1GiB
# Example on how to read info and reuse it in subsequent task
- name: Read device information (always use unit when probing)
parted: device=/dev/sdb unit=MiB
register: sdb_info
- name: Remove all partitions from disk
parted:
device: /dev/sdb
number: '{{ item.num }}'
state: absent
loop: '{{ sdb_info.partitions }}'
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Status¶
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors¶
- Fabrizio Colonna (@ColOfAbRiX)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.