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, 2019 in Ansible by Tina
3,018 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, 2019 by Sameer

Related Questions In Ansible

0 votes
1 answer

Become : yes is not working while running ansible playbook from Jenkins pipeline job

Hi, Jenkins will not able to run the ...READ MORE

answered Jul 21, 2020 in Ansible by MD
• 95,460 points
1,794 views
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,300 points
5,486 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,890 points
4,033 views
0 votes
1 answer
0 votes
1 answer

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

set "host_key_checking = False" in /etc/ansible/ansible.cfg READ MORE

answered Dec 2, 2019 in Jenkins by pavan

reshown Dec 2, 2019 by Vardhan 10,088 views
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,939 views
0 votes
1 answer
0 votes
1 answer

Ansible Playbook for Creating a VM with OS and multiple data managed disks

Hey @Ammie, Try a playbook something like ...READ MORE

answered Mar 27, 2019 in Ansible by Stark
1,411 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP