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

Safe HaskellNone




Disk image generation.

This module is designed to be imported unqualified.


Partition specification


class DiskImage d where Source #

Type class of disk image formats.

Minimal complete definition

rawDiskImage, describeDiskImage, buildDiskImage


rawDiskImage :: d -> RawDiskImage Source #

Get the location where the raw disk image should be stored.

describeDiskImage :: d -> String Source #

Describe the disk image (for display to the user)

buildDiskImage :: d -> RevertableProperty DebianLike Linux Source #

Convert the raw disk image file in the rawDiskImage location into the desired disk image format. For best efficiency, the raw disk imasge file should be left unchanged on disk.

newtype VirtualBoxPointer Source #

A virtualbox .vmdk file, which contains a pointer to the raw disk image. This can be built very quickly.

imageBuilt :: DiskImage d => d -> (FilePath -> Chroot) -> TableType -> [PartSpec ()] -> RevertableProperty (HasInfo + DebianLike) Linux 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.

The partitions default to being sized just large enough to fit the files from the chroot. You can use addFreeSpace to make them a bit larger than that, or setSize to use a fixed size.

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.

Example use:

 import Propellor.Property.DiskImage
 import Propellor.Property.Chroot
 foo = host "" $ props
 	& imageBuilt (RawDiskImage "/srv/diskimages/disk.img") mychroot
		[ partition EXT2 `mountedAt` "/boot"
			`setFlag` BootFlag
		, partition EXT4 `mountedAt` "/"
			`addFreeSpace` MegaBytes 100
			`mountOpt` errorReadonly
		, swapPartition (MegaBytes 256)
	mychroot d = debootstrapped mempty d $ props
		& osDebian Unstable X86_64
		& Apt.installed ["linux-image-amd64"]
		& Grub.installed PC
		& User.hasPassword (User "root")
		& User.accountFor (User "demo")
 		& User.hasPassword (User "demo")
		& User.hasDesktopGroups (User "demo")
 		& ...

This can also be used with hostChroot to build a disk image that has all the properties of a Host. For example:

 foo :: Host
 foo = host "" $ props
	& imageBuilt (RawDiskImage "/srv/diskimages/bar-disk.img")
		(hostChroot bar (Debootstrapped mempty))
		[ partition EXT2 `mountedAt` "/boot"
			`setFlag` BootFlag
		, partition EXT4 `mountedAt` "/"
			`addFreeSpace` MegaBytes 5000
		, swapPartition (MegaBytes 256)

 bar :: Host
 bar = host "" $ props
	& osDebian Unstable X86_64
	& Apt.installed ["linux-image-amd64"]
	& Grub.installed PC
	& hasPassword (User "root")

imageRebuilt :: DiskImage d => d -> (FilePath -> Chroot) -> TableType -> [PartSpec ()] -> RevertableProperty (HasInfo + DebianLike) Linux 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 d => d -> FilePath -> TableType -> Finalization -> [PartSpec ()] -> RevertableProperty (HasInfo + DebianLike) Linux Source #

Builds a disk image from the contents of a chroot.

imageExists :: RawDiskImage -> ByteSize -> Property Linux 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.

data BIOS Source #

Types of machines that grub can boot.