0

I am using Chef and this s3cmd cookbook.

As this tutorial says I use knife to download and tar it. I actually made s3cmd work following the tutorial instructions, but I have problems understanding where exactly the installation of s3cmd is happening?

Can anyone explain to me what Chef is doing when using the s3cmd recipe?

Matt
  • 68,711
  • 7
  • 155
  • 158
user2266685
  • 191
  • 1
  • 2
  • 8
  • Could you link to the recipe and tutorial you are using? What have you added to your nodes run list? Have you looked at DEBUG logs for the `chef-client` run? – Matt Sep 10 '14 at 10:29
  • I use this tutorial: http://gettingstartedwithchef.com/first-steps-with-chef.html – user2266685 Sep 10 '14 at 10:35
  • And I use this for my s3cmd configuration : https://github.com/fred/chef-s3cmd – user2266685 Sep 10 '14 at 10:35
  • Ok. So you have added the recipe to a node's run list and it has installed `s3cmd` successfully? You just want to know how? – Matt Sep 10 '14 at 10:53
  • Yes, everything works, I just don't see where and how chef installs it for me, I need to know in order to administer my server correctly. – user2266685 Sep 10 '14 at 10:58

1 Answers1

0

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

  1. First it installs some packages (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!

  2. 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
    
  3. 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.

Matt
  • 68,711
  • 7
  • 155
  • 158