{"id":13480851,"url":"https://github.com/edelight/chef-mongodb","last_synced_at":"2025-12-17T03:04:19.909Z","repository":{"id":1623097,"uuid":"2308414","full_name":"edelight/chef-mongodb","owner":"edelight","description":"MongoDB Chef cookbook","archived":false,"fork":true,"pushed_at":"2017-04-12T06:27:03.000Z","size":2480,"stargazers_count":362,"open_issues_count":90,"forks_count":3,"subscribers_count":30,"default_branch":"master","last_synced_at":"2024-10-30T14:42:48.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://community.opscode.com/cookbooks/mongodb","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"arunjax/cookbooks-1","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edelight.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-09-01T15:28:09.000Z","updated_at":"2023-05-20T21:41:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/edelight/chef-mongodb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edelight%2Fchef-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edelight%2Fchef-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edelight%2Fchef-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edelight%2Fchef-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edelight","download_url":"https://codeload.github.com/edelight/chef-mongodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245836094,"owners_count":20680320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:00:45.851Z","updated_at":"2025-12-17T03:04:19.555Z","avatar_url":"https://github.com/edelight.png","language":"Ruby","funding_links":[],"categories":["Tools","Others"],"sub_categories":["Deployment"],"readme":"# MongoDB Cookbook\n\nInstalls and configures MongoDB, supporting:\n\n* Single MongoDB instance\n* Replication\n* Sharding\n* Replication and Sharding\n* 10gen repository package installation\n* 10gen MongoDB Monitoring System\n\n[![Build Status](https://travis-ci.org/edelight/chef-mongodb.png?branch=master)](https://travis-ci.org/edelight/chef-mongodb)\n\n## REQUIREMENTS:\n\nThis cookbook depends on these external cookbooks\n\n- apt\n- python\n- yum\n\nAs of 0.16 This Cookbook requires\n\n- Chef \u003e 11\n- Ruby \u003e 1.9\n\n### Platform:\n\nCurrently we 'actively' test using test-kitchen on Ubuntu, Debian, CentOS, Redhat\n\n## DEFINITIONS:\n\nThis cookbook contains a definition `mongodb_instance` which can be used to configure\na certain type of mongodb instance, like the default mongodb or various components\nof a sharded setup.\n\nFor examples see the USAGE section below.\n\n## ATTRIBUTES:\n\n### Mongodb Configuration\n\nBasically all settings defined in the Configuration File Options documentation page can be added to the `node['mongodb']['config'][\u003csetting\u003e]` attribute: http://docs.mongodb.org/manual/reference/configuration-options/\n\n* `node['mongodb']['config']['dbpath']` - Location for mongodb data directory, defaults to \"/var/lib/mongodb\"\n* `node['mongodb']['config']['logpath']` - Path for the logfiles, default is \"/var/log/mongodb/mongodb.log\"\n* `node['mongodb']['config']['port']` - Port the mongod listens on, default is 27017\n* `node['mongodb']['config']['rest']` - Enable the ReST interface of the webserver\n* `node['mongodb']['config']['smallfiles']` - Modify MongoDB to use a smaller default data file size\n* `node['mongodb']['config']['oplogsize']` - Specifies a maximum size in megabytes for the replication operation log\n* `node['mongodb']['config']['bind_ip']` - Configure from which address to accept connections\n* `node['mongodb']['config'][\u003csetting\u003e]` - General MongoDB Configuration File option\n\n### Cookbook specific attributes\n\n* `node[:mongodb][:reload_action]` - Action to take when MongoDB conf files are\n    modified, default is `\"restart\"`\n* `node[:mongodb][:package_version]` - Version of the MongoDB package to install, default is nil\n* `node[:mongodb][:client_role]` - Role identifying all external clients which should have access to a mongod instance\n\n### Sharding and replication attributes\n\n* `node['mongodb']['config']['replSet']` - Define name of replicaset\n* `node[:mongodb][:cluster_name]` - Name of the cluster, all members of the cluster must\n    reference to the same name, as this name is used internally to identify all\n    members of a cluster.\n* `node[:mongodb][:shard_name]` - Name of a shard, default is \"default\"\n* `node['mongodb']['sharded_collections']` - Define which collections are sharded\n* `node[:mongodb][:replica_arbiter_only]` - Set to true to make node an [arbiter](http://docs.mongodb.org/manual/reference/replica-configuration/#local.system.replset.members[n].arbiterOnly).\n* `node[:mongodb][:replica_build_indexes]` - Set to false to omit [index creation](http://docs.mongodb.org/manual/reference/replica-configuration/#local.system.replset.members[n].buildIndexes).\n* `node[:mongodb][:replica_hidden]` - Set to true to [hide](http://docs.mongodb.org/manual/reference/replica-configuration/#local.system.replset.members[n].hidden) node from replicaset.\n* `node[:mongodb][:replica_slave_delay]` - Number of seconds to [delay slave replication](http://docs.mongodb.org/manual/reference/replica-configuration/#local.system.replset.members[n].slaveDelay).\n* `node[:mongodb][:replica_priority]` - Node [priority](http://docs.mongodb.org/manual/reference/replica-configuration/#local.system.replset.members[n].priority).\n* `node[:mongodb][:replica_tags]` - Node [tags](http://docs.mongodb.org/manual/reference/replica-configuration/#local.system.replset.members[n].tags).\n* `node[:mongodb][:replica_votes]` - Number of [votes](http://docs.mongodb.org/manual/reference/replica-configuration/#local.system.replset.members[n].votes) node will cast in an election.\n\n\n### shared MMS Agent attributes\n\n* `node['mongodb']['mms_agent']['api_key']` - MMS Agent API Key. No default, required.\n* `node['mongodb['mms_agent']['monitoring']['version']` - Version of the MongoDB MMS Monitoring Agent package to download and install. Default is '2.0.0.17-1', required.\n* `node['mongodb['mms_agent']['monitoring'][\u003csetting\u003e]` - General MongoDB MMS Monitoring Agent configuration file option.\n* `node['mongodb['mms_agent']['backup']['version']` - Version of the MongoDB MMS Backup Agent package to download and install. Default is '1.4.3.28-1', required.\n* `node['mongodb['mms_agent']['backup'][\u003csetting\u003e]` - General MongoDB MMS Monitoring Agent configuration file option.\n\n### User management attributes\n\n* `node['mongodb']['config']['auth']` - Require authentication to access or modify the database\n* `node['mongodb']['admin']` - The admin user with userAdmin privileges that allows user management\n* `node['mongodb']['users']` - Array of users to add when running the user management recipe\n\n#### Monitoring Agent Settings\n\nThe defaults values installed by the package are:\n\n```\nmmsBaseUrl=https://mms.mongodb.com\nconfigCollectionsEnabled=true\nconfigDatabasesEnabled=true\nthrottlePassesShardChunkCounts = 10\nthrottlePassesDbstats = 20\nthrottlePassesOplog = 10\ndisableProfileDataCollection=false\ndisableGetLogsDataCollection=false\ndisableLocksAndRecordStatsDataCollection=false\nenableMunin=true\nuseSslForAllConnections=false\nsslRequireValidServerCertificates=false\n```\n\n#### Backup Agent Settings\n\nThe defaults values installed by the package are:\n\n```\nmothership=api-backup.mongodb.com\nhttps=true\nsslRequireValidServerCertificates=false\n```\n\n## USAGE:\n\n### 10gen\nAdds the stable [10gen repo](http://www.mongodb.org/downloads#packages) for the\ncorresponding platform. Currently only implemented for the Debian and Ubuntu repository.\n\nUsage: just add `recipe[mongodb::10gen_repo]` to the node run_list *before* any other\nMongoDB recipe, and the mongodb-10gen **stable** packages will be installed instead of the distribution default.\n\n### Single mongodb instance\n\nSimply add\n\n```ruby\ninclude_recipe \"mongodb::default\"\n```\n\nto your recipe. This will run the mongodb instance as configured by your distribution.\nYou can change the dbpath, logpath and port settings (see ATTRIBUTES) for this node by\nusing the `mongodb_instance` definition:\n\n```ruby\nmongodb_instance \"mongodb\" do\n  port node['application']['port']\nend\n```\n\nThis definition also allows you to run another mongod instance with a different\nname on the same node\n\n```ruby\nmongodb_instance \"my_instance\" do\n  port node['mongodb']['port'] + 100\n  dbpath \"/data/\"\nend\n```\n\nThe result is a new system service with\n\n```shell\n  /etc/init.d/my_instance \u003cstart|stop|restart|status\u003e\n```\n\n### Replicasets\n\nAdd `mongodb::replicaset` (instead of `mongodb::default`) to the node's run_list. Also choose a name for your\nreplicaset cluster and set the value of `node[:mongodb][:cluster_name]` for each\nmember to this name.\n\n### Sharding\n\nYou need a few more components, but the idea is the same: identification of the\nmembers with their different internal roles (mongos, configserver, etc.) is done via\nthe `node[:mongodb][:cluster_name]` and `node[:mongodb][:shard_name]` attributes.\n\nLet's have a look at a simple sharding setup, consisting of two shard servers, one\nconfig server and one mongos.\n\nFirst we would like to configure the two shards. For doing so, just use\n`mongodb::shard` in the node's run_list and define a unique `mongodb[:shard_name]`\nfor each of these two nodes, say \"shard1\" and \"shard2\".\n\nThen configure a node to act as a config server - by using the `mongodb::configserver`\nrecipe.\n\nAnd finally you need to configure the mongos. This can be done by using the\n`mongodb::mongos` recipe. The mongos needs some special configuration, as these\nmongos are actually doing the configuration of the whole sharded cluster.\nMost importantly you need to define what collections should be sharded by setting the\nattribute `mongodb[:sharded_collections]`:\n\n```ruby\n{\n  \"mongodb\": {\n    \"sharded_collections\": {\n      \"test.addressbook\": \"name\",\n      \"mydatabase.calendar\": \"date\"\n    }\n  }\n}\n```\n\nNow mongos will automatically enable sharding for the \"test\" and the \"mydatabase\"\ndatabase. Also the \"addressbook\" and the \"calendar\" collection will be sharded,\nwith sharding key \"name\" resp. \"date\".\nIn the context of a sharding cluster always keep in mind to use a single role\nwhich is added to all members of the cluster to identify all member nodes.\nAlso shard names are important to distinguish the different shards.\nThis is esp. important when you want to replicate shards.\n\n### Sharding + Replication\n\nThe setup is not much different to the one described above. All you have to do is add the\n`mongodb::replicaset` recipe to all shard nodes, and make sure that all shard\nnodes which should be in the same replicaset have the same shard name.\n\nFor more details, you can find a [tutorial for Sharding + Replication](https://github.com/edelight/chef-mongodb/wiki/MongoDB%3A-Replication%2BSharding) in the wiki.\n\n### MMS Agent\n\nThis cookbook also includes support for\n[MongoDB Monitoring System (MMS)](https://mms.mongodb.com/)\nagent. MMS is a hosted monitoring service, provided by 10gen, Inc. Once\nthe small python agent program is installed on the MongoDB host, it\nautomatically collects the metrics and uploads them to the MMS server.\nThe graphs of these metrics are shown on the web page. It helps a lot\nfor tackling MongoDB related problems, so MMS is the baseline for all\nproduction MongoDB deployments.\n\n\nTo setup MMS, simply set your keys in\n`node['mongodb']['mms_agent']['api_key']` and then add the\n`mongodb::mms-agent` recipe to your run list. Your current keys should\nbe available at your [MMS Settings page](https://mms.mongodb.com/settings).\n\n### User Management\n\nAn optional recipe is `mongodb::user_management` which will enable authentication in\nthe configuration file by default and create any users in the `node['mongodb']['users']`.\nThe users array expects a hash of username, password, roles, and database. Roles should be\nan array of roles the user should have on the database given.\n\nBy default, authentication is not required on the database. This can be overridden by setting\nthe `node['mongodb']['config']['auth']` attribute to true in the chef json.\n\nIf the auth configuration is true, it will try to create the `node['mongodb']['admin']` user, or\nupdate them if they already exist. Before using on a new database, ensure you're overwriting\nthe `node['mongodb']['admin']['username']` and `node['mongodb']['admin']['password']` to\nsomething besides their default values.\n\nThere's also a user resource which has the actions `:add`, `:modify` and `:delete`. If modify is\nused on a user that doesn't exist, it will be added. If add is used on a user that exists, it\nwill be modified.\n\n# LICENSE and AUTHOR:\n\nAuthor:: Markus Korn \u003cmarkus.korn@edelight.de\u003e\n\nCopyright:: 2011-2014, edelight GmbH\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedelight%2Fchef-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedelight%2Fchef-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedelight%2Fchef-mongodb/lists"}