How to run a chef cookbook?
knife cookbook site download
just gives you a raw tarball, not in a format you can use with Chef directly. If you're looking for a fully-feature chef-solo workflow I would use the knife-solo
plugin together with Berkshelf.
Put the cookbooks you want to use in the Berksfile
and then use knife solo cook
to transfer them to the target node and run chef-solo
.
@coderanger advised to use berkshelf and the following snippets were found in this documentation:
Berksfile
source "https://supermarket.chef.io"
cookbook "terraform"
Installing the cookbooks
user@host ~ $ berks install
Resolving cookbook dependencies...
Fetching cookbook index from https://supermarket.chef.io...
Installing ark (1.1.0)
Installing compat_resource (12.16.2)
Installing seven_zip (2.0.2)
Installing build-essential (7.0.2)
Installing ohai (4.2.2)
Using terraform (0.5.3)
Installing mingw (1.2.4)
Installing windows (2.1.1)
run berks vendor
user@host ~ $ berks vendor
Resolving cookbook dependencies...
Using terraform (0.5.3)
Using ark (1.1.0)
Using mingw (1.2.4)
Using ohai (4.2.2)
Using build-essential (7.0.2)
Using seven_zip (2.0.2)
Using compat_resource (12.16.2)
Using windows (2.1.1)
Vendoring ark (1.1.0) to /home/user/berks-cookbooks/ark
Vendoring build-essential (7.0.2) to /home/user/berks-cookbooks/build-essential
Vendoring compat_resource (12.16.2) to /home/user/berks-cookbooks/compat_resource
Vendoring mingw (1.2.4) to /home/user/berks-cookbooks/mingw
Vendoring ohai (4.2.2) to /home/user/berks-cookbooks/ohai
Vendoring seven_zip (2.0.2) to /home/user/berks-cookbooks/seven_zip
Vendoring terraform (0.5.3) to /home/user/berks-cookbooks/terraform
Vendoring windows (2.1.1) to /home/user/berks-cookbooks/windows
the following snippets are based on this answer:
config.rb
cookbook_path [
'/home/user/berks-cookbooks'
]
config.json
{
"run_list": [
"terraform"
]
}
Run
sudo chef-solo -c config.rb -j config.json