Git authentication in Chef

前端 未结 6 1542
眼角桃花
眼角桃花 2020-12-14 02:11

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/ap         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 02:32

    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
    

提交回复
热议问题