L. *_*mek 27 git ssh chef-infra
在使用Chef部署应用程序时,我已经使用以下资源从私有github存储库中克隆了代码库:
git '/mnt/application' do
repository 'git@github.com:organization/repository'
reference 'master'
action :sync
user node.application.user
group node.application.user
end
Run Code Online (Sandbox Code Playgroud)
但是,在扫描git
资源的文档后,我无法看到您如何提供密钥文件进行身份验证.我也很困惑如何将这个密钥存储在数据包中,因为该文件包含一堆新行.有任何想法吗?
psa*_*aan 27
Run Code Online (Sandbox Code Playgroud)ssh_wrapper "ssh -i /some/path/id_rsa"
如果有人碰到这个,上面的内容对我不起作用,我不断收到错误:
error: cannot run ssh -i /some/path/id_rsa: No such file or directory
Run Code Online (Sandbox Code Playgroud)
指定ssh_wrapper的是它设置了GIT_SSH环境变量,结果发现你不能在GIT_SSH环境变量中提供参数(参见使用GIT_SSH错误的自定义SSH的Git克隆).
相反,您需要先将脚本写入文件,然后将GIT_SSH设置为它.
所以:
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
Run Code Online (Sandbox Code Playgroud)
并将git资源部分更改为:
git "/opt/mysources/couch" do
repository "git://git.apache.org/couchdb.git"
reference "master"
action :sync
ssh_wrapper "/some/path/git_wrapper.sh"
end
Run Code Online (Sandbox Code Playgroud)
Dra*_*ter 12
我们使用Mercurial的类似设置,但我希望它与Git相同.
我们使用ssh密钥进行身份验证.密钥存储在加密的数据库中(换行符替换为"\n").首先,在数据库的节点上创建此私钥.
git_key = Chef::EncryptedDataBagItem.load( "private_keys", "git_key" )
file "/some/path/id_rsa" do
content git_key['private']
end
Run Code Online (Sandbox Code Playgroud)
然后在使用ssh_wrapper连接到git存储库时使用它:
git "/opt/mysources/couch" do
repository "git://git.apache.org/couchdb.git"
reference "master"
action :sync
ssh_wrapper "ssh -i /some/path/id_rsa" #the path to our private key file
end
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11081 次 |
最近记录: |