Search code examples
chef-infraprovisioningchef-recipe

How should i use community chef cookbooks?


Should i just download finished community cookbooks from supermarket, or there is some special mechanism (or package manager) for them, and i can just import them in my recipes somehow?


Solution

  • You should use something like berkshelf to manage dependencies.

    So if you have a community cookbook like "rvm" and you want to use a portion of the cookbook you might create your own cookbook called "my_rvm"

    Then in "my_rvm" you would modify your "metadata.rb" file and add a dependency for "rvm":

    depends "rvm"
    

    then in the default recipe for "my_rvm" you might put a documented rvm recipe:

    include_recipe "rvm::system"
    

    Then in the root of your "my_rvm" cookbook you would type:

    berks install
    

    This will install the dependency cookbook on your workstation so that it is available to your new customized "my_rvm" cookbook.