I'm having trouble getting my chef's recipe for cloning a private repo. Well, yesterday it worked for me, but after the "Cheffin" of my stray box half a dozen times, I broke it. I, as you might imagine, a beginner chef.
Following the deployment_resource guide, I created my deploy.rb recipe (shortened):
deploy_branch "/var/www/html/ps" do repo git@github.com :simonmorley/private-v2.git ssh_wrapper "/tmp/.ssh/chef_ssh_deploy_wrapper.sh" branch "rails4" migrate false environment "RAILS_ENV" => node[:ps][:rails_env] purge_before_symlink %w{conf data log tmp public/system public/assets} create_dirs_before_symlink [] symlinks( # the arrow is sort of reversed: "conf" => "conf", # current/conf -> shared/conf "data" => "data", # current/data -> shared/data "log" => "log", # current/log -> shared/log "tmp" => "tmp", # current/tmp -> shared/tmp "system" => "public/system", # current/public/system -> shared/system "assets" => "public/assets" # current/public/assets -> shared/assets ) scm_provider Chef::Provider::Git # is the default, for svn: Chef::Provider::Subversion notifies :restart, "service[ps]" notifies :restart, "service[nginx]" end
In the default settings, I have the following to create dirs, etc.
directory "/tmp/.ssh" do action :create owner node[:base][:username] group node[:base][:username] recursive true end template "/tmp/.ssh/chef_ssh_deploy_wrapper.sh" do source "chef_ssh_deploy_wrapper.sh.erb" owner node[:base][:username] mode 0770 end # Put SSH private key to be used with SSH wrapper template "/tmp/.ssh/id_deploy" do source "id_rsa.pub.erb" owner node[:base][:username] mode 0600 end
And in a wrapper:
#!/bin/sh exec ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "/tmp/.ssh/id_deploy" " $@ "
And I created a public key and uploaded it to github.
When I breed a recipe, it gives me an error:
deploy_branch[/var/www/html/ps] action deployEnter passphrase for key '/tmp/.ssh/id_deploy':
Obvs I do not have a set of passwords ... Therefore, the private key should be absent.
Just by chance, I deleted the id_deploy key from the recipe, deleted the folders, and started it again. Low and now it started working ... The reason is id_rsa.pub && The id_rsa files were in /root/.ssh when I manually generated them for testing.
I do not understand what I'm doing wrong here. So my questions are:
- Do I need a private and public key for each node I deploy to? Documents do not mention this.
- Should it not be deployed as a non-root user? I installed the user in my roles file.
- Why ssh_wrapper is not doing what it should