chroot

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2021 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package chroot provides convenience tooling specific to chroot builders.

Chroot builders work by creating a new volume from an existing source image and attaching it into an already-running instance. Once attached, a chroot is used to provision the system within that volume. After provisioning, the volume is detached, snapshotted, and a cloud-specific image is made.

Using this process, minutes can be shaved off image build processes because a new instance doesn't need to be launched in the cloud before provisioning can take place.

There are some restrictions, however. The host instance where the volume is attached to must be a similar system (generally the same OS version, kernel versions, etc.) as the image being built. Additionally, this process is much more expensive because the instance used to perform the build must be kept running persistently in order to build images, whereas the other non-chroot cloud image builders start instances on-demand to build images as needed.

The HashiCorp-maintained Amazon and Azure builder plugins have chroot builders which use this option and can serve as an example for how the chroot steps and communicator are used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunLocalCommands

func RunLocalCommands(commands []string, wrappedCommand common.CommandWrapper, ictx interpolate.Context, ui packersdk.Ui) error

Types

type Cleanup

type Cleanup interface {
	CleanupFunc(multistep.StateBag) error
}

Cleanup is an interface that some steps implement for early cleanup.

type Communicator

type Communicator struct {
	Chroot     string
	CmdWrapper common.CommandWrapper
}

Communicator is a special communicator that works by executing commands locally but within a chroot.

func (*Communicator) Download

func (c *Communicator) Download(src string, w io.Writer) error

func (*Communicator) DownloadDir

func (c *Communicator) DownloadDir(src string, dst string, exclude []string) error

func (*Communicator) Start

func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error

func (*Communicator) Upload

func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error

func (*Communicator) UploadDir

func (c *Communicator) UploadDir(dst string, src string, exclude []string) error

type StepChrootProvision

type StepChrootProvision struct {
}

StepChrootProvision provisions the instance within a chroot.

func (*StepChrootProvision) Cleanup

func (s *StepChrootProvision) Cleanup(state multistep.StateBag)

func (*StepChrootProvision) Run

type StepCopyFiles

type StepCopyFiles struct {
	Files []string
	// contains filtered or unexported fields
}

StepCopyFiles copies some files from the host into the chroot environment.

Produces:

copy_files_cleanup CleanupFunc - A function to clean up the copied files
early.

func (*StepCopyFiles) Cleanup

func (s *StepCopyFiles) Cleanup(state multistep.StateBag)

func (*StepCopyFiles) CleanupFunc

func (s *StepCopyFiles) CleanupFunc(state multistep.StateBag) error

func (*StepCopyFiles) Run

type StepEarlyCleanup

type StepEarlyCleanup struct{}

StepEarlyCleanup performs some of the cleanup steps early in order to prepare for snapshotting and creating an AMI.

func (*StepEarlyCleanup) Cleanup

func (s *StepEarlyCleanup) Cleanup(state multistep.StateBag)

func (*StepEarlyCleanup) Run

type StepMountExtra

type StepMountExtra struct {
	ChrootMounts [][]string
	// contains filtered or unexported fields
}

StepMountExtra mounts the attached device.

Produces:

mount_extra_cleanup CleanupFunc - To perform early cleanup

func (*StepMountExtra) Cleanup

func (s *StepMountExtra) Cleanup(state multistep.StateBag)

func (*StepMountExtra) CleanupFunc

func (s *StepMountExtra) CleanupFunc(state multistep.StateBag) error

func (*StepMountExtra) Run

type StepPostMountCommands

type StepPostMountCommands struct {
	Commands []string
}

StepPostMountCommands allows running arbitrary commands after mounting the device, but prior to the bind mount and copy steps.

func (*StepPostMountCommands) Cleanup

func (s *StepPostMountCommands) Cleanup(state multistep.StateBag)

func (*StepPostMountCommands) Run

type StepPreMountCommands

type StepPreMountCommands struct {
	Commands []string
}

StepPreMountCommands sets up the a new block device when building from scratch

func (*StepPreMountCommands) Cleanup

func (s *StepPreMountCommands) Cleanup(state multistep.StateBag)

func (*StepPreMountCommands) Run

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL