The chef-zero or "local-mode" of chef-client should be used to apply a cookbook to the server that you run it on without involving a full blown Chef Server of any kind. It does this by firing up a mini chef server that requires zero configuration in the background and uploding your cookbooks to it and doing a real chef-client converge against it, completely transparently. This allows you to use all the features of Chef without the need to think about running a server.
There is also the chef-solo
utility that is similar, but is limited in that it cannot talk to a chef server at all, and therefore features like search are architecturally broken. Ideally, it should not be used for new development work.
The chef-apply
utility that can be used to converge resources in a single file against a host without a server and without any cookbook structure at all. Since there is no available structure other than the recipe file features like search, data bags, templates and other resources are architecturally broken. It is most useful for quickly testing some of the resources which do not require talking to a chef server.
create a directory for a sandbox:
mkdir ~/zero
cd ~/zero
create a cookbooks directory under that, with single 'test' cookbook and a single 'default.rb' recipe:
mkdir -p cookbooks/test/recipes
vim cookbooks/test/recipes/default.rb
put some resources in your recipe:
file "/tmp/arglebargle" do
content "arglebargle"
end
converge:
chef-client -z -r 'recipe[test::default]'
Put them alongside the cookbooks directory just like in a normal chef-repo:
mkdir {roles,data_bags,environments}
For setting arbitrary node data (or setting the run_list
via the JSON and not the -r option), use the -j option:
vim dna.json
with contents like:
{
"run_list": [ "recipe[test::default]" ]
}
and run:
chef-client -z -j dna.json