pause_before_connecting does not pause before connecting
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
#### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
#### Overview of the Issue
I was deploying a simple template to build a VM on a VMware systems and ran into a problem with the build timing out before the VM was fully set up and running. When this occurs the SSH daemon isn't running yet so trying to connect to it too early cannot succeed. We expected to use the pause_before_connecting as a sleep period to wait until the SSH daemon was started and listening on its port. It never gets to the pause timer because it timed out trying to do its initial (and unneeded) connection.
This is really a duplicate of [#7430](https://github.com/hashicorp/packer/issues/7430) that was submitted a couple of years ago and the "solution" was to update the documentation to describe how the option actually behaves. I believe that if it works incorrectly to begin with, simply documenting that behavior is not a solution at all. The option states "pause BEFORE connecting", not Connect -> log off -> pause -> and then reconnect.
The way it currently functions makes the option completely useless. I cannot imagine any scenario where I would ever want to connect via SSH, wait, and then reconnect. If you're going to have an option called pause_before_connecting then please make it actually pause before connecting.
#### Reproduction Steps
Steps to reproduce this issue:
Produce on a system that takes longer than 3 minutes to download Ubuntu ISO and build the VM.
### Packer version
Packer v1.8.2
### Simplified Packer Template
```json
{
"builders": [
{
"type": "vsphere-iso",
"convert_to_template": "true",
"host": "mysys.i.mydomain.com",
"username": "administrator@i.mydomain.com",
"password":"mypwd",
"vcenter_server": "vcenter7.i.mydomain.com",
"insecure_connection": "true",
"iso_checksum": "none",
"iso_url" : "https://releases.ubuntu.com/20.04/ubuntu-20.04.4-live-server-amd64.iso",
"vm_name": "testsys",
"cpus": "4",
"ram": "4096",
"datastore" : "datastore1",
"datacenter" : "Testing",
"storage": [
{
"disk_size": "40000"
}
],
"network_adapters": [
{
"network": "VLAN 111"
}
],
"pause_before_connecting": "5m",
"ssh_password": "mypwd",
"ssh_username": "mypwd",
"ssh_timeout": "20m",
"boot_command": [
"<>wait>",
"",
"admin admin admin admin admin ",
""
]
}
]
}
```
### Operating system and Environment details
Client: Ubuntu 20.04 workstation
VMware: vcenter 7.0.0
### Log Fragments and crash.log files
==> vsphere-iso: File /home/myuser/.cache/packer/f56bff3df62a8576625321cf140b318c53705f7f.iso already uploaded; continuing
==> vsphere-iso: File [datastore1] packer_cache//f56bff3df62a8576625321cf140b318c53705f7f.iso already exists; skipping upload.
==> vsphere-iso: Creating VM...
==> vsphere-iso: Customizing hardware...
==> vsphere-iso: Mounting ISO images...
==> vsphere-iso: Adding configuration parameters...
==> vsphere-iso: Set boot order temporary...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting 10s for boot...
==> vsphere-iso: Typing boot command...
==> vsphere-iso: Waiting for IP...
==> vsphere-iso: IP address: 192.168.121.25
==> vsphere-iso: Using SSH communicator to connect: 192.168.121.25
==> vsphere-iso: Waiting for SSH to become available...
==> vsphere-iso: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
==> vsphere-iso: Clear boot order...
==> vsphere-iso: Power off VM...
==> vsphere-iso: Destroying VM...
Build 'vsphere-iso' errored after 2 minutes 57 seconds: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
Set the env var `PACKER_LOG=1` for maximum log detail.
Contributor guide
Assessment
This issue has not been assessed yet.