dandyrow.linux.disks role – Declare disk setup as code

Note

This role is part of the dandyrow.linux collection (version 2.6.0).

To install it use: ansible-galaxy collection install dandyrow.linux.

To use it in a playbook, specify: dandyrow.linux.disks.

Entry point main – Declare disk setup as code

Synopsis

  • Define disk layout as yaml to create partitions then format and mount them.

  • Disks can also be formatted and mounted without creating partitions.

  • Make sure if not partitoning disks don’t define part_number and only define one layout item.

  • If defining partitons make sure to include part_number for each list item or you may experience unexpected behaviour.

Parameters

Parameter

Comments

disks

list / elements=dictionary / required

List of disks to partition and / or format and mount.

dev_path

path / required

Target path to block device to operate on.

layout

list / elements=dictionary / required

Target layout of the specified disk.

To format and mount device without partitions leave part_number undefined.

Other part_ options which are defined will be ignored when part_number is not defined.

If multiple list items are specified without a part_number defined only the last item will end up applied.

force_format

boolean

If true, allows creation of filesystem on device already containing one.

Choices:

  • false ← (default)

  • true

fs_options

string

Options string to pass to mkfs during device formatting.

fs_type

string / required

Desired filesystem type of the device.

Required when partitions list is not set.

See community.general.filesystem for supported filesystems.

mount_boot

boolean

If true, will set the device to moount on system boot.

If false, it will store option noauto in fstab.

If noauto is specified in mount_options this will be ignored.

Choices:

  • false

  • true ← (default)

mount_dump

string

See fstab(5) for details about dump field.

Default: "0"

mount_options

string

Options to use when mounting.

Stored in fstab entry for the mount.

See fstab(5) for applicable options.

mount_passno

string

See fstab(5) for details about passno field.

Default: "0"

mount_path

path / required

Target path to mount formatted device to.

Parent directories will be created if they don’t already exist

Required if partitions list is not set.

mount_uuid

boolean

If true, use device’s UUID to mount it rather than dev path.

Mounting by UUID can be safer in case dev path changes for a particular disk.

Choices:

  • false ← (default)

  • true

part_align

string

Set alignment for newly created partitions.

Use undefined for parted default alignment.

Choices:

  • "cylinder"

  • "minimal"

  • "none"

  • "optimal" ← (default)

  • "undefined"

part_end

string

See community.general.parted docs for description.

Default: "100%"

part_flags

list / elements=string

List of flags to be set on the partition.

part_fs_type

string

Sets the filesystem type of the partition.

Unlike fs_type, this is not required.

part_label

string

Disk label type or partition table to use.

If device already contains a different label, it will be changed to label and any previous partitons will be lost. Therefore, USE AT YOUR OWN RISK! You have been warned.

Name must be specified for a gpt partition table.

Choices:

  • "six"

  • "amiga"

  • "bsd"

  • "dvh"

  • "gpt"

  • "loop"

  • "mac"

  • "msdos" ← (default)

  • "pc98"

  • "sun"

part_name

string

Sets name for partition number.

Only applicable to GPT, Mac, MIPS and PC98.

Required when part_label set to gpt.

part_number

integer

Number of the partition being affected.

Required when specifying partitions.

part_start

string

See community.general.parted docs for description.

Default: "0%"

part_type

string

May only be specified with part_label=msdos or part_label=dvh.

Choices:

  • "extended"

  • "logical"

  • "primary" ← (default)

part_unit

string

Unit which Parted will use to display capacities on disk.

Choices:

  • "s"

  • "B"

  • "KB"

  • "KiB" ← (default)

  • "MB"

  • "MiB"

  • "GB"

  • "GiB"

  • "TB"

  • "TiB"

  • "%"

  • "cyl"

  • "chs"

  • "compact"

resize

boolean

Resize existing partitions to match size specified by part_end.

And / or resize filesystem to fill device size.

Choices:

  • false ← (default)

  • true

Authors

  • Daniel Lowry (github.com/dandyrow)