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?
Git uses SSH to establish a secure connection through which it can execute commands. You're passing it in your ssh username, git , and the host to connect to, github.com . So far this is normal SSH. You also pass it the path to look for your Git repository, MY_GIT_USERNAME/PROJECT.
When you authenticate to GitHub, you supply or confirm credentials that are unique to you to prove that you are exactly who you declare to be. You can access your resources in GitHub in a variety of ways: in the browser, via GitHub Desktop or another desktop application, with the API, or via the command line.
With SSH keys, you can connect to GitHub without supplying your username and personal access token at each visit. You can also use an SSH key to sign commits. You can access and write data in repositories on GitHub.com using SSH (Secure Shell Protocol).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With