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.
Code generated by "mapstructure-to-hcl2 -type SharedImageGalleryDestination,TargetRegion"; DO NOT EDIT.
Index ¶
- Constants
- Variables
- func CreateVMMetadataTemplateFunc() func(string) (string, error)
- type Builder
- type Config
- type DiskAttacher
- type Diskset
- type FlatConfig
- type FlatSharedImageGalleryDestination
- type FlatTargetRegion
- type SharedImageGalleryDestination
- type StepAttachDisk
- type StepCreateImage
- type StepCreateNewDiskset
- type StepCreateSharedImageVersion
- type StepCreateSnapshotset
- type StepMountDevice
- type StepResolvePlatformImageVersion
- type StepVerifySharedImageDestination
- type StepVerifySharedImageSource
- type StepVerifySourceDisk
- type TargetRegion
Constants ¶
const BuilderID = "azure.chroot"
BuilderID is the unique ID for this builder
Variables ¶
var DiskNotFoundError = errors.New("Disk not found")
var NewDiskAttacher = func(azureClient client.AzureClientSet) DiskAttacher {
return &diskAttacher{
azcli: azureClient,
}
}
Functions ¶
func CreateVMMetadataTemplateFunc ¶
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
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"` // One of the following can be used as a source for an image: // - a shared image version resource ID // - a managed disk resource ID // - 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"` // 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"` // The [storage SKU](https://docs.microsoft.com/en-us/rest/api/compute/disks/createorupdate#diskstorageaccounttypes) // to use for datadisks. Defaults to `Standard_LRS`. DataDiskStorageAccountType string `mapstructure:"data_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` DataDiskCacheType string `mapstructure:"data_disk_cache_type"` // The [Hyper-V generation type](https://docs.microsoft.com/en-us/rest/api/compute/images/createorupdate#hypervgenerationtypes) for Managed Image output. // Defaults to `V1`. ImageHyperVGeneration string `mapstructure:"image_hyperv_generation"` // The id of the temporary OS disk that will be created. Will be generated if not set. TemporaryOSDiskID string `mapstructure:"temporary_os_disk_id"` // The id of the temporary OS disk snapshot that will be created. Will be generated if not set. TemporaryOSDiskSnapshotID string `mapstructure:"temporary_os_disk_snapshot_id"` // The prefix for the resource ids of the temporary data disks that will be created. The disks will be suffixed with a number. Will be generated if not set. TemporaryDataDiskIDPrefix string `mapstructure:"temporary_data_disk_id_prefix"` // The prefix for the resource ids of the temporary data disk snapshots that will be created. The snapshots will be suffixed with a number. Will be generated if not set. TemporaryDataDiskSnapshotIDPrefix string `mapstructure:"temporary_data_disk_snapshot_id"` // If set to `true`, leaves the temporary disks and snapshots behind in the Packer VM resource group. Defaults to `false` SkipCleanup bool `mapstructure:"skip_cleanup"` // The managed image to create using this build. ImageResourceID string `mapstructure:"image_resource_id"` SharedImageGalleryDestination SharedImageGalleryDestination `mapstructure:"shared_image_destination"` // 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
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 Diskset ¶ added in v1.6.0
Diskset represents all of the disks or snapshots associated with an image. It maps lun to resource ids. The OS disk is stored with lun=-1.
type FlatConfig ¶ added in v1.5.0
type FlatConfig struct { PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` CloudEnvironmentName *string `mapstructure:"cloud_environment_name" required:"false" cty:"cloud_environment_name" hcl:"cloud_environment_name"` ClientID *string `mapstructure:"client_id" cty:"client_id" hcl:"client_id"` ClientSecret *string `mapstructure:"client_secret" cty:"client_secret" hcl:"client_secret"` ClientCertPath *string `mapstructure:"client_cert_path" cty:"client_cert_path" hcl:"client_cert_path"` ClientJWT *string `mapstructure:"client_jwt" cty:"client_jwt" hcl:"client_jwt"` ObjectID *string `mapstructure:"object_id" cty:"object_id" hcl:"object_id"` TenantID *string `mapstructure:"tenant_id" required:"false" cty:"tenant_id" hcl:"tenant_id"` SubscriptionID *string `mapstructure:"subscription_id" cty:"subscription_id" hcl:"subscription_id"` FromScratch *bool `mapstructure:"from_scratch" cty:"from_scratch" hcl:"from_scratch"` Source *string `mapstructure:"source" required:"true" cty:"source" hcl:"source"` CommandWrapper *string `mapstructure:"command_wrapper" cty:"command_wrapper" hcl:"command_wrapper"` PreMountCommands []string `mapstructure:"pre_mount_commands" cty:"pre_mount_commands" hcl:"pre_mount_commands"` MountOptions []string `mapstructure:"mount_options" cty:"mount_options" hcl:"mount_options"` MountPartition *string `mapstructure:"mount_partition" cty:"mount_partition" hcl:"mount_partition"` MountPath *string `mapstructure:"mount_path" cty:"mount_path" hcl:"mount_path"` PostMountCommands []string `mapstructure:"post_mount_commands" cty:"post_mount_commands" hcl:"post_mount_commands"` ChrootMounts [][]string `mapstructure:"chroot_mounts" cty:"chroot_mounts" hcl:"chroot_mounts"` CopyFiles []string `mapstructure:"copy_files" cty:"copy_files" hcl:"copy_files"` OSDiskSizeGB *int32 `mapstructure:"os_disk_size_gb" cty:"os_disk_size_gb" hcl:"os_disk_size_gb"` OSDiskStorageAccountType *string `mapstructure:"os_disk_storage_account_type" cty:"os_disk_storage_account_type" hcl:"os_disk_storage_account_type"` OSDiskCacheType *string `mapstructure:"os_disk_cache_type" cty:"os_disk_cache_type" hcl:"os_disk_cache_type"` DataDiskStorageAccountType *string `mapstructure:"data_disk_storage_account_type" cty:"data_disk_storage_account_type" hcl:"data_disk_storage_account_type"` DataDiskCacheType *string `mapstructure:"data_disk_cache_type" cty:"data_disk_cache_type" hcl:"data_disk_cache_type"` ImageHyperVGeneration *string `mapstructure:"image_hyperv_generation" cty:"image_hyperv_generation" hcl:"image_hyperv_generation"` TemporaryOSDiskID *string `mapstructure:"temporary_os_disk_id" cty:"temporary_os_disk_id" hcl:"temporary_os_disk_id"` TemporaryOSDiskSnapshotID *string `mapstructure:"temporary_os_disk_snapshot_id" cty:"temporary_os_disk_snapshot_id" hcl:"temporary_os_disk_snapshot_id"` TemporaryDataDiskIDPrefix *string `mapstructure:"temporary_data_disk_id_prefix" cty:"temporary_data_disk_id_prefix" hcl:"temporary_data_disk_id_prefix"` TemporaryDataDiskSnapshotIDPrefix *string `mapstructure:"temporary_data_disk_snapshot_id" cty:"temporary_data_disk_snapshot_id" hcl:"temporary_data_disk_snapshot_id"` SkipCleanup *bool `mapstructure:"skip_cleanup" cty:"skip_cleanup" hcl:"skip_cleanup"` ImageResourceID *string `mapstructure:"image_resource_id" cty:"image_resource_id" hcl:"image_resource_id"` }
FlatConfig is an auto-generated flat version of Config. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatSharedImageGalleryDestination ¶ added in v1.5.6
type FlatSharedImageGalleryDestination struct {}
FlatSharedImageGalleryDestination is an auto-generated flat version of SharedImageGalleryDestination. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatSharedImageGalleryDestination) HCL2Spec ¶ added in v1.5.6
func (*FlatSharedImageGalleryDestination) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a SharedImageGalleryDestination. This spec is used by HCL to read the fields of SharedImageGalleryDestination. The decoded values from this spec will then be applied to a FlatSharedImageGalleryDestination.
type FlatTargetRegion ¶ added in v1.5.6
type FlatTargetRegion struct { Name *string `mapstructure:"name" required:"true" cty:"name" hcl:"name"` ReplicaCount *int32 `mapstructure:"replicas" cty:"replicas" hcl:"replicas"` StorageAccountType *string `mapstructure:"storage_account_type" cty:"storage_account_type" hcl:"storage_account_type"` }
FlatTargetRegion is an auto-generated flat version of TargetRegion. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type SharedImageGalleryDestination ¶ added in v1.5.6
type SharedImageGalleryDestination struct {}
SharedImageGalleryDestination models an image version in a Shared Image Gallery that can be used as a destination.
func (*SharedImageGalleryDestination) FlatMapstructure ¶ added in v1.5.6
func (*SharedImageGalleryDestination) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatSharedImageGalleryDestination. FlatSharedImageGalleryDestination is an auto-generated flat version of SharedImageGalleryDestination. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
func (SharedImageGalleryDestination) ResourceID ¶ added in v1.5.6
func (sigd SharedImageGalleryDestination) ResourceID(subscriptionID string) string
ResourceID returns the resource ID string
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 ¶
func (s *StepAttachDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCreateImage ¶
type StepCreateImage struct { ImageResourceID string ImageOSState string OSDiskStorageAccountType string OSDiskCacheType string DataDiskStorageAccountType string DataDiskCacheType string Location string }
func (*StepCreateImage) Cleanup ¶
func (*StepCreateImage) Cleanup(bag multistep.StateBag)
func (*StepCreateImage) Run ¶
func (s *StepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCreateNewDiskset ¶ added in v1.6.0
type StepCreateNewDiskset struct { OSDiskID string // Disk ID OSDiskSizeGB int32 // optional, ignored if 0 OSDiskStorageAccountType string // from compute.DiskStorageAccountTypes DataDiskStorageAccountType string // from compute.DiskStorageAccountTypes DataDiskIDPrefix string HyperVGeneration string // For OS disk // Copy another disk SourceOSDiskResourceID string // Extract from platform image SourcePlatformImage *client.PlatformImage // Extract from shared image SourceImageResourceID string // Location is needed for platform and shared images Location string SkipCleanup bool // contains filtered or unexported fields }
func (*StepCreateNewDiskset) Cleanup ¶ added in v1.6.0
func (s *StepCreateNewDiskset) Cleanup(state multistep.StateBag)
func (*StepCreateNewDiskset) Run ¶ added in v1.6.0
func (s *StepCreateNewDiskset) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCreateSharedImageVersion ¶ added in v1.5.6
type StepCreateSharedImageVersion struct {}
func (*StepCreateSharedImageVersion) Cleanup ¶ added in v1.5.6
func (*StepCreateSharedImageVersion) Cleanup(multistep.StateBag)
func (*StepCreateSharedImageVersion) Run ¶ added in v1.5.6
func (s *StepCreateSharedImageVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCreateSnapshotset ¶ added in v1.6.0
type StepCreateSnapshotset struct { OSDiskSnapshotID string DataDiskSnapshotIDPrefix string Location string SkipCleanup bool // contains filtered or unexported fields }
func (*StepCreateSnapshotset) Cleanup ¶ added in v1.6.0
func (s *StepCreateSnapshotset) Cleanup(state multistep.StateBag)
func (*StepCreateSnapshotset) Run ¶ added in v1.6.0
func (s *StepCreateSnapshotset) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
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 ¶
func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepResolvePlatformImageVersion ¶ added in v1.5.6
type StepResolvePlatformImageVersion struct { *client.PlatformImage Location string }
StepResolvePlatformImageVersion resolves the exact PIR version when the version is 'latest'
func (*StepResolvePlatformImageVersion) Cleanup ¶ added in v1.5.6
func (*StepResolvePlatformImageVersion) Cleanup(multistep.StateBag)
func (*StepResolvePlatformImageVersion) Run ¶ added in v1.5.6
func (pi *StepResolvePlatformImageVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
Run retrieves all available versions of a PIR image and stores the latest in the PlatformImage
type StepVerifySharedImageDestination ¶ added in v1.5.6
type StepVerifySharedImageDestination struct {}
StepVerifySharedImageDestination verifies that the shared image location matches the Location field in the step. Also verifies that the OS Type is Linux.
func (*StepVerifySharedImageDestination) Cleanup ¶ added in v1.5.6
func (*StepVerifySharedImageDestination) Cleanup(multistep.StateBag)
func (*StepVerifySharedImageDestination) Run ¶ added in v1.5.6
func (s *StepVerifySharedImageDestination) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
Run retrieves the image metadata from Azure and compares the location to Location. Verifies the OS Type.
type StepVerifySharedImageSource ¶ added in v1.5.6
type StepVerifySharedImageSource struct {}
StepVerifySharedImageSource verifies that the shared image location matches the Location field in the step. Also verifies that the OS Type is Linux.
func (*StepVerifySharedImageSource) Cleanup ¶ added in v1.5.6
func (*StepVerifySharedImageSource) Cleanup(multistep.StateBag)
func (*StepVerifySharedImageSource) Run ¶ added in v1.5.6
func (s *StepVerifySharedImageSource) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
Run retrieves the image metadata from Azure and compares the location to Location. Verifies the OS Type.
type StepVerifySourceDisk ¶
func (StepVerifySourceDisk) Cleanup ¶
func (s StepVerifySourceDisk) Cleanup(state multistep.StateBag)
func (StepVerifySourceDisk) Run ¶
func (s StepVerifySourceDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type TargetRegion ¶ added in v1.5.6
type TargetRegion struct { // Name of the Azure region Name string `mapstructure:"name" required:"true"` // Number of replicas in this region. Default: 1 ReplicaCount int32 `mapstructure:"replicas"` // Storage account type: Standard_LRS or Standard_ZRS. Default: Standard_ZRS StorageAccountType string `mapstructure:"storage_account_type"` }
TargetRegion describes a region where the shared image should be replicated
func (*TargetRegion) FlatMapstructure ¶ added in v1.5.6
func (*TargetRegion) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatTargetRegion. FlatTargetRegion is an auto-generated flat version of TargetRegion. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
Source Files ¶
- builder.go
- builder.hcl2spec.go
- const.go
- diskattacher.go
- diskattacher_linux.go
- diskset.go
- shared_image_gallery_destination.go
- shared_image_gallery_destination.hcl2spec.go
- step_attach_disk.go
- step_create_image.go
- step_create_new_diskset.go
- step_create_shared_image_version.go
- step_create_snapshotset.go
- step_mount_device.go
- step_resolve_plaform_image_version.go
- step_verify_shared_image_destination.go
- step_verify_shared_image_source.go
- step_verify_source_disk.go
- template_funcs.go