ddelnano / packer-plugin-xenserver

A builder plugin for Packer.IO to support building XenServer images.
Mozilla Public License 2.0
76 stars 37 forks source link

Ubuntu doesnt work without insanly high timeout and ssh_handshake_attempts #25

Open 4censord opened 3 years ago

4censord commented 3 years ago

This timeout was lowered from the previous 60000s value and the ssh_handshake_attempts (which was set to 10000) was removed. This is causing the ubuntu example to fail with the following error

ddelnano@ddelnano-desktop:~/go/src/github.com/xenserver/packer-builder-xenserver$ packer1.7.1 build examples/ubuntu/ubuntu-2004.pkr.hcl
xenserver-iso.ubuntu-2004: output will be in this color.

==> xenserver-iso.ubuntu-2004: XAPI client session established
==> xenserver-iso.ubuntu-2004: Retrieving ISO
==> xenserver-iso.ubuntu-2004: Trying http://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso
==> xenserver-iso.ubuntu-2004: Trying http://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso?checksum=d1f2bf834bbe9bb43faf16f9be992a6f3935e65be0edece1dee2aa6eb1767423
==> xenserver-iso.ubuntu-2004: http://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso?checksum=d1f2bf834bbe9bb43faf16f9be992a6f3935e65be0edece1dee2aa6eb1767423 => /home/ddelnano/go/src/github.com/xenserver/packer-builder-xenserver/packer_cache/dc8718d65b80640808a10b87f6d44fc2d16420af
==> xenserver-iso.ubuntu-2004: Starting HTTP server on port 8000
==> xenserver-iso.ubuntu-2004: Step: Upload VDI 'ubuntu-20.04.2-live-server-amd64.iso'
==> xenserver-iso.ubuntu-2004: Step: Found SRs '[OpaqueRef:beeed204-90ff-4f11-bfe2-1dfbb46d5eb5 OpaqueRef:ac11b102-c83c-4b0a-b076-2b5050474ac0 OpaqueRef:a6aca570-c039-4d21-8f2c-16c38456bdfd OpaqueRef:9963d6b4-d507-4425-90e6-2d857a25c4d0 OpaqueRef:90bdec93-5ba1-4187-bedd-5f18d3318410 OpaqueRef:10e7e21a-0569-4e6c-931e-d295a76a3be0]'
==> xenserver-iso.ubuntu-2004: PUT 'https://<sensitive>/import_raw_vdi?session_id=OpaqueRef%3A3a09798d-ccea-4da0-a069-3090f0dd42e2&task_id=OpaqueRef%3Ad5bae3ea-cf5d-4bf4-8dcd-f0089e966877&vdi=OpaqueRef%3Ada7653a0-d1d0-48fc-a777-11866f19fa56'
==> xenserver-iso.ubuntu-2004: Step: Create Instance
==> xenserver-iso.ubuntu-2004: Using the following SR for the VM: OpaqueRef:10e7e21a-0569-4e6c-931e-d295a76a3be0
==> xenserver-iso.ubuntu-2004: Created instance 'a16a1de7-eaee-c035-a349-add74a2018bd'
==> xenserver-iso.ubuntu-2004: Step: Start VM Paused
==> xenserver-iso.ubuntu-2004: Step: Set SSH address to VM host IP
==> xenserver-iso.ubuntu-2004: Set host SSH address to '192.168.88.89'.
==> xenserver-iso.ubuntu-2004: Unpausing VM a16a1de7-eaee-c035-a349-add74a2018bd
==> xenserver-iso.ubuntu-2004: Waiting 10s for boot...
==> xenserver-iso.ubuntu-2004: Connecting to the VM console VNC over xapi via 192.168.88.89
==> xenserver-iso.ubuntu-2004: Making HTTP request to initiate VNC connection: CONNECT /console?uuid=1e2a424b-b302-c212-a489-b177c49580f5 HTTP/1.0
==> xenserver-iso.ubuntu-2004: Host: 192.168.88.89
==> xenserver-iso.ubuntu-2004: Cookie: session_id=OpaqueRef:3a09798d-ccea-4da0-a069-3090f0dd42e2
==> xenserver-iso.ubuntu-2004:
==> xenserver-iso.ubuntu-2004:
==> xenserver-iso.ubuntu-2004: Received response: HTTP/1.1 200 OK
==> xenserver-iso.ubuntu-2004: Connection: keep-alive
==> xenserver-iso.ubuntu-2004: Cache-Control: no-cache, no-store
==> xenserver-iso.ubuntu-2004:
==> xenserver-iso.ubuntu-2004:
    xenserver-iso.ubuntu-2004: Found local IP: 192.168.88.254
==> xenserver-iso.ubuntu-2004: Typing boot commands over VNC...
==> xenserver-iso.ubuntu-2004: Finished typing.
==> xenserver-iso.ubuntu-2004: Step: Wait for VM's IP to become known to us.
    xenserver-iso.ubuntu-2004: Got IP '192.168.88.26' from HTTP request
==> xenserver-iso.ubuntu-2004: Got IP address '192.168.88.26'
==> xenserver-iso.ubuntu-2004: Creating a local port forward over SSH on local port 5900
==> xenserver-iso.ubuntu-2004: Port forward setup. 5900 ---> 192.168.88.26:22 on 192.168.88.89
==> xenserver-iso.ubuntu-2004: Using ssh communicator to connect: 192.168.88.26
==> xenserver-iso.ubuntu-2004: Waiting for SSH to become available...
==> xenserver-iso.ubuntu-2004: 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
==> xenserver-iso.ubuntu-2004: Deleting output directory...
Build 'xenserver-iso.ubuntu-2004' errored after 5 minutes 24 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

I have not tested if adding the ssh_handshake_attempts is enough to get it working, but I was able to verify using the previous values work.

While it's crappy to have those values set very high to get the example to work, I think we should keep the values as is (unless you want to investigate setting them more properly now).

_Originally posted by @ddelnano in https://github.com/ddelnano/packer-plugin-xenserver/pull/7#discussion_r616357669_

4censord commented 3 years ago

I assume it is some kind of ordering / race condition within the ubuntu installer. As in it installs packages first (and thus starting sshd) before creating users, so when packer tries to connect the user doesn't yet exist.

Centos works around this issue by opening the firewall as the last step, after everything has settled

This has been worked around in #7 (320e8de) but should be further investigated.