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
12 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
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,560 points
465 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
54 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,560 points
2,805 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.