Add mount_partition to amazon-chroot builder to specify a partition other than 1
This commit is contained in:
parent
d507b18eb4
commit
09543fc4e7
|
@ -37,6 +37,7 @@ type Config struct {
|
|||
SourceAmi string `mapstructure:"source_ami"`
|
||||
RootVolumeSize int64 `mapstructure:"root_volume_size"`
|
||||
MountOptions []string `mapstructure:"mount_options"`
|
||||
MountPartition int `mapstructure:"mount_partition"`
|
||||
|
||||
ctx interpolate.Context
|
||||
}
|
||||
|
@ -97,6 +98,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
b.config.MountPath = "/mnt/packer-amazon-chroot-volumes/{{.Device}}"
|
||||
}
|
||||
|
||||
if b.config.MountPartition == 0 {
|
||||
b.config.MountPartition = 1
|
||||
}
|
||||
|
||||
// Accumulate any errors
|
||||
var errs *packer.MultiError
|
||||
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
||||
|
@ -169,7 +174,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&StepAttachVolume{},
|
||||
&StepEarlyUnflock{},
|
||||
&StepMountDevice{
|
||||
MountOptions: b.config.MountOptions,
|
||||
MountOptions: b.config.MountOptions,
|
||||
MountPartition: b.config.MountPartition,
|
||||
},
|
||||
&StepMountExtra{},
|
||||
&StepCopyFiles{},
|
||||
|
|
|
@ -24,7 +24,8 @@ type mountPathData struct {
|
|||
// mount_path string - The location where the volume was mounted.
|
||||
// mount_device_cleanup CleanupFunc - To perform early cleanup
|
||||
type StepMountDevice struct {
|
||||
MountOptions []string
|
||||
MountOptions []string
|
||||
MountPartition int
|
||||
|
||||
mountPath string
|
||||
}
|
||||
|
@ -67,7 +68,7 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
|
|||
log.Printf("Source image virtualization type is: %s", *image.VirtualizationType)
|
||||
deviceMount := device
|
||||
if *image.VirtualizationType == "hvm" {
|
||||
deviceMount = fmt.Sprintf("%s%d", device, 1)
|
||||
deviceMount = fmt.Sprintf("%s%d", device, s.MountPartition)
|
||||
}
|
||||
state.Put("deviceMount", deviceMount)
|
||||
|
||||
|
|
|
@ -133,6 +133,9 @@ builder.
|
|||
where the `.Device` variable is replaced with the name of the device where
|
||||
the volume is attached.
|
||||
|
||||
- `mount_partition` (integer) - The partition number containing the /
|
||||
partition. By default this is the first partition of the volume.
|
||||
|
||||
- `mount_options` (array of strings) - 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
|
||||
|
|
Loading…
Reference in New Issue