【问题标题】:Chef Cookbook dependency from Git repository source来自 Git 存储库源的 Chef Cookbook 依赖项
【发布时间】:2022-04-07 06:16:36
【问题描述】:

我与 Chef Solo 一起维护了一本 Chef Cookbook,以配置 Vagrant VM 以进行开发。不幸的是,昨天我不小心删除了我的虚拟机并偶然发现了一个错误。它与一本食谱有关。

==> default: ================================================================================
==> default: Recipe Compile Error in /var/chef/cache/cookbooks/givingfire/recipes/default.rb
==> default: ================================================================================
==> default:
==> default: NoMethodError
==> default: -------------
==> default: undefined method `ssl_certificate' for cookbook: givingfire, recipe: ssl :Chef::Recipe
==> default:
==> default: Cookbook Trace: (most recent call first)
==> default: ----------------------------------------
==> default:   /var/chef/cache/cookbooks/givingfire/recipes/ssl.rb:1:in `from_file'
==> default:   /var/chef/cache/cookbooks/givingfire/recipes/default.rb:10:in `from_file'
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /var/chef/cache/cookbooks/givingfire/recipes/ssl.rb:
==> default:
==> default:   1>> cert = ssl_certificate node['ssl']['name'] do
==> default:   2:    namespace node['ssl']
==> default:   3:  end
==> default:   4:
==> default:   5:  log "#{node['ssl']['name']} certificate is here: #{cert.cert_path}"
==> default:   6:  log "#{node['ssl']['name']} private key is here: #{cert.key_path}"  7:

当我查看食谱问题时,我发现了一个未解决的问题和一个与之相关的 PR。

公关问题:https://github.com/zuazo/ssl_certificate-cookbook/pull/46

我的问题是:有没有一种方法可以将食谱指定为基于 Git 存储库的依赖项。理想情况下,类似于我们在 Gemfile 中通过指定源和分支来执行的操作。不幸的是,文档没有提供任何提示,我怀疑它不受支持。反正我试过没有成功。

# File: metadata.rb
depends 'ssl_certificate', '~> 2.1.0', git: 'https://github.com/vzDevelopment/ssl_certificate-cookbook.git', branch: 'add_provider-issue_45'

关于如何使用 GitHub 存储库作为依赖源的任何建议?

【问题讨论】:

  • 此功能可通过Berkshelf 获得,Cookbook 元数据希望依赖项存在于本地。

标签: chef-infra


【解决方案1】:

假设你没有使用 Policyfiles 来管理你的依赖:

在您的 metadata.rb 文件中:

depends 'ssl_certificate', '~> 2.1.0'

将此行添加到您的 Berksfile 文件中:

cookbook 'ssl_certificate', git: 'https://github.com/vzDevelopment/ssl_certificate-cookbook.git', branch: 'add_provider-issue_45'

如果您使用的是 Policyfiles,则不要创建/修改 Berksfile 文件,而是将该行添加到您的 Policyfile.rb 文件中

【讨论】:

    猜你喜欢
    • 2013-03-22
    • 1970-01-01
    • 1970-01-01
    • 2016-07-04
    • 2011-12-27
    • 1970-01-01
    • 2019-11-19
    • 1970-01-01
    • 2014-01-22
    相关资源
    最近更新 更多