Ansible playbook access github

0 votes

I have an ansible playbook that autoamtes my git usage. I am able to clone and update my repos using it. I've also used ssh forwarding and it is working perfectly fine. 

My playbook:

- hosts: webservers
  sudo: yes
  remote_user: ubuntu

  tasks:

  - name: Test that git ssh connection is working.
    command: ssh -T git@github.com

My ssh forwarding is working fine as I'm able to ssh into my server but when I try doing the same thing by executing the playbook, it gives me the following error:

failed: [xxx.xxxxx.com] => {"changed": true, "cmd": ["ssh", "-T", "git@github.com"], "delta": "0:00:00.585651", "end": "2014-06-09 14:11:37.410907", "rc": 255, "start": "2014-06-09 14:11:36.825426"}
stderr: Permission denied (publickey).

What's the issue?

Jan 16 by Neha
18 views

1 answer to this question.

0 votes

Hey @Niha, Remove this line from your playbook

sudo: yes

When sudo runs on the remote host, the environment variables set by ssh during login are not available anymore and hence ssh forwarding fails.

answered Jan 16 by Tini

Related Questions

+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
147 views
0 votes
1 answer
0 votes
1 answer
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
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,620 points
106 views
0 votes
1 answer

ansible playbook: using multiple variables in loops

Use an indexed hostname, and then define ...READ MORE

answered Jul 16, 2018 in Ansible by DareDev
• 6,810 points
4,375 views
0 votes
1 answer