diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 2cf0e4ece..f809ea219 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -274,6 +274,16 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &StepCreateOMI{ RootVolumeSize: b.config.RootVolumeSize, }, + &osccommon.StepUpdateOMIAttributes{ + AccountIds: b.config.OMIAccountIDs, + SnapshotAccountIds: b.config.SnapshotAccountIDs, + Ctx: b.config.ctx, + }, + &osccommon.StepCreateTags{ + Tags: b.config.OMITags, + SnapshotTags: b.config.SnapshotTags, + Ctx: b.config.ctx, + }, ) // Run! @@ -285,7 +295,19 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, rawErr.(error) } - return nil, nil + // If there are no OMIs, then just return + if _, ok := state.GetOk("omis"); !ok { + return nil, nil + } + + // Build the artifact and return it + artifact := &osccommon.Artifact{ + Omis: state.Get("omis").(map[string]string), + BuilderIdValue: BuilderId, + Config: clientConfig, + } + + return artifact, nil } func (b *Builder) Cancel() { diff --git a/builder/osc/chroot/builder_acc_test.go b/builder/osc/chroot/builder_acc_test.go index be28b3b76..df8256218 100644 --- a/builder/osc/chroot/builder_acc_test.go +++ b/builder/osc/chroot/builder_acc_test.go @@ -24,10 +24,18 @@ const testBuilderAccBasic = ` "type": "test", "region": "eu-west-2", "source_omi": "ami-99466096", - "omi_name": "packer-test {{timestamp}}", + "omi_name": "packer-test-{{timestamp}}", "omi_virtualization_type": "hvm", "device_path": "/dev/xvdf", "mount_partition": "0" - }] + }], + "provisioners": [ + { + "type": "shell", + "inline": [ + "echo Packer-test | tee /tmp/test.txt" + ] + } + ] } ` diff --git a/builder/osc/chroot/step_check_root_device.go b/builder/osc/chroot/step_check_root_device.go index e251a1ff5..da73cb5e0 100644 --- a/builder/osc/chroot/step_check_root_device.go +++ b/builder/osc/chroot/step_check_root_device.go @@ -9,18 +9,18 @@ import ( "github.com/outscale/osc-go/oapi" ) -// StepCheckRootDevice makes sure the root device on the AMI is EBS-backed. +// StepCheckRootDevice makes sure the root device on the OMI is BSU-backed. type StepCheckRootDevice struct{} func (s *StepCheckRootDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { image := state.Get("source_image").(oapi.Image) ui := state.Get("ui").(packer.Ui) - ui.Say("Checking the root device on source AMI...") + ui.Say("Checking the root device on source OMI...") - // It must be EBS-backed otherwise the build won't work + // It must be BSU-backed otherwise the build won't work if image.RootDeviceType != "ebs" { - err := fmt.Errorf("The root device of the source AMI must be EBS-backed.") + err := fmt.Errorf("The root device of the source OMI must be BSU-backed.") state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt diff --git a/builder/osc/common/step_create_tags.go b/builder/osc/common/step_create_tags.go index e3cd317de..44bdcc78c 100644 --- a/builder/osc/common/step_create_tags.go +++ b/builder/osc/common/step_create_tags.go @@ -24,14 +24,14 @@ func (s *StepCreateTags) Run(_ context.Context, state multistep.StateBag) multis oapiconn := state.Get("oapi").(*oapi.Client) config := state.Get("clientConfig").(*oapi.Config) ui := state.Get("ui").(packer.Ui) - amis := state.Get("amis").(map[string]string) + omis := state.Get("omis").(map[string]string) if !s.Tags.IsSet() && !s.SnapshotTags.IsSet() { return multistep.ActionContinue } // Adds tags to OMIs and snapshots - for region, ami := range amis { + for region, ami := range omis { ui.Say(fmt.Sprintf("Adding tags to OMI (%s)...", ami)) newConfig := &oapi.Config{