在 Chef 中包含第三方资源
Include third party resource in chef
我正在尝试使用 chef-gsettings
# ./cookbooks/my_cookbook/recipes/default.rb
include_recipe 'chef-gsettings'
也用
上传到 Chef Server
$ knife cookbook upload chef-gsettings
但是bootstrap失败了
$ 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-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 资源 (see Usage in 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
我正在尝试使用 chef-gsettings
# ./cookbooks/my_cookbook/recipes/default.rb
include_recipe 'chef-gsettings'
也用
上传到 Chef Server$ knife cookbook upload chef-gsettings
但是bootstrap失败了
$ 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-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 资源 (see Usage in 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