New in version 2.3.
parted
command line tool. For a full description of the fields and the options check the GNU parted manual./sys/
.parameter | required | default | choices | comments |
---|---|---|---|---|
align | no | optimal |
| Set alignment for newly created partitions. |
device | yes | The block device (disk) where to operate. | ||
flags | no | A list of the flags that has to be set on the partition. | ||
label | no | msdos |
| Creates a new disk label. |
name | no | Sets the name for the partition number (GPT, Mac, MIPS and PC98 only). | ||
number | no | 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 | no | 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 | no | 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 | no | primary |
| 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 | no | info |
| If to create or delete a partition. If set to info the module will only return the device information. |
unit | no | KiB |
| 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. |
# 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 Return Values, the following are the fields unique to this module:
name | description | returned | type | sample | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
partition_info | Current partition information | success | complex | |||||||||||||||||||||
contains: |
|
Note
/sys/
to obtain disk information. In this case the units CHS and CYL are not supported.This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/parted_module.html