hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
76 stars 112 forks source link

amazon-ebs: failed to handshake when upgrading to Packer 1.8.5 #336

Closed bgaber closed 1 year ago

bgaber commented 1 year ago

packer version: v1.8.5 initiator OS: RHEL guest image OS: RHEL 8 Ansible: 7.2

I am upgrading from Packer version v1.6.6 to v1.8.5 and am seeing this error when building a new AWS EC2 AMI:

2023-02-14T02:30:28Z: ==> amazon-ebs: Provisioning with Ansible... 2023-02-14T02:30:28Z: amazon-ebs: Setting up proxy adapter for Ansible.... 2023-02-14T02:30:28Z: ==> amazon-ebs: Executing Ansible: ansible-playbook -e packer_build_name="amazon-ebs" -e packer_builder_type=amazon-ebs --ssh-extra-args '-o IdentitiesOnly=yes' --extra-vars env=sharedservices -e ansible_ssh_private_key_file=/tmp/ansible-key3825398156 -i /tmp/packer-provisioner-ansible2559500676 /drone/src/ansible/linux8.yml 2023-02-14T02:30:32Z: amazon-ebs: 2023-02-14T02:30:32Z: amazon-ebs: PLAY [Build RHEL/CentOS 8.x] * 2023-02-14T02:30:32Z: amazon-ebs: 2023-02-14T02:30:32Z: amazon-ebs: TASK [Gathering Facts] *** 2023-02-14T02:30:32Z: ==> amazon-ebs: failed to handshake 2023-02-14T02:30:32Z: amazon-ebs: fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Unable to negotiate with 127.0.0.1 port 42665: no matching host key type found. Their offer: ssh-rsa", "unreachable": true} 2023-02-14T02:30:32Z: amazon-ebs: 2023-02-14T02:30:32Z: amazon-ebs: PLAY RECAP ***** 2023-02-14T02:30:32Z: amazon-ebs: default : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0 2023-02-14T02:30:32Z: amazon-ebs: 2023-02-14T02:30:32Z: ==> amazon-ebs: Provisioning step had errors: Running the cleanup provisioner, if present... 2023-02-14T02:30:32Z: ==> amazon-ebs: Terminating the source AWS instance... 2023-02-14T02:33:04Z: ==> amazon-ebs: Cleaning up any extra volumes... 2023-02-14T02:33:04Z: ==> amazon-ebs: No volumes to clean up, skipping 2023-02-14T02:33:04Z: ==> amazon-ebs: Deleting temporary keypair... 2023-02-14T02:33:04Z: Build 'amazon-ebs' errored after 13 minutes 20 seconds: Error executing Ansible: Non-zero exit status: exit status 4

github-actions[bot] commented 1 year ago

Hi 👋 thanks for reaching out.

For general questions we recommend reaching out to the community forum for greater visibility. As the GitHub issue tracker is only watched by a small subset of maintainers and is really reserved for bugs and enhancements, you'll have a better chance of finding someone who can help you in the forum. We'll mark this issue as needs-reply to help inform maintainers that this question is awaiting a response. If no activity is taken on this question within 30 days it will be automatically closed.

If you find the forum to be more helpful or if you've found the answer to your question elsewhere please feel free to post a response and close the issue.

Glyphack commented 1 year ago

Hi @bgaber please provide your packer build file I can take a look.

lbajolet-hashicorp commented 1 year ago

Hi @bgaber,

Since this issue is related to the Amazon plugin, I'll transfer it over to the packer-plugin-amazon project for tracking purposes.

As @Glyphack mentioned, please provide us a redacted/minimal template if possible so we can investigate the reason why this happens. Also if possible, could you run packer with the PACKER_LOG=1 environment variable set so we have more verbose logs?

Thanks for reporting this.

haho16 commented 1 year ago

@bgaber I also hit this issue. Check: https://github.com/hashicorp/packer-plugin-ansible/issues/140 for more information

lbajolet-hashicorp commented 1 year ago

Hi there,

Looking at the logs again, this looks like a problem with Ansible's local proxy connection only offering RSA keys, which is now deprecated and rejected by OpenSSH.

We fixed this by changing the default key algorithm for this in the Ansible plugin not so long ago, so this should be fixed.

I'll close this now, but feel free to reopen if this problem persists, even on the latest versions of the plugin.

Thanks