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

The mongodb cookbook has been deprecated

Author provided reason for deprecation:

The mongodb cookbook has been deprecated and is no longer being maintained by its authors. Use of the mongodb cookbook is no longer recommended.

You may find that the sc-mongodb cookbook is a suitable alternative.


mongodb (11) Versions 0.15.1

Installs and configures mongodb

cookbook 'mongodb', '= 0.15.1', :supermarket
cookbook 'mongodb', '= 0.15.1'
knife supermarket install mongodb
knife supermarket download mongodb
Quality -%

Build Status


Installs and configures MongoDB, supporting:

  • Single MongoDB
  • Replication
  • Sharding
  • Replication and Sharding
  • 10gen repository package installation
  • 10gen MongoDB Monitoring System


This cookbook depends on these external cookbooks

  • apt
  • python
  • runit
  • yum


The cookbook aims to be platform independent, but is best tested on debian squeeze systems.

The 10gen_repo recipe configures the package manager to use 10gen's
official package repositories on Debian, Ubuntu, Redhat, CentOS, Fedora, and
Amazon linux distributions.


This cookbook contains a definition mongodb_instance which can be used to configure
a certain type of mongodb instance, like the default mongodb or various components
of a sharded setup.

For examples see the USAGE section below.


Mongodb Configuration

Basically all settings defined in the Configuration File Options documentation page can be added to the mongodb[:config][:<setting>] attribute:

  • mongodb[:config][:dbpath] - Location for mongodb data directory, defaults to "/var/lib/mongodb"
  • mongodb[:config][:logpath] - Path for the logfiles, default is "/var/log/mongodb/mongodb.log"
  • mongodb[:config][:port] - Port the mongod listens on, default is 27017
  • mongodb[:config][:rest] - Enable the ReST interface of the webserver
  • mongodb[:config][:smallfiles] - Modify MongoDB to use a smaller default data file size
  • mongodb[:config][:oplogsize] - Specifies a maximum size in megabytes for the replication operation log
  • mongodb[:config][:bind_ip] - Configure from which address to accept connections
  • mongodb[:config][:<setting>] - General MongoDB Configuration File option

Cookbook specific attributes

  • mongodb[:reload_action] - Action to take when MongoDB conf files are modified, default is "restart"
  • mongodb[:package_version] - Version of the MongoDB package to install, default is nil
  • mongodb[:client_role] - Role identifying all external clients which should have access to a mongod instance

Sharding and replication attributes

  • mongodb[:config][:replSet] - Define name of replicaset
  • mongodb[:cluster_name] - Name of the cluster, all members of the cluster must reference to the same name, as this name is used internally to identify all members of a cluster.
  • mongodb[:shard_name] - Name of a shard, default is "default"
  • mongodb[:sharded_collections] - Define which collections are sharded
  • mongodb[:replica_arbiter_only] - Set to true to make node an arbiter.
  • mongodb[:replica_build_indexes] - Set to false to omit index creation.
  • mongodb[:replica_hidden] - Set to true to hide node from replicaset.
  • mongodb[:replica_slave_delay] - Number of seconds to delay slave replication.
  • mongodb[:replica_priority] - Node priority.
  • mongodb[:replica_tags] - Node tags.
  • mongodb[:replica_votes] - Number of votes node will cast in an election.

MMS Agent attributes

  • mongodb[:mms_agent][:api_key] - MMS Agent API Key. No default, required.
  • mongodb[:mms_agent][:monitoring][:version] - Version of the MongoDB MMS Monitoring Agent package to download and install. Default is '', required.
  • mongodb[:mms_agent][:monitoring][:<setting>] - General MongoDB MMS Monitoring Agent configuration file option.
  • mongodb[:mms_agent][:backup][:version] - Version of the MongoDB MMS Backup Agent package to download and install. Default is '', required.
  • mongodb[:mms_agent][:backup][:<setting>] - General MongoDB MMS Monitoring Agent configuration file option.

Monitoring Agent Settings

The defaults values installed by the package are:

throttlePassesShardChunkCounts = 10
throttlePassesDbstats = 20
throttlePassesOplog = 10

Backup Agent Settings

The defaults values installed by the package are:



Adds the stable 10gen repo for the
corresponding platform. Currently only implemented for the Debian and Ubuntu repository.

Usage: just add recipe[mongodb::10gen_repo] to the node run_list before any other
MongoDB recipe, and the mongodb-10gen stable packages will be installed instead of the distribution default.

Single mongodb instance

Simply add

include_recipe "mongodb::default"

to your recipe. This will run the mongodb instance as configured by your distribution.
You can change the dbpath, logpath and port settings (see ATTRIBUTES) for this node by
using the mongodb_instance definition:

mongodb_instance "mongodb" do
  port node['application']['port']

This definition also allows you to run another mongod instance with a different
name on the same node

mongodb_instance "my_instance" do
  port node['mongodb']['port'] + 100
  dbpath "/data/"

The result is a new system service with

  /etc/init.d/my_instance <start|stop|restart|status>


Add mongodb::replicaset (instead of mongodb::default) to the node's run_list. Also choose a name for your
replicaset cluster and set the value of node[:mongodb][:cluster_name] for each
member to this name.


You need a few more components, but the idea is the same: identification of the
members with their different internal roles (mongos, configserver, etc.) is done via
the node[:mongodb][:cluster_name] and node[:mongodb][:shard_name] attributes.

Let's have a look at a simple sharding setup, consisting of two shard servers, one
config server and one mongos.

First we would like to configure the two shards. For doing so, just use
mongodb::shard in the node's run_list and define a unique mongodb[:shard_name]
for each of these two nodes, say "shard1" and "shard2".

Then configure a node to act as a config server - by using the mongodb::configserver

And finally you need to configure the mongos. This can be done by using the
mongodb::mongos recipe. The mongos needs some special configuration, as these
mongos are actually doing the configuration of the whole sharded cluster.
Most importantly you need to define what collections should be sharded by setting the
attribute mongodb[:sharded_collections]:

  "mongodb": {
    "sharded_collections": {
      "test.addressbook": "name",
      "mydatabase.calendar": "date"

Now mongos will automatically enable sharding for the "test" and the "mydatabase"
database. Also the "addressbook" and the "calendar" collection will be sharded,
with sharding key "name" resp. "date".
In the context of a sharding cluster always keep in mind to use a single role
which is added to all members of the cluster to identify all member nodes.
Also shard names are important to distinguish the different shards.
This is esp. important when you want to replicate shards.

Sharding + Replication

The setup is not much different to the one described above. All you have to do is adding the
mongodb::replicaset recipe to all shard nodes, and make sure that all shard
nodes which should be in the same replicaset have the same shard name.

For more details, you can find a tutorial for Sharding + Replication in the wiki.

MMS Agent

This cookbook also includes support for
{MongoDB Monitoring System (MMS)}[]
agent. MMS is a hosted monitoring service, provided by 10gen, Inc. Once
the small python agent program is installed on the MongoDB host, it
automatically collects the metrics and upload them to the MMS server.
The graphs of these metrics are shown on the web page. It helps a lot
for tackling MongoDB related problems, so MMS is the baseline for all
production MongoDB deployments.

To setup MMS, simply set your keys in
node['mongodb']['mms_agent']['api_key'] and then add the
mongodb::mms-agent recipe to your run list. Your current keys should
be available at your {MMS Settings page}[].


Author:: Markus Korn

Copyright:: 2011, edelight GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Dependent cookbooks

apt >= 1.8.2
python < 1.4.6
runit < 1.5.0
yum < 3.0

Contingent cookbooks

cloudfoundry-mongodb-service Applicable Versions
cloudless-box Applicable Versions
cube Applicable Versions
errbit Applicable Versions
errbit-server Applicable Versions
graylog Applicable Versions
graylog2 Applicable Versions
greysystems-mongodb Applicable Versions
nodestack Applicable Versions
pa11y Applicable Versions
phpstack Applicable Versions
pythonstack Applicable Versions
razor Applicable Versions
rocketchat Applicable Versions
seyren Applicable Versions
stack_commons Applicable Versions
stackstorm Applicable Versions
tyk Applicable Versions
uptime Applicable Versions

No quality metric results found