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