move pause to after connection can be established.

This commit is contained in:
Megan Marsh 2019-02-26 12:24:45 -08:00
parent b8510f35fc
commit 9db844a807
1 changed files with 13 additions and 8 deletions

View File

@ -60,13 +60,6 @@ func (s *StepConnect) pause(pauseLen time.Duration, ctx context.Context) bool {
func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
if s.Config.PauseBeforeConnect > 0 {
cancelled := s.pause(s.Config.PauseBeforeConnect, ctx)
if cancelled {
return multistep.ActionHalt
}
}
typeMap := map[string]multistep.Step{
"none": nil,
"ssh": &StepConnectSSH{
@ -114,7 +107,19 @@ func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multist
}
s.substep = step
return s.substep.Run(ctx, state)
action := s.substep.Run(ctx, state)
if action == multistep.ActionHalt {
return action
}
if s.Config.PauseBeforeConnect > 0 {
cancelled := s.pause(s.Config.PauseBeforeConnect, ctx)
if cancelled {
return multistep.ActionHalt
}
}
return multistep.ActionContinue
}
func (s *StepConnect) Cleanup(state multistep.StateBag) {