Skip to content

Commit

Permalink
Skip unneeded steps (cirruslabs#126)
Browse files Browse the repository at this point in the history
* Skip run step if we don't have boot commands or communicator

Without a communicator we can't provision, and if we don't have
boot commands there's not any keys to send to the running VM, so
running it is not needed.

This allows configuring builders that only create the VM,
in preparation for later OS installation and provisioning:

source "tart-cli" "create-only" {
  cpu_count    = 4
  memory_gb    = 8
  disk_size_gb = 40
  from_ipsw    = var.ipsw_file
  vm_name      = "pre-install-vm"
  communicator = "none"
}

* Skip typeBootCommandOverVNC if there are no boot commands

There's no need to connect to VNC if we have no boot commands
to type.
  • Loading branch information
torarnv authored Mar 11, 2024
1 parent 2a23549 commit 1d969c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions builder/tart/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,14 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
steps = append(steps,
new(stepSetVM),
new(stepDiskFilePrepare),
new(stepRun),
)

if !b.config.Recovery {
communicatorConfigured := b.config.CommunicatorConfig.Type != "none"
if len(b.config.BootCommand) > 0 || communicatorConfigured {
steps = append(steps, new(stepRun))
}

if !b.config.Recovery && communicatorConfigured {
steps = append(steps,
&communicator.StepConnect{
Config: &b.config.CommunicatorConfig,
Expand Down
2 changes: 1 addition & 1 deletion builder/tart/step_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *stepRun) Run(ctx context.Context, state multistep.StateBag) multistep.S

state.Put("tart-cmd", cmd)

if (len(config.FromISO) == 0) && !config.DisableVNC {
if len(config.BootCommand) > 0 && (len(config.FromISO) == 0) && !config.DisableVNC {
if !typeBootCommandOverVNC(ctx, state, config, ui, stdout) {
return multistep.ActionHalt
}
Expand Down

0 comments on commit 1d969c0

Please sign in to comment.