Merge pull request #6194 from hashicorp/fix_6176
allow user to mount entire block device in chroot builder
This commit is contained in:
commit
a8b6a04dda
|
@ -35,7 +35,7 @@ type Config struct {
|
||||||
DevicePath string `mapstructure:"device_path"`
|
DevicePath string `mapstructure:"device_path"`
|
||||||
FromScratch bool `mapstructure:"from_scratch"`
|
FromScratch bool `mapstructure:"from_scratch"`
|
||||||
MountOptions []string `mapstructure:"mount_options"`
|
MountOptions []string `mapstructure:"mount_options"`
|
||||||
MountPartition int `mapstructure:"mount_partition"`
|
MountPartition string `mapstructure:"mount_partition"`
|
||||||
MountPath string `mapstructure:"mount_path"`
|
MountPath string `mapstructure:"mount_path"`
|
||||||
PostMountCommands []string `mapstructure:"post_mount_commands"`
|
PostMountCommands []string `mapstructure:"post_mount_commands"`
|
||||||
PreMountCommands []string `mapstructure:"pre_mount_commands"`
|
PreMountCommands []string `mapstructure:"pre_mount_commands"`
|
||||||
|
@ -112,8 +112,8 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||||
b.config.MountPath = "/mnt/packer-amazon-chroot-volumes/{{.Device}}"
|
b.config.MountPath = "/mnt/packer-amazon-chroot-volumes/{{.Device}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.config.MountPartition == 0 {
|
if b.config.MountPartition == "" {
|
||||||
b.config.MountPartition = 1
|
b.config.MountPartition = "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accumulate any errors or warnings
|
// Accumulate any errors or warnings
|
||||||
|
|
|
@ -26,7 +26,7 @@ type mountPathData struct {
|
||||||
// mount_device_cleanup CleanupFunc - To perform early cleanup
|
// mount_device_cleanup CleanupFunc - To perform early cleanup
|
||||||
type StepMountDevice struct {
|
type StepMountDevice struct {
|
||||||
MountOptions []string
|
MountOptions []string
|
||||||
MountPartition int
|
MountPartition string
|
||||||
|
|
||||||
mountPath string
|
mountPath string
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,9 @@ func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multi
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceMount := device
|
deviceMount := device
|
||||||
if virtualizationType == "hvm" {
|
|
||||||
deviceMount = fmt.Sprintf("%s%d", device, s.MountPartition)
|
if virtualizationType == "hvm" && s.MountPartition != "0" {
|
||||||
|
deviceMount = fmt.Sprintf("%s%s", device, s.MountPartition)
|
||||||
}
|
}
|
||||||
state.Put("deviceMount", deviceMount)
|
state.Put("deviceMount", deviceMount)
|
||||||
|
|
||||||
|
|
|
@ -213,8 +213,10 @@ each category, the available configuration keys are alphabetized.
|
||||||
where the `.Device` variable is replaced with the name of the device where
|
where the `.Device` variable is replaced with the name of the device where
|
||||||
the volume is attached.
|
the volume is attached.
|
||||||
|
|
||||||
- `mount_partition` (number) - The partition number containing the
|
- `mount_partition` (string) - The partition number containing the
|
||||||
/ partition. By default this is the first partition of the volume.
|
/ partition. By default this is the first partition of the volume, (for
|
||||||
|
example, `xvda1`) but you can designate the entire block device by setting
|
||||||
|
`"mount_partition": "0"` in your config, which will mount `xvda` instead.
|
||||||
|
|
||||||
- `mount_options` (array of strings) - Options to supply the `mount` command
|
- `mount_options` (array of strings) - Options to supply the `mount` command
|
||||||
when mounting devices. Each option will be prefixed with `-o` and supplied
|
when mounting devices. Each option will be prefixed with `-o` and supplied
|
||||||
|
@ -291,9 +293,9 @@ each category, the available configuration keys are alphabetized.
|
||||||
This is most useful for selecting a daily distro build.
|
This is most useful for selecting a daily distro build.
|
||||||
|
|
||||||
You may set this in place of `source_ami` or in conjunction with it. If you
|
You may set this in place of `source_ami` or in conjunction with it. If you
|
||||||
set this in conjunction with `source_ami`, the `source_ami` will be added to
|
set this in conjunction with `source_ami`, the `source_ami` will be added to
|
||||||
the filter. The provided `source_ami` must meet all of the filtering criteria
|
the filter. The provided `source_ami` must meet all of the filtering criteria
|
||||||
provided in `source_ami_filter`; this pins the AMI returned by the filter,
|
provided in `source_ami_filter`; this pins the AMI returned by the filter,
|
||||||
but will cause Packer to fail if the `source_ami` does not exist.
|
but will cause Packer to fail if the `source_ami` does not exist.
|
||||||
|
|
||||||
- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)
|
- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)
|
||||||
|
|
Loading…
Reference in New Issue