When deploying an application with Chef, I've got the code base set to be cloned from a private github repository with the following resource:
git '/mnt/application' do
repository '[email protected]:organization/repository'
reference 'master'
action :sync
user node.application.user
group node.application.user
end
However, after scanning the documentation for the git
resource, I can't see how you supply the key file for authentication. I'm also confused as to how to store this key in a data bag, as the file contains a bunch of new lines. Any ideas?
ssh_wrapper "ssh -i /some/path/id_rsa"
In case someone comes across this, the above didn't work for me, I kept getting the error:
error: cannot run ssh -i /some/path/id_rsa: No such file or directory
What specifying ssh_wrapper does is it sets the GIT_SSH environment variable, and it turns out you can't provide parameters in the GIT_SSH environment variable (see Git clone with custom SSH using GIT_SSH error).
Instead, you would need to write your script to a file first, then set GIT_SSH to it.
So:
file "/some/path/git_wrapper.sh" do
owner "your_user"
mode "0755"
content "#!/bin/sh\nexec /usr/bin/ssh -i /some/path/id_rsa \"$@\""
end
And change the git resource part to:
git "/opt/mysources/couch" do
repository "git://git.apache.org/couchdb.git"
reference "master"
action :sync
ssh_wrapper "/some/path/git_wrapper.sh"
end