diff --git a/builder/virtualbox/common/step_export.go b/builder/virtualbox/common/step_export.go index 26f587875..cf1bd18cf 100644 --- a/builder/virtualbox/common/step_export.go +++ b/builder/virtualbox/common/step_export.go @@ -21,6 +21,7 @@ type StepExport struct { OutputDir string ExportOpts []string SkipNatMapping bool + SkipExport bool } func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { @@ -28,6 +29,12 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) + // Skip export if requested + if s.SkipExport { + ui.Say("Skipping export of virtual machine...") + return multistep.ActionContinue + } + // Wait a second to ensure VM is really shutdown. log.Println("1 second timeout to ensure VM is really shutdown") time.Sleep(1 * time.Second) diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index b833c583b..abe32590c 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -39,16 +39,17 @@ type Config struct { BootCommand []string `mapstructure:"boot_command"` DiskSize uint `mapstructure:"disk_size"` - KeepRegistered bool `mapstructure:"keep_registered"` GuestAdditionsMode string `mapstructure:"guest_additions_mode"` GuestAdditionsPath string `mapstructure:"guest_additions_path"` - GuestAdditionsURL string `mapstructure:"guest_additions_url"` GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"` + GuestAdditionsURL string `mapstructure:"guest_additions_url"` GuestOSType string `mapstructure:"guest_os_type"` + HardDriveDiscard bool `mapstructure:"hard_drive_discard"` HardDriveInterface string `mapstructure:"hard_drive_interface"` HardDriveNonrotational bool `mapstructure:"hard_drive_nonrotational"` - HardDriveDiscard bool `mapstructure:"hard_drive_discard"` ISOInterface string `mapstructure:"iso_interface"` + KeepRegistered bool `mapstructure:"keep_registered"` + SkipExport bool `mapstructure:"skip_export"` VMName string `mapstructure:"vm_name"` ctx interpolate.Context @@ -268,6 +269,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe OutputDir: b.config.OutputDir, ExportOpts: b.config.ExportOpts.ExportOpts, SkipNatMapping: b.config.SSHSkipNatMapping, + SkipExport: b.config.SkipExport, }, } diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index 9cf63af2b..b7d42183e 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -142,6 +142,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe OutputDir: b.config.OutputDir, ExportOpts: b.config.ExportOpts.ExportOpts, SkipNatMapping: b.config.SSHSkipNatMapping, + SkipExport: b.config.SkipExport, }, } diff --git a/builder/virtualbox/ovf/config.go b/builder/virtualbox/ovf/config.go index 5987118cd..0151c3ca1 100644 --- a/builder/virtualbox/ovf/config.go +++ b/builder/virtualbox/ovf/config.go @@ -27,17 +27,18 @@ type Config struct { vboxcommon.VBoxVersionConfig `mapstructure:",squash"` BootCommand []string `mapstructure:"boot_command"` - SourcePath string `mapstructure:"source_path"` Checksum string `mapstructure:"checksum"` ChecksumType string `mapstructure:"checksum_type"` - TargetPath string `mapstructure:"target_path"` GuestAdditionsMode string `mapstructure:"guest_additions_mode"` GuestAdditionsPath string `mapstructure:"guest_additions_path"` - GuestAdditionsURL string `mapstructure:"guest_additions_url"` GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"` - VMName string `mapstructure:"vm_name"` - ImportOpts string `mapstructure:"import_opts"` + GuestAdditionsURL string `mapstructure:"guest_additions_url"` ImportFlags []string `mapstructure:"import_flags"` + ImportOpts string `mapstructure:"import_opts"` + SourcePath string `mapstructure:"source_path"` + TargetPath string `mapstructure:"target_path"` + VMName string `mapstructure:"vm_name"` + SkipExport bool `mapstructure:"skip_export"` ctx interpolate.Context } diff --git a/website/source/docs/builders/virtualbox-iso.html.md b/website/source/docs/builders/virtualbox-iso.html.md index bad944a7d..debbf6e29 100644 --- a/website/source/docs/builders/virtualbox-iso.html.md +++ b/website/source/docs/builders/virtualbox-iso.html.md @@ -271,6 +271,10 @@ builder. doesn't shut down in this time, it is an error. By default, the timeout is `5m`, or five minutes. +- `skip_export` (boolean) - Defaults to `false`. When enabled Packer will + skip export of the installed virtual machine. Only useful for some edge + use cases. + - `ssh_host_port_min` and `ssh_host_port_max` (integer) - The minimum and maximum port to use for the SSH port on the host machine which is forwarded to the SSH port on the guest machine. Because Packer often runs in parallel, diff --git a/website/source/docs/builders/virtualbox-ovf.html.md b/website/source/docs/builders/virtualbox-ovf.html.md index 6b0f73ee3..e0f2a5e71 100644 --- a/website/source/docs/builders/virtualbox-ovf.html.md +++ b/website/source/docs/builders/virtualbox-ovf.html.md @@ -229,6 +229,10 @@ builder. doesn't shut down in this time, it is an error. By default, the timeout is "5m", or five minutes. +- `skip_export` (boolean) - Defaults to `false`. When enabled Packer will + skip export of the installed virtual machine. Only useful for some edge + use cases. + - `ssh_host_port_min` and `ssh_host_port_max` (integer) - The minimum and maximum port to use for the SSH port on the host machine which is forwarded to the SSH port on the guest machine. Because Packer often runs in parallel,