When you run chef-solo
locally (or chef-client
in a server setup) you are telling Chef to compile a set of resources defined in your cookbooks recipes to then be applied to the node you are running the command on.
A resource defines the tasks and settings for something you want to setup.
The run_list
set for the node defines what cookbook recipes will be compiled.
s3cmd
In your case, your run_list
will have probably been recipe[s3cmd]
.
This instructs Chef to look in the s3cmd
cookbook and as you didn't give a specific recipe, it loads s3cmd/recipes/default.rb
.
If you gave a specific recipe, like recipe[s3_cmd::other]
then Chef would load the file s3_cmd/recipes/other.rb
.
Chef will compile all the resources defined in the recipe(s) into a list and the run through the list applying changes as required to your system.
What s3cmd::default
does
First it installs some package
s (via your distributions package manager)
python, python-setuptools, python-distutils-extra, python-dateutil, s3cmd
Note: This is entirely different to what the readme says about how s3cmd
is installed! Always check!
Figures out where the config should go.
if node['s3cmd']['config_dir']
home_folder = node['s3cmd']['config_dir']
else
home_folder = node['etc']['passwd'][node['s3cmd']['user']]['dir']
end
Creates the .s3cfg
config file from a template
in the cookbook.
template "#{home_folder}/.s3cfg" do...
What else
Cookbooks can also define their own resources and providers to create more reusable cookbooks. The resource names and attributes will be defined in cookbook/resources/blah.rb
. The code for each resource action
will be in cookbook/providers/blah.rb
Code can be packaged in cookbook/libraries/blah.rb
and included in other Ruby files.
Run chef-solo
with the --log-level DEBUG
option and step through the output. Try and identify the run list compilation phase, and then where everything is being applied.