简体   繁体   English

检查厨师是否以厨师独奏的形式运行

[英]Check if chef is running as chef-solo

I'm using Vagrant and chef-solo to test my cookbooks, but I have one particular recipe that requires chef-server (it uses search). 我正在使用Vagrant和chef-solo来测试我的食谱,但我有一个特殊的食谱需要厨师服务器(它使用搜索)。 I'd like my default recipe to look like the following: 我希望我的默认配方如下所示:

include_recipe 'some_recipe'
include_recipe 'some_other_recipe'
unless running_as_chef_solo?
  include_recipe 'a_recipe_that_requires_chef_server'
end

How can I check whether chef is running as chef-solo from within a cookbook, so I can skip unsupported recipes? 如何检查厨师是否在菜谱中作为厨师独奏运行,所以我可以跳过不支持的食谱?

Use the Chef::Config object: 使用Chef::Config对象:

unless Chef::Config[:solo]
  include_recipe 'a_recipe_that_requires_chef_server'
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM