Version information
This version is compatible with:
- Puppet Enterprise 3.x
- Puppet >=2.7.20 <5.0.0
- RedHat, CentOS, Scientific, Debian, Ubuntu
Start using this module
Add this module to your Puppetfile:
mod 'dwerder-mongodb', '3.5.0'
Learn more about managing modules with a PuppetfileDocumentation
#mongodb
####Table of Contents
- Overview - What is the mongodb module?
- Module Description - What does this module do?
- Setup - The basics of getting started with mongodb
- Usage - The class and defined types available for configuration
- Requirements
- Limitations - OS compatibility, etc.
- Contributing to the mongodb module
##Overview
This module installs and makes basic configs for mongodb. That includes mongod and mongos. Out-of-the-box the defaults are set to install a mongodb version 2.4.x. If you want to use 2.6 see the setup examples below.
##Module Description
MongoDB, is an open-source document database, and the leading NoSQL database. This module can be used to set up a simple standalone DB or all components for a full sharding cluster.
##Setup
What mongodb affects:
- repos/packages/services/basic configuration files for MongoDB
What mongodb NOT affects:
- internal configuration of your MongoDB cluster, like Sharding Members and so on
###Beginning with MongoDB
Starting with a mongodb server with replSet. This will install a 2.4.x version MongoDB:
include mongodb
mongodb::mongod {
'my_mongod_instanceX':
mongod_instance => 'mongodb1',
mongod_replSet => 'mongoShard1',
mongod_add_options => ['slowms = 50']
}
###Install MongoDB version 2.6
class { 'mongodb':
package_name => 'mongodb-org',
logdir => '/var/log/mongodb/',
# only debian like distros
old_servicename => 'mongod'
}
mongodb::mongod {
'my_mongod_instanceX':
mongod_instance => 'mongodb1',
mongod_replSet => 'mongoShard1',
mongod_add_options => ['slowms = 50']
}
###Install exact version
Holy shit, I work in an enterprise environment. I need an specific version. So on a RHEL like system it would look like this:
# mongodb 2.6.x
class { 'mongodb':
package_name => 'mongodb-org',
package_ensure => '2.6.2-1',
logdir => '/var/log/mongodb/',
# only debian like distros
old_servicename => 'mongod'
}
# mongodb 2.4.x
class { 'mongodb':
package_ensure => '2.4.10-mongodb_1',
logdir => '/var/log/mongodb/'
}
###Configure MongoDB with run as user
Now we change the run as user and logdir path.
class { 'mongodb':
run_as_user => mongod,
run_as_group => wheel,
logdir => '/nfsshare/mymongologs/'
}
mongodb::mongod {
'my_mongod_instanceX':
mongod_instance => 'mongodb1',
mongod_replSet => 'mongoShard1',
mongod_add_options => ['slowms = 20']
}
###Configuration mongodb cluster
And here is a more complex example of building a mongo sharding cluster 4 nodes (3 of them config server) with 4 shards in replication.
node mongo_sharding_default {
# Install MongoDB
include mongodb
# Install the MongoDB shard server
mongodb::mongod { 'mongod_Shard1':
mongod_instance => 'Shard1',
mongod_port => 27019,
mongod_replSet => 'Shard1',
mongod_shardsvr => 'true'
}
mongodb::mongod { 'mongod_Shard2':
mongod_instance => 'Shard2',
mongod_port => 27020,
mongod_replSet => 'Shard2',
mongod_shardsvr => 'true'
}
mongodb::mongod { 'mongod_Shard3':
mongod_instance => 'Shard3',
mongod_port => 27021,
mongod_replSet => 'Shard3',
mongod_shardsvr => 'true'
}
mongodb::mongod { 'mongod_Shard4':
mongod_instance => 'Shard4',
mongod_port => 27022,
mongod_replSet => 'Shard4',
mongod_shardsvr => 'true'
}
# Install the MongoDB Loadbalancer server
mongodb::mongos { 'mongos_shardproxy':
mongos_instance => 'mongoproxy',
mongos_port => 27017,
mongos_configServers => 'mongo1.my.domain:27018,mongo2.my.domain:27018,mongo3.my.domain:27018'
}
}
# This three nodes are shard members and run a mongoS
node 'mongo1.my.domain',
'mongo2.my.domain',
'mongo3.my.domain' inherits mongo_sharding_default {
# Install the MongoDB config server
include mongodb
mongodb::mongod { 'mongod_config':
mongod_instance => 'shardproxy',
mongod_port => 27018,
mongod_replSet => '',
mongod_configsvr => 'true'
}
}
# This node is just a shard member
node 'mongo4.my.domain' inherits mongo_sharding_default { }
##Usage
###Classes and Defined Types
This module installs mongodb from the repo with class mongodb
.
The redis service(s) are configured with the defined type redis::server
.
####Class: mongodb
This class installs mongodb packages and makes basic install configurations.
It does not configure any mongo services. This is done by defined type
mongodb::mongod
and mongodb::mongos
.
Most global parameters are set in params.pp and should fit the most use cases. But you can also set them, when including class mongodb.
Parameters within mongodb
:
#####dbdir
Default is '/var/lib' (string). This is the root directory where the mongo instances will create their own subdirectories.
#####pidfilepath
Default is dbdir
.
#####logdir
Default on Redhat '/var/log/mongo' and on Debian '/var/log/mongodb'.
#####logrotatenumber
Number of days to keep the logfiles.
#####package_ensure
Default is 'installed' . Here you can choose the version to be installed.
#####repo_manage
Default is true (boolean). Choose if this module should manage the repos needed to install the mongodb packages.
#####ulimit_nofiles
Default is 64000 (integer). Number of allowed filehandles. See recommendations
#####ulimit_nproc
Default is 32000 (integer). See recommendations
#####run_as_user
Default on Redhat is 'mongod' and on Debian 'mongodb' (string). The user the mongod is run with.
#####run_as_group
Default on Redhat is 'mongod' and on Debian 'mongodb' (string). The group the mongod is run with.
#####old_servicename
Default on Redhat is 'mongod' and on Debian 'mongodb' (string). Name of the origin mongodb package service. his will be deactivated.
####Defined Type: mongodb::mongod
Used to configure mongoD instances. You can setup multiple mongodb servers on the same node. See the setup examples.
**Parameters within mongodb::mongod
#####mongod_instance
Despription of mongd service (shard1, config, etc) (required)
#####mongod_bind_ip
Default is '' (empty string). So listen in all.
#####mongod_port
Listen port (defaul: 27017)
#####mongod_replSet
Name of ReplSet (optional)
#####mongod_enable
Enable/Disable service at boot (default: true)
#####mongod_running
Start/Stop service (default: true)
#####mongod_configsvr
Is config server true/false (default: false)
#####mongod_shardsvr
Is shard server true/false (default: false)
#####mongod_logappend
Enable/Disable log file appending (default: true)
#####mongod_rest
Enable/Disable REST api (default: true)
#####mongod_fork
Enable/Disable fork of mongod process (default: true)
#####mongod_auth
Enable/Disable auth true/false (default: false)
#####mongod_useauth
Keyfile contents. Your random string/false (default: false)
#####mongod_monit
Use monit monitoring for mongod instances (default: false)
#####mongod_add_options
Array. Each field is "key" or "key=value" for parameters for config file
####Defined Type: mongodb::mongos
Used to configure mongoS instances. You can setup multiple mongodb proxy servers on the same node. See the setup examples.
**Parameters within mongodb::mongos
#####mongos_instance
Despription of mongd service (shard1, config, etc) (required)
#####mongos_bind_ip
Listen ip (defaul: emtpy, so listen in all)
#####mongos_port
Listen port (defaul: 27017)
#####mongos_configServers
String with comma seperated list of config servers (optional)
#####mongos_enable
Enable/Disable service at boot (default: true)
#####mongos_running
Start/Stop service (default: true)
#####mongos_logappend
Enable/Disable log file appending (default: true)
#####mongos_fork
Enable/Disable fork of mongod process (default: true)
#####mongos_useauth
Keyfile contents. Your random string/false (default: false)
#####mongos_add_options
Array. Each field is "key" or "key=value" for parameters for config file
##Requirements
###Modules needed:
- puppetlabs-stdlib
- rodjek-logrotate
- puppetlabs-apt ( only for Debian/Ubuntu )
###Software versions needed:
- facter > 1.6.2
- puppet > 2.6.2
On Redhat distributions you need the EPEL or RPMforge repository, because Graphite needs packages, which are not part of the default repos.
##Limitations
This module is tested on CentOS 6.5 and should also run without problems on
- RHEL/CentOS/Scientific 6+
- Debian 6+
- Ubunutu 10.04 and newer
##Contributing
Echocat modules are open projects. So if you want to make this module even better, you can contribute to this module on Github.
2016-01-18 - 3.5.0 (Feature release)
Features:
- add parameter
mongod_deactivate_transparent_hugepage
for mongod - use of module rodjek/logrotate instead of own logrotate functions
- add repos for debain and mongo 3.x versions
2014-12-11 - 3.4.3 (Bugfix release)
Bugfixes:
- puppet-lint to match "approved" requirements
- add first spec tests
- fail on unsupported OS
2014-12-02 - 3.4.2 (Bugfix release)
Bugfixes:
- inheriting
old_servicename
correctly from main classmongodb
- fix different apt source for debian and ubuntu
2014-11-08 - 3.4.1 (Bugfix release)
Features:
- set some more ulimits default
- cleanup newlines and whitespaces
Bugfixes:
- fix absolute variable path from params.pp
- Debian: remove --make-pidfile , because mongod sets pidfile itself
2014-06-23 - 3.4.0 (Feature release)
Features:
- specify
package_name
andpackage_ensure
to install specific version - new README examples for version 2.6.x
Bugfixes:
- Debian init script uses pidfile correct
- fix package naming on Debian-like systems
- package names are version 2.6.x compatiple now
2014-04-22 - 3.3.1 (Bugfix release)
- set ulimit nproc (number of processes) to recommend value 32k (was 1024)
- add parameter to set ulimit nproc
- complete rewrite of README
2014-01-10 - 3.3.0 (Feature release)
- you can specify which version of mongodb to be installed (package_ensure)
- ensure default init script is replaced on ubuntu on puppet >3.3
- parameter logrotate_package_manage allows you to specify if this module should install logrotate package
2013-12-11 - 3.2.1 (Bugfix release)
- fix a bunch of changed variables
2013-12-11 - 3.2.0
- Release adds some more flexability for global parameters
- add @ to puppet variables in erb, to avoid warnings
- added user, group, old_servicename parameters to class mongodb
- update Monit configuration file path for Ubuntu
Dependencies
- puppetlabs/stdlib (>= 3.2.0)
- puppetlabs/apt (>= 1.1.0)
- rodjek/logrotate (>= 1.1.1)
Version: Apache 2.0 echocat puppet-mongodb, Copyright (c) 2014 echocat 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 http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.