我正在使用带有Ansible provision的Vagrant。当我使用Ansible进行git克隆时,我遇到了以下错误:
但是每当我试图手动从Vagrant框中克隆时,它都可以正常工作。我已经搜索了网络,并且在Vagrant中将ssh转发设置为true,我的~/.ssh/config如下,这允许从主机转发。
每当我从ansible中进行git clone时,为什么会运行以下命令而不是git clone命令:
failed: [default] => {"cmd": "/usr/bin/git ls-remote '' -h refs/heads/HEAD", "failed": true, "rc": 128}
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
msg: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
FATAL: all hosts have already failed -- aborting
但是每当我试图手动从Vagrant框中克隆时,它都可以正常工作。我已经搜索了网络,并且在Vagrant中将ssh转发设置为true,我的~/.ssh/config如下,这允许从主机转发。
Host *
ForwardAgent yes
我的ansible yml文件如下:
---
- hosts: all
sudo: true
tasks:
- name: Clone project
git: repo=<git ssh link>
accept_hostkey=yes
clone=yes
dest=/home/vagrant
我的 Vagrant 文件如下:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 9000
config.vm.provision :ansible do |ansible|
ansible.playbook = "playbook.yml"
end
config.ssh.forward_agent = true
end
每当我从ansible中进行git clone时,为什么会运行以下命令而不是git clone命令:
/usr/bin/git ls-remote '' -h refs/heads/HEAD