【发布时间】:2015-12-25 14:40:10
【问题描述】:
我正在尝试使用 ansible 和 vagrant 设置开发环境。现在我被困在从 bitbucket 克隆一个 git repo。
下面是 Vagrantfile 和 ansible 设置以及我尝试过的东西。
在我的 Vagrantfile 中,我有 config.ssh.forward_agent = true
在我的 deploy.yml 我有
- name: ensure bitbucket is a known host
lineinfile:
dest: /home/vagrant/.ssh/known_hosts
create: yes
state: present
line: "{{ lookup('pipe', 'ssh-keyscan -p 443 -t rsa altssh.bitbucket.org') }}"
regexp: "^altssh\\.bitbucket\\.org"
sudo_user: "vagrant"
tags: known_hosts
- name: checkout opentest repo
git: >
dest="/home/vagrant/ot/"
repo="ssh://git@altssh.bitbucket.org:443/muhammadammar/opentest/"
version="master"
accept_hostkey=yes
sudo_user: "vagrant"
tags: checkout
上面的第一个任务将bitbucket的公钥添加到/home/vagrant/.ssh/known_hosts。
下面是 ansible 尝试检查 repo 时的输出
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> REMOTE_MODULE git dest="/home/vagrant/ot/" repo="ssh:********@altssh.bitbucket.org:443/muhammadammar/opentest/" version=master accept_hostkey=yes
<127.0.0.1> EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/ammar/.ansible/cp/%h-%r" -o StrictHostKeyChecking=no -o Port=2222 -o IdentityFile="/Users/ammar/.vagrant.d/insecure_private_key" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 127.0.0.1 /bin/sh -c 'sudo -k && sudo -HE -S -p "[sudo via ansible, key=vwkfotuvzzmllxvxptkgehjzdlqygoez] password: " -u vagrant /bin/sh -c '"'"'echo BECOME-SUCCESS-vwkfotuvzzmllxvxptkgehjzdlqygoez; LANG=C LC_CTYPE=C /usr/bin/python'"'"''
failed: [default] => {"cmd": "/usr/bin/git ls-remote 'ssh:********@altssh.bitbucket.org:443/muhammadammar/opentest/' -h refs/heads/master", "failed": true, "rc": 128}
stderr: RSA host key for IP address '131.103.20.174' not in list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
msg: RSA host key for IP address '131.103.20.174' not in list of known hosts.
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
to retry, use: --limit @/Users/ammar/dev.retry
default : ok=1 changed=0 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
在我的主机上,我已将我的私钥添加到 ssh 身份验证代理。我可以在主机和 vagrant box 上使用 ssh-add -l 查看私钥身份。
在 vagrant box 中,我可以使用 git clone ssh://git@altssh.bitbucket.org:443/muhammadammar/opentest ot 成功克隆 repo
我不确定是什么问题。谁能帮忙解决这个问题。
编辑
即使是下面的也不能在 ansible 中工作
shell: "git clone ssh://git@altssh.bitbucket.org:443/muhammadammar/opentest/ /home/vagrant/omp/"
【问题讨论】:
-
你尝试过stackoverflow.com/a/30775053/4296747的建议吗?
-
@FrédéricHenri 不工作