I am trying to call my Ansible playbook from jenkins. But everytime i do so, i am getting permission denied for public key error. My objective is to push the playbook from local machine to GC VM.
Facts:
- Ansible and jenkins are installed on same machine
- My GC VM instance key is in /home/govind/Desktop/splukinstancekey.pem path. This is in my main user ("govind").
- In jenkins, i have generated a RSA key using ssh-keygen and added the same in user "govind" .ssh/authorized_keys. So i am able to make a connection from jenkins user to govind user (where ansible is installed ).
The problem is whenever i run the playbook from jenkins user , below error is thrown:
TASK [Gathering Facts] *********************************************************************************************************************** fatal: [34.71.8.168]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Load key "/home/govind/Desktop/splunkinstancekey.pem": Permission denied\r\[email protected]: Permission denied (publickey).", "unreachable": true} fatal: [35.223.166.86]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Load key "/home/govind/Desktop/splunkinstancekey.pem": Permission denied\r\[email protected]: Permission denied (publickey).", "unreachable": true}
From user "govind" i can easily ping remote servers via ansible command. Can anyone please help me in understanding what gap i might be missing from jenkins user. I understand that jenkins cannot access the pem file in as it does not belong to it. From various other posts i read that jenkins makes connection to user where ansible in installed and then that playbook is executed. But not able to make any progress.