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


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

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: [] => {"changed": true, "cmd": ["ssh", "-T", ""], "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, 2019 by Neha

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, 2019 by Tini

Related Questions

+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
+2 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,890 points
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,680 points
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,890 points
+1 vote
2 answers

What is the difference between ansible playbook and roles?

Hi, Roles: Roles containing certain vars_files, tasks, and handlers ...READ MORE

answered Jan 21, 2020 in Ansible by vivek
• 530 points