Documentation ¶
Overview ¶
The chroot package is able to create an Amazon AMI without requiring the launch of a new instance for every build. It does this by attaching and mounting the root volume of another AMI and chrooting into that directory. It then creates an AMI from that attached drive.
Index ¶
- Constants
- func AvailableDevice() (string, error)
- func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ictx interpolate.Context, ...) error
- func ShellCommand(command string) *exec.Cmd
- type Builder
- type Cleanup
- type CommandWrapper
- 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 *packer.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 Config
- type StepAttachVolume
- type StepCheckRootDevice
- type StepChrootProvision
- type StepCopyFiles
- type StepCreateVolume
- type StepEarlyCleanup
- type StepEarlyUnflock
- type StepFlock
- type StepInstanceInfo
- type StepMountDevice
- type StepMountExtra
- type StepPostMountCommands
- type StepPreMountCommands
- type StepPrepareDevice
- type StepRegisterAMI
- type StepSnapshot
Constants ¶
const BuilderId = "mitchellh.amazon.chroot"
The unique ID for this builder
const LOCK_EX = 2
See: http://linux.die.net/include/sys/file.h
const LOCK_NB = 4
const LOCK_UN = 8
Variables ¶
This section is empty.
Functions ¶
func AvailableDevice ¶
AvailableDevice finds an available device and returns it. Note that you should externally hold a flock or something in order to guarantee that this device is available across processes.
func RunLocalCommands ¶ added in v0.11.0
func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ictx interpolate.Context, ui packer.Ui) error
func ShellCommand ¶ added in v0.3.9
ShellCommand takes a command string and returns an *exec.Cmd to execute it within the context of a shell (/bin/sh).
Types ¶
type CommandWrapper ¶ added in v0.3.9
CommandWrapper is a type that given a command, will possibly modify that command in-flight. This might return an error.
type Communicator ¶
type Communicator struct { Chroot string CmdWrapper CommandWrapper }
Communicator is a special communicator that works by executing commands locally but within a chroot.
func (*Communicator) DownloadDir ¶ added in v0.9.0
func (c *Communicator) DownloadDir(src string, dst string, exclude []string) error
type Config ¶
type Config struct { common.PackerConfig `mapstructure:",squash"` awscommon.AMIBlockDevices `mapstructure:",squash"` awscommon.AMIConfig `mapstructure:",squash"` awscommon.AccessConfig `mapstructure:",squash"` ChrootMounts [][]string `mapstructure:"chroot_mounts"` CommandWrapper string `mapstructure:"command_wrapper"` CopyFiles []string `mapstructure:"copy_files"` DevicePath string `mapstructure:"device_path"` NVMEDevicePath string `mapstructure:"nvme_device_path"` FromScratch bool `mapstructure:"from_scratch"` MountOptions []string `mapstructure:"mount_options"` MountPartition string `mapstructure:"mount_partition"` MountPath string `mapstructure:"mount_path"` PostMountCommands []string `mapstructure:"post_mount_commands"` PreMountCommands []string `mapstructure:"pre_mount_commands"` RootDeviceName string `mapstructure:"root_device_name"` RootVolumeSize int64 `mapstructure:"root_volume_size"` RootVolumeType string `mapstructure:"root_volume_type"` SourceAmi string `mapstructure:"source_ami"` SourceAmiFilter awscommon.AmiFilterOptions `mapstructure:"source_ami_filter"` RootVolumeTags awscommon.TagMap `mapstructure:"root_volume_tags"` Architecture string `mapstructure:"ami_architecture"` // contains filtered or unexported fields }
Config is the configuration that is chained through the steps and settable from the template.
type StepAttachVolume ¶
type StepAttachVolume struct {
// contains filtered or unexported fields
}
StepAttachVolume attaches the previously created volume to an available device location.
Produces:
device string - The location where the volume was attached. attach_cleanup CleanupFunc
func (*StepAttachVolume) Cleanup ¶
func (s *StepAttachVolume) Cleanup(state multistep.StateBag)
func (*StepAttachVolume) CleanupFunc ¶
func (s *StepAttachVolume) CleanupFunc(state multistep.StateBag) error
func (*StepAttachVolume) Run ¶
func (s *StepAttachVolume) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCheckRootDevice ¶ added in v0.6.1
type StepCheckRootDevice struct{}
StepCheckRootDevice makes sure the root device on the AMI is EBS-backed.
func (*StepCheckRootDevice) Cleanup ¶ added in v0.6.1
func (s *StepCheckRootDevice) Cleanup(multistep.StateBag)
func (*StepCheckRootDevice) Run ¶ added in v0.6.1
func (s *StepCheckRootDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
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 {
// 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 StepCreateVolume ¶
type StepCreateVolume struct { RootVolumeSize int64 RootVolumeType string RootVolumeTags awscommon.TagMap Ctx interpolate.Context // contains filtered or unexported fields }
StepCreateVolume creates a new volume from the snapshot of the root device of the AMI.
Produces:
volume_id string - The ID of the created volume
func (*StepCreateVolume) Cleanup ¶
func (s *StepCreateVolume) Cleanup(state multistep.StateBag)
func (*StepCreateVolume) Run ¶
func (s *StepCreateVolume) 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 StepEarlyUnflock ¶
type StepEarlyUnflock struct{}
StepEarlyUnflock unlocks the flock.
func (*StepEarlyUnflock) Cleanup ¶
func (s *StepEarlyUnflock) Cleanup(state multistep.StateBag)
func (*StepEarlyUnflock) Run ¶
func (s *StepEarlyUnflock) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepFlock ¶
type StepFlock struct {
// contains filtered or unexported fields
}
StepFlock provisions the instance within a chroot.
Produces:
flock_cleanup Cleanup - To perform early cleanup
type StepInstanceInfo ¶
type StepInstanceInfo struct{}
StepInstanceInfo verifies that this builder is running on an EC2 instance.
func (*StepInstanceInfo) Cleanup ¶
func (s *StepInstanceInfo) Cleanup(multistep.StateBag)
func (*StepInstanceInfo) Run ¶
func (s *StepInstanceInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepMountDevice ¶
type StepMountDevice struct { MountOptions []string MountPartition string // contains filtered or unexported fields }
StepMountDevice mounts the attached device.
Produces:
mount_path string - The location where the volume was mounted. mount_device_cleanup CleanupFunc - To perform early cleanup
func (*StepMountDevice) Cleanup ¶
func (s *StepMountDevice) Cleanup(state multistep.StateBag)
func (*StepMountDevice) CleanupFunc ¶
func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error
func (*StepMountDevice) Run ¶
func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepMountExtra ¶
type StepMountExtra struct {
// 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 ¶ added in v0.11.0
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 ¶ added in v0.11.0
func (s *StepPostMountCommands) Cleanup(state multistep.StateBag)
func (*StepPostMountCommands) Run ¶ added in v0.11.0
func (s *StepPostMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepPreMountCommands ¶ added in v0.11.0
type StepPreMountCommands struct {
Commands []string
}
StepPreMountCommands sets up the a new block device when building from scratch
func (*StepPreMountCommands) Cleanup ¶ added in v0.11.0
func (s *StepPreMountCommands) Cleanup(state multistep.StateBag)
func (*StepPreMountCommands) Run ¶ added in v0.11.0
func (s *StepPreMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepPrepareDevice ¶
type StepPrepareDevice struct { }
StepPrepareDevice finds an available device and sets it.
func (*StepPrepareDevice) Cleanup ¶
func (s *StepPrepareDevice) Cleanup(state multistep.StateBag)
func (*StepPrepareDevice) Run ¶
func (s *StepPrepareDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepRegisterAMI ¶
type StepRegisterAMI struct { RootVolumeSize int64 EnableAMIENASupport *bool EnableAMISriovNetSupport bool }
StepRegisterAMI creates the AMI.
func (*StepRegisterAMI) Cleanup ¶
func (s *StepRegisterAMI) Cleanup(state multistep.StateBag)
func (*StepRegisterAMI) Run ¶
func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepSnapshot ¶
type StepSnapshot struct {
// contains filtered or unexported fields
}
StepSnapshot creates a snapshot of the created volume.
Produces:
snapshot_id string - ID of the created snapshot
func (*StepSnapshot) Cleanup ¶
func (s *StepSnapshot) Cleanup(state multistep.StateBag)
func (*StepSnapshot) Run ¶
func (s *StepSnapshot) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
Source Files ¶
- builder.go
- cleanup.go
- command.go
- communicator.go
- copy_files.go
- device.go
- lockfile_unix.go
- run_local_commands.go
- step_attach_volume.go
- step_check_root_device.go
- step_chroot_provision.go
- step_copy_files.go
- step_create_volume.go
- step_early_cleanup.go
- step_early_unflock.go
- step_flock.go
- step_instance_info.go
- step_mount_device.go
- step_mount_extra.go
- step_post_mount_commands.go
- step_pre_mount_commands.go
- step_prepare_device.go
- step_register_ami.go
- step_snapshot.go