propellor-4.7.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.

Synopsis

Partition specification

Properties

imageBuilt :: DiskImage -> (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 "foo.example.com" $ props
 	& imageBuilt "/srv/diskimages/disk.img" mychroot
		MSDOS
		[ partition EXT2 `mountedAt` "/boot"
			`setFlag` BootFlag
		, partition EXT4 `mountedAt` "/"
			`addFreeSpace` MegaBytes 100
			`mountOpt` errorReadonly
		, swapPartition (MegaBytes 256)
		]
  where
	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 "foo.example.com" $ props
	& imageBuilt "/srv/diskimages/bar-disk.img"
		(hostChroot bar (Debootstrapped mempty))
		MSDOS
		[ partition EXT2 `mountedAt` "/boot"
			`setFlag` BootFlag
		, partition EXT4 `mountedAt` "/"
			`addFreeSpace` MegaBytes 5000
		, swapPartition (MegaBytes 256)
		]

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

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

Builds a disk image from the contents of a chroot.

imageExists :: FilePath -> 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.

vmdkBuiltFor :: FilePath -> RevertableProperty DebianLike UnixLike Source #

Builds a VirtualBox .vmdk file for the specified disk image file.

data BIOS Source #

Types of machines that grub can boot.

Constructors

PC 
EFI64 
EFI32 
Coreboot 
Xen