propellor-2.10.0: property-based host configuration management in haskell

Safe HaskellNone
LanguageHaskell98

Propellor.Property.DiskImage

Contents

Description

Disk image generation.

This module is designed to be imported unqualified.

TODO run final

TODO avoid starting services while populating chroot and running final

Synopsis

Properties

imageBuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> [PartSpec] -> Finalization -> RevertableProperty Source

Creates a bootable disk image.

First the specified Chroot is set up, and its properties are satisfied.

Then, the disk image is set up, and the chroot is copied into the appropriate partition(s) of it.

Example use:

import Propellor.Property.DiskImage
 let chroot d = Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty d
 		& Apt.installed ["linux-image-amd64"]
		& ...
 in imageBuilt "/srv/images/foo.img" chroot MSDOS 
		[ partition EXT2 `mountedAt` "/boot"
			`setFlag` BootFlag
		, partition EXT4 `mountedAt` "/"
			`addFreeSpace` MegaBytes 100
		, swapPartition (MegaBytes 256)
		] (grubBooted PC)

imageRebuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> [PartSpec] -> Finalization -> RevertableProperty Source

Like built, but the chroot is deleted and rebuilt from scratch each time. This is more expensive, but useful to ensure reproducible results when the properties of the chroot have been changed.

imageBuiltFrom :: DiskImage -> FilePath -> TableType -> [PartSpec] -> Property NoInfo -> RevertableProperty Source

Builds a disk image from the contents of a chroot.

The passed property is run inside the mounted disk image.

imageExists :: FilePath -> ByteSize -> Property NoInfo Source

Ensures that a disk image file of the specified size exists.

If the file doesn't exist, or is too small, creates a new one, full of 0's.

If the file is too large, truncates it down to the specified size.

Partitioning

data Partition Source

A partition on the disk.

Instances

newtype PartSize Source

All partition sizing is done in megabytes, so that parted can automatically lay out the partitions.

Note that these are SI megabytes, not mebibytes.

Constructors

MegaBytes Integer 

data Fs Source

Filesystems etc that can be used for a partition.

Constructors

EXT2 
EXT3 
EXT4 
BTRFS 
REISERFS 
XFS 
FAT 
VFAT 
NTFS 
LinuxSwap 

Instances

type PartSpec = (MountPoint, PartSize -> Partition) Source

Specifies a mount point and a constructor for a Partition.

The size that is eventually provided is the amount of space needed to hold the files that appear in the directory where the partition is to be mounted. Plus a fudge factor, since filesystems have some space overhead.

(Partitions that are not to be mounted (ie, LinuxSwap), or that have no corresponding directory in the chroot will have 128 MegaBytes provided as a default size.)

type MountPoint = Maybe FilePath Source

Where a partition is mounted. Use Nothing for eg, LinuxSwap.

swapPartition :: PartSize -> PartSpec Source

Specifies a swap partition of a given size.

partition :: Fs -> PartSpec Source

Specifies a partition with a given filesystem.

The partition is not mounted anywhere by default; use the combinators below to configure it.

mountedAt :: PartSpec -> FilePath -> PartSpec Source

Specifies where to mount a partition.

addFreeSpace :: PartSpec -> PartSize -> PartSpec Source

Adds additional free space to the partition.

setSize :: PartSpec -> PartSize -> PartSpec Source

Forced a partition to be a specific size, instead of scaling to the size needed for the files in the chroot.

data PartFlag Source

Flags that can be set on a partition.

Instances

setFlag :: PartSpec -> PartFlag -> PartSpec Source

Sets a flag on the partition.

data TableType Source

Types of partition tables supported by parted.

Constructors

MSDOS 
GPT 
AIX 
AMIGA 
BSD 
DVH 
LOOP 
MAC 
PC98 
SUN 

Instances

extended :: PartSpec -> PartSpec Source

Makes a MSDOS partition be Extended, rather than Primary.

Finalization

type Finalization = (Property NoInfo, Property NoInfo) Source

A pair of properties. The first property is satisfied within the chroot, and is typically used to download the boot loader. The second property is satisfied chrooted into the resulting disk image, and will typically take care of installing the boot loader to the disk image.

grubBooted :: BIOS -> Finalization Source

Makes grub be the boot loader of the disk image. TODO not implemented

data BIOS Source

Types of machines that grub can boot.

Constructors

PC 
EFI64 
EFI32 
Coreboot 
Xen