change pause to run connect again afterwards
This commit is contained in:
parent
d486459a00
commit
2dcf950441
|
@ -41,7 +41,6 @@ type Config struct {
|
|||
// that uses `docker exec` and `docker cp` to execute scripts and copy
|
||||
// files.
|
||||
Type string `mapstructure:"communicator"`
|
||||
|
||||
// We recommend that you enable SSH or WinRM as the very last step in your
|
||||
// guest's bootstrap script, but sometimes you may have a race condition
|
||||
// where you need Packer to wait before attempting to connect to your
|
||||
|
|
|
@ -47,7 +47,6 @@ type StepConnect struct {
|
|||
|
||||
func (s *StepConnect) pause(pauseLen time.Duration, ctx context.Context) bool {
|
||||
// Use a select to determine if we get cancelled during the wait
|
||||
log.Printf("Pausing before connecting...")
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return true
|
||||
|
@ -112,10 +111,18 @@ func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multist
|
|||
}
|
||||
|
||||
if s.Config.PauseBeforeConnect > 0 {
|
||||
ui.Say(fmt.Sprintf("Pausing %s before connecting...",
|
||||
s.Config.PauseBeforeConnect.String()))
|
||||
cancelled := s.pause(s.Config.PauseBeforeConnect, ctx)
|
||||
if cancelled {
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
// After pause is complete, re-run the connect substep to make sure
|
||||
// you've connected properly
|
||||
action := s.substep.Run(ctx, state)
|
||||
if action == multistep.ActionHalt {
|
||||
return action
|
||||
}
|
||||
}
|
||||
|
||||
// Put communicator config into state so we can pass it to provisioners
|
||||
|
|
Loading…
Reference in New Issue