Add option to skip export of installed VM for Virtualbox ISO & OVF builders
Closes #4131
This commit is contained in:
parent
282bb6ad37
commit
0ac071b6e7
|
@ -21,6 +21,7 @@ type StepExport struct {
|
||||||
OutputDir string
|
OutputDir string
|
||||||
ExportOpts []string
|
ExportOpts []string
|
||||||
SkipNatMapping bool
|
SkipNatMapping bool
|
||||||
|
SkipExport bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction {
|
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)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
vmName := state.Get("vmName").(string)
|
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.
|
// Wait a second to ensure VM is really shutdown.
|
||||||
log.Println("1 second timeout to ensure VM is really shutdown")
|
log.Println("1 second timeout to ensure VM is really shutdown")
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
|
@ -39,16 +39,17 @@ type Config struct {
|
||||||
|
|
||||||
BootCommand []string `mapstructure:"boot_command"`
|
BootCommand []string `mapstructure:"boot_command"`
|
||||||
DiskSize uint `mapstructure:"disk_size"`
|
DiskSize uint `mapstructure:"disk_size"`
|
||||||
KeepRegistered bool `mapstructure:"keep_registered"`
|
|
||||||
GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
|
GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
|
||||||
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
||||||
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
|
||||||
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
||||||
|
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
||||||
GuestOSType string `mapstructure:"guest_os_type"`
|
GuestOSType string `mapstructure:"guest_os_type"`
|
||||||
|
HardDriveDiscard bool `mapstructure:"hard_drive_discard"`
|
||||||
HardDriveInterface string `mapstructure:"hard_drive_interface"`
|
HardDriveInterface string `mapstructure:"hard_drive_interface"`
|
||||||
HardDriveNonrotational bool `mapstructure:"hard_drive_nonrotational"`
|
HardDriveNonrotational bool `mapstructure:"hard_drive_nonrotational"`
|
||||||
HardDriveDiscard bool `mapstructure:"hard_drive_discard"`
|
|
||||||
ISOInterface string `mapstructure:"iso_interface"`
|
ISOInterface string `mapstructure:"iso_interface"`
|
||||||
|
KeepRegistered bool `mapstructure:"keep_registered"`
|
||||||
|
SkipExport bool `mapstructure:"skip_export"`
|
||||||
VMName string `mapstructure:"vm_name"`
|
VMName string `mapstructure:"vm_name"`
|
||||||
|
|
||||||
ctx interpolate.Context
|
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,
|
OutputDir: b.config.OutputDir,
|
||||||
ExportOpts: b.config.ExportOpts.ExportOpts,
|
ExportOpts: b.config.ExportOpts.ExportOpts,
|
||||||
SkipNatMapping: b.config.SSHSkipNatMapping,
|
SkipNatMapping: b.config.SSHSkipNatMapping,
|
||||||
|
SkipExport: b.config.SkipExport,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
OutputDir: b.config.OutputDir,
|
OutputDir: b.config.OutputDir,
|
||||||
ExportOpts: b.config.ExportOpts.ExportOpts,
|
ExportOpts: b.config.ExportOpts.ExportOpts,
|
||||||
SkipNatMapping: b.config.SSHSkipNatMapping,
|
SkipNatMapping: b.config.SSHSkipNatMapping,
|
||||||
|
SkipExport: b.config.SkipExport,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,18 @@ type Config struct {
|
||||||
vboxcommon.VBoxVersionConfig `mapstructure:",squash"`
|
vboxcommon.VBoxVersionConfig `mapstructure:",squash"`
|
||||||
|
|
||||||
BootCommand []string `mapstructure:"boot_command"`
|
BootCommand []string `mapstructure:"boot_command"`
|
||||||
SourcePath string `mapstructure:"source_path"`
|
|
||||||
Checksum string `mapstructure:"checksum"`
|
Checksum string `mapstructure:"checksum"`
|
||||||
ChecksumType string `mapstructure:"checksum_type"`
|
ChecksumType string `mapstructure:"checksum_type"`
|
||||||
TargetPath string `mapstructure:"target_path"`
|
|
||||||
GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
|
GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
|
||||||
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
||||||
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
|
||||||
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
||||||
VMName string `mapstructure:"vm_name"`
|
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
||||||
ImportOpts string `mapstructure:"import_opts"`
|
|
||||||
ImportFlags []string `mapstructure:"import_flags"`
|
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
|
ctx interpolate.Context
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,6 +268,10 @@ builder.
|
||||||
doesn't shut down in this time, it is an error. By default, the timeout is
|
doesn't shut down in this time, it is an error. By default, the timeout is
|
||||||
`5m`, or five minutes.
|
`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
|
- `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
|
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,
|
to the SSH port on the guest machine. Because Packer often runs in parallel,
|
||||||
|
|
|
@ -229,6 +229,10 @@ builder.
|
||||||
doesn't shut down in this time, it is an error. By default, the timeout is
|
doesn't shut down in this time, it is an error. By default, the timeout is
|
||||||
"5m", or five minutes.
|
"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
|
- `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
|
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,
|
to the SSH port on the guest machine. Because Packer often runs in parallel,
|
||||||
|
|
Loading…
Reference in New Issue