techiescamp / devops-projects

DevOps Real World Projects for Aspiring DevOps Engineers [Beginner to Advanced]
https://devopscube.com/devops-projects/
1.09k stars 793 forks source link

Packer Ansible Issue for Jenkins Projects #11

Closed techiescamp closed 1 year ago

techiescamp commented 1 year ago

Issue 01:

amazon-ebs.jenkins: fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Unable to negotiate with 127.0.0.1 port 58791: no matching host key type found. Their offer: ssh-rsa", "unreachable": true}

Issue 02:

amazon-ebs.jenkins: fatal: [default]: FAILED! => {"msg": "failed to transfer file to /Users/bibinwilson/.ansible/tmp/ansible-local-50186_ndddr6c/tmp_1v02xx4 ~bibinwilson/.ansible/tmp/ansible-tmp-1681489405.599305-50189-81149797253717/AnsiballZ_setup.py:\n\nscp: dest open \"'~bibinwilson/.ansible/tmp/ansible-tmp-1681489405.599305-50189-81149797253717/AnsiballZ_setup.py'\": No such file or directory\r\nscp: failed to upload file /Users/bibinwilson/.ansible/tmp/ansible-local-50186_ndddr6c/tmp_1v02xx4 to '~bibinwilson/.ansible/tmp/ansible-tmp-1681489405.599305-50189-81149797253717/AnsiballZ_setup.py'\r\n"}

Cause

This issue is caused due to OpenSSH latest version support with anisble + packer.

References:

Solution

Thes issues can be resolved by adding extra args to the ansible provisioner as shown below.

extra_arguments = [ "--extra-vars", "ami-id=${var.ami_id} efs_mount_point=${var.efs_mount_point}", "--scp-extra-args", "'-O'", "--ssh-extra-args", "-o IdentitiesOnly=yes -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa" ]