Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

Ridley Chef Tool

A reliable Chef API client with a clean syntax

Install & Usage Instructions


Gem Version
Build Status
Dependency Status
Code Climate

A reliable Chef API client with a clean syntax


Add Ridley to your Gemfile:

gem 'ridley'

And run the bundle command to install. Alternatively, you can install the gem directly:

$ gem install ridley


Before you can use Ridley, you must require it in your application:

require 'ridley'

Creating a new Ridley client

ridley =
  server_url: "",
  client_name: "reset",
  client_key: "/Users/reset/.chef/reset.pem"

Creating a new instance of Ridley requires the following options:

  • server_url
  • client_name
  • client_key

client_key can be either a file path or the client key as a string. You can also optionally supply an encrypted data bag secret for decrypting encrypted data bags. The option is "encrypted_data_bag_secret" This can be a file name or the key itself as a string.

ridley =
  server_url: "",
  client_name: "reset",
  client_key: "some key data",
  encrypted_data_bag_secret: "File path or key as a string"

Ridley exposes a number of functions that return resources which you can use to retrieve or create objects on your Chef server. Here is a simple example of getting a list of all the roles on your Chef server.

ridley =
ridley.role.all #=> [
  #<Ridley::RoleObject chef_id:motherbrain_srv ...>,
  #<Ridley::RoleObject chef_id:motherbrain_proxy ...>

For more information scroll down to the Manipulating Chef Resources section of this README.

You can also tell Ridley to read the values from your Chef config (knife.rb):

ridley = Ridley.from_chef_config('/path/to/knife.rb')
ridley.role.all #=> [
  #<Ridley::RoleObject chef_id:motherbrain_srv ...>,
  #<Ridley::RoleObject chef_id:motherbrain_proxy ...>

The mapping between Chef Config values and Ridley values is:


Additionally, you can leave the path blank and Ridley will perform a "knife.rb search" the same way Chef does:

ridley = Ridley.from_chef_config
ridley.role.all #=> [
  #<Ridley::RoleObject chef_id:motherbrain_srv ...>,
  #<Ridley::RoleObject chef_id:motherbrain_proxy ...>

If you don't want to instantiate and manage a connection object you can use to open a connection, do some work, and it will be closed for you after the block executes. "", ...) do |r|

Manipulating Chef Resources

Resources are accessed by instance functions on a new instance of Ridley::Client.

ridley =
ridley.client      #=> Ridley::ClientResource
ridley.cookbook    #=> Ridley::CookbookResource
ridley.data_bag    #=> Ridley::DataBagResource
ridley.environment #=> Ridley::EnvironmentResource
ridley.node        #=> Ridley::NodeResource
ridley.role        #=> Ridley::RoleResource
ridley.sandbox     #=> Ridley::SandboxResource      #=> Ridley::SearchResource
ridley.user        #=> Ridley::UserResource

DataBagItems are the only exception to this rule. The DataBagItem resource is accessed from a DataBagObject

data_bag = ridley.data_bag.find("my_data")
data_bag.item                 #=> Ridley::DataBagItemResource
data_bag.item.find("my_item") #=> Ridley::DataBagItemObject


Most resources can be listed, retrieved, created, updated, and destroyed. These are commonly referred to as CRUD (Create Read Update Delete) operations.


A new Chef Object can be created in four ways

With the #create function and an attribute hash

ridley =
ridley.role.create(name: "reset") #=> #<Ridley::RoleObject: chef_id:reset>

With the #create function and an instance of a Chef Object

obj = = "reset"
ridley.role.create(obj) #=> #<Ridley::RoleObject: chef_id:reset>

With the #save function on an instance of a Chef Object

obj = = "reset" #=> #<Ridley::RoleObject: chef_id:reset>

With the #save function on an instance of a Chef Object built from serialized json

obj = ridley.role.from_file('/path/to/role.json') #=> #<:roleobject: chef_id:reset>

Each of these methods produce an identical object on the Chef server. It is up to you on how you'd like to create new resources.


Most resources have two read functions

  • #all for listing all the Chef Objects
  • #find for retrieving a specific Chef Object

If you want to get a list of all of the roles on your Chef server

ridley =
ridley.role.all #=> [
  #<Ridley::RoleObject chef_id:motherbrain_srv ...>,
  #<Ridley::RoleObject chef_id:motherbrain_proxy ...>

Notify: You have to send the #reload message to node objects returned from a full listing. Their attributes aren't automatically populated from the initial search.

ridley =
ridley.role.all.first  => #<Ridley::RoleObject chef_id:some_chef_id, attributes:#<VariaModel::Attributes chef_type="role" default_attributes=#<Hashie::Mash> description="" env_run_lists=#<VariaModel::Attributes> json_class="Chef::Role" name="some_chef_id" override_attributes=#<Hashie::Mash> run_list=[]>>
ridley.role.all.first.reload => #<Ridley::RoleObject chef_id:some_chef_id, attributes:#<VariaModel::Attributes chef_type="role" default_attributes=#<Hashie::Mash SOME ATTRIBUTES> description="Some description" env_run_lists=#<VariaModel::Attributes> json_class="Chef::Role" name="some_chef_id" override_attributes=#<Hashie::Mash> run_list=[ SOME RUN LIST ]>>

If you want to retrieve a single role from the Chef server

ridley =
ridley.role.find("motherbrain_srv") #=> #<Ridley::RoleObject: chef_id:motherbrain_srv ...>

If the role does not exist on the Chef server then nil is returned

ridley =
ridley.role.find("not_there") #=> nil


Updating a resource can be expressed in three ways

With the #update function, the ID of the Object to update, and an attributes hash

ridley =
ridley.role.update("motherbrain_srv", description: "testing updates") #=> #<Ridley::RoleObject chef_id:motherbrain_srv, description="testing updates" ...>

With the #update function and an instance of a Chef Object

obj = ridley.role.find("motherbrain_srv")
obj.description = "chef object"

ridley.role.update(obj) #=> #<Ridley::RoleObject: chef_id:motherbrain_srv, description="chef object" ...

With the #save function on an instance of a Chef Object

obj = ridley.role.find("reset")
obj.description = "saving an object" #=> #<Ridley::RoleObject: chef_id:motherbrain_srv, description="saving an object" ...>


Destroying a resource can be expressed in three ways

With the #delete function and the ID of the Object to destroy

ridley =
ridley.role.delete("motherbrain_srv") => #<Ridley::RoleObject: chef_id:motherbrain_srv ...>

With the #delete function and a Chef Object

obj = ridley.role.find("motherbrain_srv")
ridley.role.delete(obj) => #<Ridley::RoleObject: chef_id:motherbrain_srv ...>

With the #destroy function on an instance of a Chef Object

obj = ridley.role.find("motherbrain_srv")
obj.destroy #=> true

Client Resource

Regenerating a client's private key

With the #regnerate_key function and the ID of the Client to regenerate

ridley =
ridley.client.regenerate_key("jamie") #=> #<Ridley::ClientObject: chef_id:"jamie", private_key="**HIDDEN***" ...>

With the #regenerate_key function on an instance of a Client Object

obj = ridley.client.find("jamie")
obj.regenerate_key #=> #<Ridley::ClientObject: chef_id:"jamie", private_key="**HIDDEN***" ...>

Cookbook Resource

Cookbooks can be created, listed, updated and deleted as shown in the Manipulating Chef Resources section of this README.

To find a cookbook, you must provide both its name and version:

ridley =
ridley.cookbook.find("apache2", "1.6.6")

Cookbooks can be downloaded. If no download path is specified, the chosen cookbook will be downloaded to a tmp folder.

ridley ="apache2", "1.6.6", "/path/to/download/cookbook") #=> "/path/to/download/cookbook""apache2", "1.6.6") #=> "/tmp/d20140211-6621-kstalp"

A cookbook's metadata can be accessed using the #metadata method:

ridley =
apache2 = ridley.cookbook.find("apache2", "1.6.6")
apache2.metadata #=> Hashie::Mash

Data Bag Resource

A data bag is managed exactly the same as any other Chef resource

ridley =
ridley.data_bag.create(name: "ridley-test")

You can create, delete, update, or retrieve a data bag exactly how you would expect if you read through the
Manipulating Chef Resources portion of this document.

Unlike a role, node, client, or environment, a data bag is a container for other resources. These other resources are Data Bag Items. Data Bag Items behave slightly different than other resources. Data Bag Items can have an abritrary attribute hash filled with any key values that you would like. The one exception is that every Data Bag Item requires an 'id' key and value. This identifier is the name of the Data Bag Item.

Creating a Data Bag Item

ridley   =
data_bag = ridley.data_bag.create(name: "ridley-test")

data_bag.item.create(id: "appconfig", host: "reset.local", user: "jamie") #=> #<Ridley::DataBagItemObject: chef_id:appconfig, host="reset.local", user="jamie">

Environment Resource

Setting Attributes

Setting a default environment attribute is just like setting a node level default attribute

ridley =
production_env = ridley.environment.find("production")
production_env.set_default_attribute("my_app.proxy.enabled", false) #=> true

And the same goes for setting an environment level override attribute

production_env.set_override_attribute("my_app.proxy.enabled", false) #=> true

Role Resource

Role Attributes

Setting role attributes is just like setting node and environment attributes

ridley =
my_app_role = ridley.role.find("my_app")
my_app_role.set_default_attribute("my_app.proxy.enabled", false) #=> true

And the same goes for setting an environment level override attribute

my_app_role.set_override_attribute("my_app.proxy.enabled", false) #=> true

Sandbox Resource

Search Resource

ridley =, "name:ridley-test.local")

Search will return an array of the appropriate Chef Objects if one of the default indices is specified. The indices are

  • node
  • role
  • client
  • environment

User Resource

Regenerating a user's private key

Works the same way as with a client resource.

Authenticating a user's password

ridley =
ridley.user.authenticate('username', 'password')

Authors and Contributors

Thank you to all of our Contributors, testers, and users.