builder/amazon/chroot: can modify AMI attributes

This commit is contained in:
Mitchell Hashimoto 2013-08-08 22:52:39 -07:00
parent fd6dbc42d1
commit b4d18f9d30
1 changed files with 7 additions and 9 deletions

View File

@ -24,8 +24,8 @@ const BuilderId = "mitchellh.amazon.chroot"
type Config struct { type Config struct {
common.PackerConfig `mapstructure:",squash"` common.PackerConfig `mapstructure:",squash"`
awscommon.AccessConfig `mapstructure:",squash"` awscommon.AccessConfig `mapstructure:",squash"`
awscommon.AMIConfig `mapstructure:",squash"`
AMIName string `mapstructure:"ami_name"`
ChrootMounts [][]string `mapstructure:"chroot_mounts"` ChrootMounts [][]string `mapstructure:"chroot_mounts"`
CopyFiles []string `mapstructure:"copy_files"` CopyFiles []string `mapstructure:"copy_files"`
DevicePath string `mapstructure:"device_path"` DevicePath string `mapstructure:"device_path"`
@ -91,14 +91,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
// Accumulate any errors // Accumulate any errors
errs := common.CheckUnusedConfig(md) errs := common.CheckUnusedConfig(md)
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(b.config.tpl)...) errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(b.config.tpl)...)
errs = packer.MultiErrorAppend(errs, b.config.AMIConfig.Prepare(b.config.tpl)...)
if b.config.AMIName == "" {
errs = packer.MultiErrorAppend(
errs, errors.New("ami_name must be specified"))
} else if b.config.AMIName, err = b.config.tpl.Process(b.config.AMIName, nil); err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error processing ami_name: %s", err))
}
for i, mounts := range b.config.ChrootMounts { for i, mounts := range b.config.ChrootMounts {
if len(mounts) != 3 { if len(mounts) != 3 {
@ -195,6 +188,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&StepEarlyCleanup{}, &StepEarlyCleanup{},
&StepSnapshot{}, &StepSnapshot{},
&StepRegisterAMI{}, &StepRegisterAMI{},
&awscommon.StepModifyAMIAttributes{
Description: b.config.AMIDescription,
Users: b.config.AMIUsers,
Groups: b.config.AMIGroups,
},
} }
// Run! // Run!