Via Jenkins, I'm trying to run ansible playbook.yml, but its failing due to below error

UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n”, “unreachable”: true}

I have added the key, even though its say ssh fail to connect.

can you please share the exact steps to fix!

Hi,
Please check if you are able to do ssh connection to that host directly without entering any password.

Regards,
Sunil Bansal

Hi,

Thank you for response …

Yes I have added the keys on .ssh… Passwordless is working

Thanks,
Deepan

Hi,

Password less ssh enabled and i can able to run palybook from terminal, but when i try the same playbook via jenkins, its throwing an error like

Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", “unreachable”: true}.

FYI… Using Ldap user for ansible play.

can some one please suggest!

Thanks,

Deepan M

when you run the playbook through jenkins, it run as jenkins user, did you add the ssh key under the jenkins’s user (/var/lib/jenkins/.ssh/) authorize key and also mentioned the user that you want to connect to remote server over ssh.

Problem fixed by adding ansible_user=username on extra variables on jenkins build.

turn on debug on the ssh daemon on the target host and see why it’s complaining. perms maybe on the home dir or .ssh dir of the user you are
attempting to run the playbook as?

Password less has been enabled, even though its failed because of permission denied, so after adding key ansible_user value username on extra variables, now its fixed.