propellor-2.15.3: 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.

Synopsis

Partition specification

Properties

imageBuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> Finalization -> [PartSpec] -> RevertableProperty HasInfo 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"]
	& User.hasPassword (User "root")
	& User.accountFor (User "demo")
 	& User.hasPassword (User "demo")
	& User.hasDesktopGroups (User "demo")
 	& ...
 in imageBuilt "/srv/images/foo.img" chroot
	MSDOS (grubBooted PC)
	[ partition EXT2 `mountedAt` "/boot"
		`setFlag` BootFlag
	, partition EXT4 `mountedAt` "/"
		`addFreeSpace` MegaBytes 100
		`mountOpt` errorReadonly
	, swapPartition (MegaBytes 256)
	]

Note that the disk image file is reused if it already exists, to avoid expensive IO to generate a new one. And, it's updated in-place, so its contents are undefined during the build process.

Note that the noServices property is automatically added to the chroot while the disk image is being built, which should prevent any daemons that are included from being started on the system that is building the disk image.

imageRebuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> Finalization -> [PartSpec] -> RevertableProperty HasInfo 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 -> Finalization -> [PartSpec] -> RevertableProperty NoInfo Source

Builds a disk image from the contents of a chroot.

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.

Finalization

type Finalization = (Property NoInfo, FilePath -> [LoopDev] -> 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 run after the disk image is created, with its populated partition tree mounted in the provided location from the provided loop devices. This will typically take care of installing the boot loader to the image.

It's ok if the second property leaves additional things mounted in the partition tree.

grubBooted :: BIOS -> Finalization Source

Makes grub be the boot loader of the disk image.

data BIOS Source

Types of machines that grub can boot.

Constructors

PC 
EFI64 
EFI32 
Coreboot 
Xen