Chef中的Git认证 [英] Git authentication in Chef

查看:149
本文介绍了Chef中的Git认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

 

在使用Chef部署应用程序时,我已将代码库设置为从具有以下资源的私有github存储库克隆。 code> git'/ mnt / application'do
repository'git@github.com:organization / repository'

参考'master'
action:sync

user node.application.user
group node.application.user
end

但是,在扫描 git 资源的文档后,我看不到如何提供密钥文件进行身份验证。我也对如何将这个密钥存储在数据包中感到困惑,因为该文件包含大量新行。任何想法?

解决方案


  ssh_wrapperssh -i / some / path / id_rsa


如果有人遇到这种情况,上面没有为我工作,我不断收到错误:

 错误:无法运行ssh -i / some /路径/ id_rsa:没有这样的文件或目录

ssh_wrapper的作用是设置GIT_SSH环境变量,事实证明,您无法在GIT_SSH环境变量中提供参数(请参阅 Git clone with custom SSH using GIT_SSH error )。



相反,您需要先将脚本写入文件,然后将GIT_SSH设置为它。

所以:

  file/ some / path / git_wrapper .shdo 
owneryour_user
mode0755
content#!/ bin / sh \\\
exec / usr / bin / ssh -i / some / path / id_rsa \$ @ \
end

然后将git资源部分更改为:

  git/ opt / mysources / couchdo 
仓库git://git.apache.org/couchdb.git
引用主
动作:同步
ssh_wrapper/some/path/git_wrapper.sh
结束


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 'git@github.com: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

这篇关于Chef中的Git认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆