david_igou.armbian.disk_provision role – Apply a declarative partition layout to one block device and populate it from a source rootfs

Note

This role is part of the david_igou.armbian collection (version 0.0.5-alpha).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it use: ansible-galaxy collection install david_igou.armbian.

To use it in a playbook, specify: david_igou.armbian.disk_provision.

Entry point main – Apply a declarative partition layout to one block device and populate it from a source rootfs

Synopsis

  • Given one disk_provision_disk_binding (device + layout list), validates the layout, translates it to systemd-repart .repart.d/*.conf files, invokes systemd-repart against the device, populates the resulting filesystems by rsyncing `source` (default /), writes a generated /etc/fstab on the root partition referencing every mount by LABEL=, and unmounts.

  • Single-disk contract. Callers with multiple disks loop the role per disk binding.

  • Preserved partitions (preserve_on_reprovision: true with a matching label already present on the disk) are skipped at systemd-repart and excluded from rsync. Set `force: true` on the binding to bypass preserve idempotency.

  • Transport-agnostic. Knows nothing about netboot, PXE, boot modes, or what the rootfs will be used for.

Parameters

Parameter

Comments

disk_provision_disk_binding

dictionary / required

One entry from armbian_local_disks. Shape: {device, force?, fast_wipe?, layout: [partition_spec, …]}.

device

path / required

Whole-disk path, e.g. /dev/nvme0n1. WILL BE WIPED unless preserve rules apply.

fast_wipe

boolean

When true, issue `blkdiscard <device>` (full-device TRIM using the storage’s native chunk size) before systemd-repart, AND suppress mkfs.ext4’s per-block discard at format time (`-E nodiscard` via SYSTEMD_REPART_MKFS_OPTIONS_EXT4). Net effect: ~30x speedup on large NVMe (>200 GiB), no functional change on small disks. Set false for devices with broken TRIM firmware (some old eMMC) where blkdiscard hangs.

Choices:

  • false

  • true ← (default)

force

boolean

Bypass preserve_on_reprovision idempotency — destructively wipe preserved partitions too.

Choices:

  • false ← (default)

  • true

layout

list / elements=dictionary / required

format

string / required

Filesystem type.

Choices:

  • "vfat"

  • "ext4"

  • "xfs"

  • "btrfs"

  • "swap"

id

string / required

Unique within this layout. Drives the .repart.d filename ordering.

label

string

Filesystem label. Required if preserve_on_reprovision is true. Recommended otherwise (fstab references it).

mount

path

Absolute mount path written to /etc/fstab. Optional (e.g. swap has no mount).

mount_opts

string

fstab mount options. Defaults: ext4=’defaults,noatime’; vfat=’defaults,noatime’; swap=’sw’; xfs=’defaults,noatime’; btrfs=’defaults,noatime,compress=zstd’.

preserve_on_reprovision

boolean

If true and a partition with matching label already exists, skip wipe + exclude from rsync. Requires label.

Choices:

  • false ← (default)

  • true

size

string / required

Size string: <number>MiB|GiB|TiB, or ‘grow’ (exactly one ‘grow’ per disk).

type

string / required

GPT partition type purpose. systemd-repart resolves to the architecture-appropriate GUID.

Choices:

  • "esp"

  • "linux"

  • "root"

  • "var"

  • "home"

  • "srv"

  • "swap"

disk_provision_installed_marker

boolean

Write INSTALLED=true to /etc/armbian-image-release on the target to suppress armbian-resize-filesystem.

Choices:

  • false

  • true ← (default)

disk_provision_mount_dir_base

path

Base for per-device temporary mount points. Each device mounts under <base>/<device-basename>/.

Default: "/var/lib/armbian/disk_provision_mnt"

disk_provision_render_only

boolean

When true, render .repart.d configs and run validation, then return. Used by Layer 1 molecule test.

Choices:

  • false ← (default)

  • true

disk_provision_reset_identity

boolean

Zero /etc/machine-id and /var/lib/dbus/machine-id on the target. Default false because the typical caller (NFS-booted board copying its rootfs to local disk) wants the same machine-id across both boot modes — it’s the same machine. Set true when provisioning a disk for a *different* host than the source.

Choices:

  • false ← (default)

  • true

disk_provision_source

path

Source rootfs to rsync. Typically “/” when the role runs on a board copying its currently-mounted rootfs; can be any directory containing a populated Linux rootfs.

Default: "/"