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 ¶
- func RunLocalCommands(commands []string, wrappedCommand common.CommandWrapper, ...) error
- type Cleanup
- type Communicator
- func (c *Communicator) Download(src string, w io.Writer) error
- func (c *Communicator) DownloadDir(src string, dst string, exclude []string) error
- func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error
- func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error
- func (c *Communicator) UploadDir(dst string, src string, exclude []string) error
- type StepChrootProvision
- type StepCopyFiles
- type StepEarlyCleanup
- type StepMountExtra
- type StepPostMountCommands
- type StepPreMountCommands
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 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) DownloadDir ¶
func (c *Communicator) DownloadDir(src string, dst 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 ¶
func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
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 ¶
func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
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 ¶
func (s *StepEarlyCleanup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
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 ¶
func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
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 ¶
func (s *StepPostMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
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 ¶
func (s *StepPreMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction