chroot

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MPL-2.0, MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package chroot is able to create an Azure managed image without requiring the launch of a new virtual machine for every build. It does this by attaching and mounting the root disk and chrooting into that directory. It then creates a managed image from that attached disk.

Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.

Index

Constants

View Source
const BuilderId = "azure.chroot"

BuilderId is the unique ID for this builder

Variables

View Source
var DiskNotFoundError = errors.New("Disk not found")
View Source
var NewDiskAttacher = func(azureClient client.AzureClientSet) DiskAttacher {
	return &diskAttacher{
		azcli: azureClient,
	}
}

Functions

func CreateVMMetadataTemplateFunc

func CreateVMMetadataTemplateFunc() func(string) (string, error)

CreateVMMetadataTemplateFunc returns a template function that retrieves VM metadata. VM metadata is retrieved only once and reused for all executions of the function.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func (*Builder) ConfigSpec added in v1.5.0

func (b *Builder) ConfigSpec() hcldec.ObjectSpec

func (*Builder) Prepare

func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error)

func (*Builder) Run

func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error)

type Config

type Config struct {
	common.PackerConfig `mapstructure:",squash"`

	ClientConfig client.Config `mapstructure:",squash"`

	// When set to `true`, starts with an empty, unpartitioned disk. Defaults to `false`.
	FromScratch bool `mapstructure:"from_scratch"`
	// Either a managed disk resource ID or a publisher:offer:sku:version specifier for plaform image sources.
	Source string `mapstructure:"source" required:"true"`

	// How to run shell commands. This may be useful to set environment variables or perhaps run
	// a command with sudo or so on. This is a configuration template where the `.Command` variable
	// is replaced with the command to be run. Defaults to `{{.Command}}`.
	CommandWrapper string `mapstructure:"command_wrapper"`
	// A series of commands to execute after attaching the root volume and before mounting the chroot.
	// This is not required unless using `from_scratch`. If so, this should include any partitioning
	// and filesystem creation commands. The path to the device is provided by `{{.Device}}`.
	PreMountCommands []string `mapstructure:"pre_mount_commands"`
	// Options to supply the `mount` command when mounting devices. Each option will be prefixed with
	// `-o` and supplied to the `mount` command ran by Packer. Because this command is ran in a shell,
	// user discretion is advised. See this manual page for the `mount` command for valid file system specific options.
	MountOptions []string `mapstructure:"mount_options"`
	// The partition number containing the / partition. By default this is the first partition of the volume.
	MountPartition string `mapstructure:"mount_partition"`
	// The path where the volume will be mounted. This is where the chroot environment will be. This defaults
	// to `/mnt/packer-amazon-chroot-volumes/{{.Device}}`. This is a configuration template where the `.Device`
	// variable is replaced with the name of the device where the volume is attached.
	MountPath string `mapstructure:"mount_path"`
	// As `pre_mount_commands`, but the commands are executed after mounting the root device and before the
	// extra mount and copy steps. The device and mount path are provided by `{{.Device}}` and `{{.MountPath}}`.
	PostMountCommands []string `mapstructure:"post_mount_commands"`
	// This is a list of devices to mount into the chroot environment. This configuration parameter requires
	// some additional documentation which is in the "Chroot Mounts" section below. Please read that section
	// for more information on how to use this.
	ChrootMounts [][]string `mapstructure:"chroot_mounts"`
	// Paths to files on the running Azure instance that will be copied into the chroot environment prior to
	// provisioning. Defaults to `/etc/resolv.conf` so that DNS lookups work. Pass an empty list to skip copying
	// `/etc/resolv.conf`. You may need to do this if you're building an image that uses systemd.
	CopyFiles []string `mapstructure:"copy_files"`

	// The name of the temporary disk that will be created in the resource group of the VM that Packer is
	// running on. Will be generated if not set.
	TemporaryOSDiskName string `mapstructure:"temporary_os_disk_name"`
	// Try to resize the OS disk to this size on the first copy. Disks can only be englarged. If not specified,
	// the disk will keep its original size. Required when using `from_scratch`
	OSDiskSizeGB int32 `mapstructure:"os_disk_size_gb"`
	// The [storage SKU](https://docs.microsoft.com/en-us/rest/api/compute/disks/createorupdate#diskstorageaccounttypes)
	// to use for the OS Disk. Defaults to `Standard_LRS`.
	OSDiskStorageAccountType string `mapstructure:"os_disk_storage_account_type"`
	// The [cache type](https://docs.microsoft.com/en-us/rest/api/compute/images/createorupdate#cachingtypes)
	// specified in the resulting image and for attaching it to the Packer VM. Defaults to `ReadOnly`
	OSDiskCacheType string `mapstructure:"os_disk_cache_type"`
	// If set to `true`, leaves the temporary disk behind in the Packer VM resource group. Defaults to `false`
	OSDiskSkipCleanup bool `mapstructure:"os_disk_skip_cleanup"`

	// The image to create using this build.
	ImageResourceID string `mapstructure:"image_resource_id" required:"true"`
	// The [Hyper-V generation type](https://docs.microsoft.com/en-us/rest/api/compute/images/createorupdate#hypervgenerationtypes).
	// Defaults to `V1`.
	ImageHyperVGeneration string `mapstructure:"image_hyperv_generation"`
	// contains filtered or unexported fields
}

Config is the configuration that is chained through the steps and settable from the template.

func (*Config) FlatMapstructure added in v1.5.0

func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatConfig. FlatConfig is an auto-generated flat version of Config. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*Config) GetContext

func (c *Config) GetContext() interpolate.Context

GetContext implements ContextProvider to allow steps to use the config context for template interpolation

type DiskAttacher

type DiskAttacher interface {
	AttachDisk(ctx context.Context, disk string) (lun int32, err error)
	DiskPathForLun(lun int32) string
	WaitForDevice(ctx context.Context, i int32) (device string, err error)
	DetachDisk(ctx context.Context, disk string) (err error)
	WaitForDetach(ctx context.Context, diskID string) error
}

type FlatConfig added in v1.5.0

type FlatConfig struct {
	PackerBuildName          *string           `mapstructure:"packer_build_name" cty:"packer_build_name"`
	PackerBuilderType        *string           `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
	PackerDebug              *bool             `mapstructure:"packer_debug" cty:"packer_debug"`
	PackerForce              *bool             `mapstructure:"packer_force" cty:"packer_force"`
	PackerOnError            *string           `mapstructure:"packer_on_error" cty:"packer_on_error"`
	PackerUserVars           map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
	PackerSensitiveVars      []string          `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
	CloudEnvironmentName     *string           `mapstructure:"cloud_environment_name" required:"false" cty:"cloud_environment_name"`
	ClientID                 *string           `mapstructure:"client_id" cty:"client_id"`
	ClientSecret             *string           `mapstructure:"client_secret" cty:"client_secret"`
	ClientCertPath           *string           `mapstructure:"client_cert_path" cty:"client_cert_path"`
	ClientJWT                *string           `mapstructure:"client_jwt" cty:"client_jwt"`
	ObjectID                 *string           `mapstructure:"object_id" cty:"object_id"`
	TenantID                 *string           `mapstructure:"tenant_id" required:"false" cty:"tenant_id"`
	SubscriptionID           *string           `mapstructure:"subscription_id" cty:"subscription_id"`
	FromScratch              *bool             `mapstructure:"from_scratch" cty:"from_scratch"`
	Source                   *string           `mapstructure:"source" required:"true" cty:"source"`
	CommandWrapper           *string           `mapstructure:"command_wrapper" cty:"command_wrapper"`
	PreMountCommands         []string          `mapstructure:"pre_mount_commands" cty:"pre_mount_commands"`
	MountOptions             []string          `mapstructure:"mount_options" cty:"mount_options"`
	MountPartition           *string           `mapstructure:"mount_partition" cty:"mount_partition"`
	MountPath                *string           `mapstructure:"mount_path" cty:"mount_path"`
	PostMountCommands        []string          `mapstructure:"post_mount_commands" cty:"post_mount_commands"`
	ChrootMounts             [][]string        `mapstructure:"chroot_mounts" cty:"chroot_mounts"`
	CopyFiles                []string          `mapstructure:"copy_files" cty:"copy_files"`
	TemporaryOSDiskName      *string           `mapstructure:"temporary_os_disk_name" cty:"temporary_os_disk_name"`
	OSDiskSizeGB             *int32            `mapstructure:"os_disk_size_gb" cty:"os_disk_size_gb"`
	OSDiskStorageAccountType *string           `mapstructure:"os_disk_storage_account_type" cty:"os_disk_storage_account_type"`
	OSDiskCacheType          *string           `mapstructure:"os_disk_cache_type" cty:"os_disk_cache_type"`
	OSDiskSkipCleanup        *bool             `mapstructure:"os_disk_skip_cleanup" cty:"os_disk_skip_cleanup"`
	ImageResourceID          *string           `mapstructure:"image_resource_id" required:"true" cty:"image_resource_id"`
	ImageHyperVGeneration    *string           `mapstructure:"image_hyperv_generation" cty:"image_hyperv_generation"`
}

FlatConfig is an auto-generated flat version of Config. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatConfig) HCL2Spec added in v1.5.0

func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Config. This spec is used by HCL to read the fields of Config. The decoded values from this spec will then be applied to a FlatConfig.

type StepAttachDisk

type StepAttachDisk struct {
	// contains filtered or unexported fields
}

func (*StepAttachDisk) Cleanup

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

func (*StepAttachDisk) CleanupFunc

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

func (*StepAttachDisk) Run

type StepCreateImage

type StepCreateImage struct {
	ImageResourceID          string
	ImageOSState             string
	OSDiskStorageAccountType string
	OSDiskCacheType          string
	Location                 string
	// contains filtered or unexported fields
}

func (*StepCreateImage) Cleanup

func (*StepCreateImage) Cleanup(bag multistep.StateBag)

func (*StepCreateImage) Run

type StepCreateNewDisk

type StepCreateNewDisk struct {
	SubscriptionID, ResourceGroup, DiskName string
	DiskSizeGB                              int32  // optional, ignored if 0
	DiskStorageAccountType                  string // from compute.DiskStorageAccountTypes
	HyperVGeneration                        string

	Location      string
	PlatformImage *client.PlatformImage

	SourceDiskResourceID string

	SkipCleanup bool
}

func (StepCreateNewDisk) Cleanup

func (s StepCreateNewDisk) Cleanup(state multistep.StateBag)

func (StepCreateNewDisk) Run

type StepMountDevice

type StepMountDevice struct {
	MountOptions   []string
	MountPartition string
	MountPath      string
	// contains filtered or unexported fields
}

func (*StepMountDevice) Cleanup

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

func (*StepMountDevice) CleanupFunc

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

func (*StepMountDevice) Run

type StepVerifySourceDisk

type StepVerifySourceDisk struct {
	SubscriptionID       string
	SourceDiskResourceID string
	Location             string
}

func (StepVerifySourceDisk) Cleanup

func (s StepVerifySourceDisk) Cleanup(state multistep.StateBag)

func (StepVerifySourceDisk) Run

Jump to

Keyboard shortcuts

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