Ansible playbook with jenkins not working

0 votes

So I have an EC2 instance that has ansible and Jenkins on it. I'm trying to copy a few files from one host to another. I executed the ansible playbook which I've written specifically for this and it worked perfectly fine. But when I tried doing the same using Jenkins, It fails to give the following error:

fatal: [172.xx.xx.xx]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: no such identity: /home/ec2-user/.ssh/Host_Keypair.pem: Permission denied\r\nPermission denied (publickey).\r\n", "unreachable": true}
to retry, use: --limit @/var/lib/jenkins/workspace/Ansible/copy.retr
Jan 17 in Ansible by Tina
136 views

1 answer to this question.

0 votes

When you execute the playbook under Jenkins, your Jenkins does not have the access to /home/ec2-user/.ssh/Host_Keypair.pem key to authenticate on a remote server. 

What you can do is, copy your Host_Keypair.pem somewhere where Jenkins has all the required permissions and can read the ssh key required to connect to a remote host.

answered Jan 17 by Sameer

Related Questions In Ansible

0 votes
1 answer

When conditional not working in Ansible

Your identation is wrong and when is ...READ MORE

answered Apr 27, 2018 in Ansible by ajs3033
• 7,280 points
711 views
0 votes
1 answer

Permission denied when running ansible playbook through jenkins

Jenkins uses it's own user to execute ...READ MORE

answered Jun 25, 2018 in Ansible by DareDev
• 6,810 points
654 views
0 votes
1 answer
0 votes
0 answers

Not able to connect remote host via jenkins to run ansible playbook

Not able to connect remote host via ...READ MORE

Apr 2 in Jenkins by Nishant
• 160 points

recategorized Apr 2 by Nishant 1,007 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
148 views
0 votes
1 answer