【发布时间】:2018-03-22 04:24:56
【问题描述】:
我正在尝试从测试厨房中的私人 Bitbucket 存储库进行克隆。我已经为 Bitbucket 使用配置了一个密钥对,当我运行厨房登录时,可以以 root 身份手动运行命令:
git clone <repo> <directory>
但是,当运行厨房融合时,它总是失败。我这辈子都想不通。这是我在食谱中所做的:
directory '/root/.ssh/' do
owner "root"
group "root"
mode '0700'
action :create
end
template '/root/.ssh/id_rsa' do
source 'id_rsa.erb'
owner 'root'
group 'root'
mode '0600'
end
package 'git'
file "/root/git_wrapper.sh" do
owner "root"
mode "0755"
content "#!/bin/sh\nexec /usr/bin/ssh -i /root/.ssh/id_rsa \"$@\""
end
git "/etc/myrepo" do
# The following line ensures that our repo-specific deployment
# ssh-key will be used for all clone & fetch operations.
repository 'git@bitbucket.org:myrepo/myrepo.git'
checkout_branch "master"
ssh_wrapper "/root/git_wrapper.sh"
user "root"
action :sync
end
我对此完全不知所措,尤其是如果我可以在容器内运行 git 命令。这是我得到的堆栈跟踪:
Running handlers:
[2018-03-21T14:38:36+00:00] ERROR: Running exception handlers
Running handlers complete
[2018-03-21T14:38:36+00:00] ERROR: Exception handlers complete
Chef Client failed. 14 resources updated in 13 seconds
[2018-03-21T14:38:36+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2018-03-21T14:38:36+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-03-21T14:38:36+00:00] ERROR: git[/etc/myrepo] (bsd-env-mtarep::mtarep line 50) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
---- Begin output of git ls-remote "git@bitbucket.org:myrepo/myrepo.git" "HEAD" ----
STDOUT:
STDERR: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
---- End output of git ls-remote "git@bitbucket.org:myrepo/myrepo.git" "HEAD" ----
Ran git ls-remote "git@bitbucket.org:myrepo/myrepo.git" "HEAD" returned 128
[2018-03-21T14:38:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
有人可以建议我需要做什么来解决这个问题吗?
【问题讨论】:
-
看起来您需要使用 bitbucket.org 的公共主机密钥删除一个“/root/.ssh/known_hosts”文件
-
这正是发生的事情!实际上,我可以通过更新我的 SSH 包装脚本来修复它..
标签: git chef-infra test-kitchen