I could clone public repos using Chef 12 on AWS OpsWorks as follows:
execute "get code" do
user "root"
cwd node['conf-cookbook']['project_root']
command "git clone #{app['app_source']['url']}"
end
but I don't know how to use deploy ssh key to clone private repos - I have searched a while and see a potential solution as follows:
git node['conf-cookbook']['app_dir'] do
repository "ext::ssh -i #{app['app_source']['ssh_key']} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no #{app['app_source']['url']}"
checkout_branch "master"
action :sync
end
which did not work with the error msg:
---- Begin output of git ls-remote "ext::ssh -i -----BEGIN RSA PRIVATE KEY----
MIIJKQIBAAKCAgEApaViIRinBrusrE....[key detail]7xAOmo3NAmqcPxdrOI+hZJHh5KRvrQPLHY
-----END RSA PRIVATE KEY----- -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected]:harrywang/app-main.git" "HEAD" ----
STDOUT:
STDERR: Warning: Identity file -----BEGIN not accessible: No such file or directory.
ssh: Could not resolve hostname rsa: Name or service not known
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
Any help? Thanks!
-i
takes a path to a key file, not the actual key data itself. Use the application_git
cookbook for setting up deploy keys with Chef.