I am trying to clone from a private Bitbucket repo in test kitchen. I have went as far as configuring a key pair for Bitbucket use and when I run kitchen login can manually run the command as root:
git clone <repo> <directory>
But when running a kitchen converge, it ALWAYS fails. I can't figure it out for the life of me. Here is what I am doing in my recipe:
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
I am at a complete loss on this, especially if I can run the git command inside the container. Here is the stacktrace I get:
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)
Can someone advise what I need to do to fix this?