Open ghost opened 3 years ago
I have the same issue with Packer 1.7.4 on Ubuntu 20.10. I'm trying to create an Ubuntu AMI, and it's really flaky. It seems that if you try to SSH too early after instance provisioning the SSH port will just hang. It will never connect and shh_timeout will be reached no matter the time.
I managed to recreate this behavior even when running Packer with the -debug flag. As soon as packer announces that the instance is ready, I try to ssh manually and it hangs. But if I wait a few seconds it works, both manually and from Packer. So this might be a problem with just specific AMIs, maybe it's hit by some weird timing issue, when SSH manager is not ready but still accepts connections.
I confirmed this by cloning this repo and adding a step in builder/ebs/builder.go, right before the &communicator.StepConnect entry in the steps array. This step just sleeps for 10 seconds. Like this SSH always works for me.
This issue was originally opened by @njgrisafi as hashicorp/packer#10992. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
1.7.0
macOS BigSur 11.3
I'm using packer to automate the creation of AWS AMIs. Using packer locally has been a bit frustrating due to frequent SSH timeout errors. My work around is to retry the
packer build
command until ssh connects successfully.This happens for any packer buildfile that requires SSH via EC2. The EC2 instance is ready and available but packer says it can't connect. I've ran packer in debug mode and confirmed I can connect to the EC2 via SSH when packer says it got a timeout.
I'm thinking this could be an issue with my host machine but not sure. Any help is appreciated!