So I’ve spent a good amount of time researching this problem and trying out numerous solutions but I’ve still had no luck so I thought I’d ask.
My current setup is an EC2 instance with Jenkins and Ansible playbooks. I want this Jenkins instance to watch the repositories and run a playbook if something new is pushed up to github.
The Jenkins instance has the ubuntu user with the playbooks and necessary ssh keys for the other ec2 instances. I’m having a problem with ssh-agent and ssh-forwarding from the Jenkins instance to the other ec2 instances.
If I ssh in to the Jenkins node from my personal machine I can run the playbooks no problem. The problems arise when I try to run the Jenkins job from the web interface. I fixed the problem with allowing Jenkins to connect by switching to the jenkins user from the ubuntu user and running eval ssh-agent
and then ssh-add .pem.
This allows the playbooks to connect in the first place but then it fails when trying to pull from git because it isn’t forwarding the ssh key for git. I’ve even tried editing the .ssh/config file for the jenkins user to allow ssh forwarding to amazon instances.
I’m having a hard time finding any resources or tutorials on this type of setup. I’ve found similar ones but nothing that addresses this specific configuration.