【问题标题】:Cloning git repository from Chef从 Chef 克隆 git 存储库
【发布时间】:2018-03-07 12:43:24
【问题描述】:

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

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

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

【问题讨论】:

  • 大多数情况下不是重复,因为 4 年后会有更好的答案,尽管 SO 喜欢假装旧问题实际上得到了更新,但我们都知道它们大多没有。

标签: ruby chef-infra chef-recipe


【解决方案1】:

查看 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?我在想一种方法,我可以为此使用秘密数据包。这就是为什么。
  • 在他们的文档中或在 10-20 分钟的 google + stackoverflow 搜索中找不到正常的凭据 - 所以我猜 - SSH 是解决这个问题的方法。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2013-07-14
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 2021-02-04
    • 2012-07-15
    • 2019-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多