builder/amazon-chroot: add mount_options configuration option
This commit is contained in:
parent
3884555007
commit
29cef0eae4
|
@ -35,6 +35,7 @@ type Config struct {
|
||||||
MountPath string `mapstructure:"mount_path"`
|
MountPath string `mapstructure:"mount_path"`
|
||||||
SourceAmi string `mapstructure:"source_ami"`
|
SourceAmi string `mapstructure:"source_ami"`
|
||||||
RootVolumeSize int64 `mapstructure:"root_volume_size"`
|
RootVolumeSize int64 `mapstructure:"root_volume_size"`
|
||||||
|
MountOptions []string `mapstructure:"mount_options"`
|
||||||
|
|
||||||
ctx interpolate.Context
|
ctx interpolate.Context
|
||||||
}
|
}
|
||||||
|
@ -165,7 +166,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
},
|
},
|
||||||
&StepAttachVolume{},
|
&StepAttachVolume{},
|
||||||
&StepEarlyUnflock{},
|
&StepEarlyUnflock{},
|
||||||
&StepMountDevice{},
|
&StepMountDevice{
|
||||||
|
MountOptions: b.config.MountOptions,
|
||||||
|
},
|
||||||
&StepMountExtra{},
|
&StepMountExtra{},
|
||||||
&StepCopyFiles{},
|
&StepCopyFiles{},
|
||||||
&StepChrootProvision{},
|
&StepChrootProvision{},
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
|
@ -23,7 +24,8 @@ type mountPathData struct {
|
||||||
// mount_path string - The location where the volume was mounted.
|
// mount_path string - The location where the volume was mounted.
|
||||||
// mount_device_cleanup CleanupFunc - To perform early cleanup
|
// mount_device_cleanup CleanupFunc - To perform early cleanup
|
||||||
type StepMountDevice struct {
|
type StepMountDevice struct {
|
||||||
mountPath string
|
mountPath string
|
||||||
|
MountOptions []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
|
@ -70,8 +72,15 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
|
|
||||||
ui.Say("Mounting the root device...")
|
ui.Say("Mounting the root device...")
|
||||||
stderr := new(bytes.Buffer)
|
stderr := new(bytes.Buffer)
|
||||||
|
|
||||||
|
// build mount options from mount_options config, usefull for nouuid options
|
||||||
|
// or other specific device type settings for mount
|
||||||
|
opts := ""
|
||||||
|
if len(s.MountOptions) > 0 {
|
||||||
|
opts = "-o " + strings.Join(s.MountOptions, " -o ")
|
||||||
|
}
|
||||||
mountCommand, err := wrappedCommand(
|
mountCommand, err := wrappedCommand(
|
||||||
fmt.Sprintf("mount %s %s", deviceMount, mountPath))
|
fmt.Sprintf("mount %s %s %s", opts, deviceMount, mountPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error creating mount command: %s", err)
|
err := fmt.Errorf("Error creating mount command: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
|
Loading…
Reference in New Issue