Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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). 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?

like image 355
AndrewF Avatar asked Mar 09 '13 00:03

AndrewF


People also ask

Where is chef-Solo?

Unlike chef-client, where the node object is stored on the Chef server, chef-solo stores its node objects as JSON files on local disk. By default, chef-solo stores these files in a nodes folder in the same directory as your cookbooks directory.

What user does chef run as?

You probably should be running chef as root. Chef is running as a root user.


1 Answers

Use the Chef::Config object:

unless Chef::Config[:solo]
  include_recipe 'a_recipe_that_requires_chef_server'
end
like image 138
cmur2 Avatar answered Oct 03 '22 04:10

cmur2