Ansible bitbucket clone repo provisioning ssh error

南笙酒味 提交于 2019-12-01 14:50:49

This generally means Ansible is not trying to clone the repo with the same user than the one use with vagrant ssh.

One trick to better debug what is going on is to run the command:

GIT_SSH_COMMAND='ssh -v' git clone ...

That way, you will see exactly which ssh keys are tried.

As kostix suggests in the comments, adding the id (or id -a) in the Ansible commands would be helpful too.


The OP Gustavmahler confirms in the comments:

You were right: Ansible was cloning the repo as a different user than the one I expected.
I added the following which fixed the task:

become: true 
become_user: vagrant 

The ssh-agent is associated with a terminal session - but automated Ansible runs are not. (Same deal for most cron jobs, fwiw.) This also explains why things work just fine if you SSH into your Vagrant box and run things.

If you add ansible_ssh_private_key_file: /path/to/file to the playbook, then does that resolve the issue?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!