从 Chef 克隆 git 个存储库

Cloning git repository from Chef

我在网上发现我们可以从以下 chef 资源块克隆 git 存储库。

git "/path/to/check/out/to" do
  repository "git://github.com/opscode/chef.git"
  reference "master"
  action :sync
end

我的问题是如何在此资源块中使用我的 Git 用户凭据。

查看 chef 的文档,您可以为此 https://docs.chef.io/resource_git.html 添加 ssh_wrapper 参数,这将允许您使用特定用户进行克隆。

可能ssh_wrapper

您的 ssh_wrapper 可能看起来像:

ssh_wrapper "ssh -i /some/path/id_rsa"

所有参数

git 'name' do
  additional_remotes         Hash
  checkout_branch            String
  depth                      Integer
  destination                String # defaults to 'name' if not specified
  enable_checkout            TrueClass, FalseClass
  enable_submodules          TrueClass, FalseClass
  environment                Hash
  group                      String, Integer
  notifies                   # see description
  provider                   Chef::Provider::Scm::Git
  reference                  String
  remote                     String
  repository                 String
  revision                   String
  ssh_wrapper                String
  subscribes                 # see description
  timeout                    Integer
  user                       String, Integer
  action                     Symbol # defaults to :sync if not specified
end

如果您想使用 SSH 密钥作为凭据,请查看 poise_git cookbook and resource,它会为您处理。