在厨师中加入第三方资源

问题描述 投票:1回答:1

我正在尝试使用 厨师-gsettings

# ./cookbooks/my_cookbook/recipes/default.rb
include_recipe 'chef-gsettings'

同时将其上传到Chef Server与

$ knife cookbook upload chef-gsettings

但是引导失败

$ knife bootstrap 192.168.1.88 -U user -i ~/.ssh/id --node-name node1 --sudo --run-list 'recipe[my_cookbook]' 
...
FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe default for cookbook chef-gsettings
chef
1个回答
1
投票

正如你可以看到。厨师-gsettings 烹饪书中没有任何食谱。它只是提供了一个 gsettings 在你的烹饪书中使用的资源。

但在这里你包括 chef-gsettings::default 菜谱(只提供菜谱名称而省略菜谱,意味着您包括了 ::default 配方)。)

# ./cookbooks/my_cookbook/recipes/default.rb
include_recipe 'chef-gsettings'

这就是为什么会出现错误。

FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe default for cookbook chef-gsettings

实际上,你需要使用 gsettings 资源在您的配方中 (参见readme中的用法):

# ./cookbooks/my_cookbook/recipes/default.rb
gsettings "org.gnome.desktop.interface" do
  option "monospace-font-name"
  value "Monospace 14"
  user "bob"
end

如果这不起作用,这是有可能的,因为你是以 "chef-gsettings "而不是 "gsettings "的形式导入这本烹饪书的,你需要使用... ... chef-gsettings 资源。

# ./cookbooks/my_cookbook/recipes/default.rb
chef-gsettings "org.gnome.desktop.interface" do  # !!! this will not work, as Ruby does not allow `-` in method names
  [...]
end

# Try using this workaround instead:
declare_resource('chef-gsettings'.to_sym, "org.gnome.desktop.interface") do
  option "monospace-font-name"
  [...]
end
© www.soinside.com 2019 - 2024. All rights reserved.