Puppet Class: mongodb::server
- Inherits:
- mongodb::params
- Defined in:
- manifests/server.pp
Overview
This installs a MongoDB server. See README.md for more details.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'manifests/server.pp', line 2
class mongodb::server (
$ensure = $mongodb::params::ensure,
$user = $mongodb::params::user,
$group = $mongodb::params::group,
$config = $mongodb::params::config,
$dbpath = $mongodb::params::dbpath,
$dbpath_fix = $mongodb::params::dbpath_fix,
$pidfilepath = $mongodb::params::pidfilepath,
$pidfilemode = $mongodb::params::pidfilemode,
$manage_pidfile = $mongodb::params::manage_pidfile,
$rcfile = $mongodb::params::rcfile,
$service_manage = $mongodb::params::service_manage,
$service_provider = $mongodb::params::service_provider,
$service_name = $mongodb::params::service_name,
$service_enable = $mongodb::params::service_enable,
$service_ensure = $mongodb::params::service_ensure,
$service_status = $mongodb::params::service_status,
$package_ensure = $mongodb::params::package_ensure,
$package_name = $mongodb::params::server_package_name,
$logpath = $mongodb::params::logpath,
$bind_ip = $mongodb::params::bind_ip,
$ipv6 = undef,
$logappend = true,
$system_logrotate = undef,
$fork = $mongodb::params::fork,
$port = undef,
$journal = $mongodb::params::journal,
$nojournal = undef,
$smallfiles = undef,
$cpu = undef,
$auth = false,
$noauth = undef,
$verbose = undef,
$verbositylevel = undef,
$objcheck = undef,
$quota = undef,
$quotafiles = undef,
$diaglog = undef,
$directoryperdb = undef,
$profile = undef,
$maxconns = undef,
$oplog_size = undef,
$nohints = undef,
$nohttpinterface = undef,
$noscripting = undef,
$notablescan = undef,
$noprealloc = undef,
$nssize = undef,
$mms_token = undef,
$mms_name = undef,
$mms_interval = undef,
$replset = undef,
$replset_config = undef,
$replset_members = undef,
$configsvr = undef,
$shardsvr = undef,
$rest = undef,
$quiet = undef,
$slowms = undef,
$keyfile = undef,
$key = undef,
$set_parameter = undef,
$syslog = undef,
$config_content = undef,
$config_template = undef,
$ssl = undef,
$ssl_key = undef,
$ssl_ca = undef,
$ssl_weak_cert = false,
$restart = $mongodb::params::restart,
$storage_engine = undef,
$create_admin = $mongodb::params::create_admin,
$admin_username = $mongodb::params::admin_username,
$admin_password = undef,
$handle_creds = $mongodb::params::handle_creds,
$store_creds = $mongodb::params::store_creds,
$admin_roles = ['userAdmin', 'readWrite', 'dbAdmin',
'dbAdminAnyDatabase', 'readAnyDatabase',
'readWriteAnyDatabase', 'userAdminAnyDatabase',
'clusterAdmin', 'clusterManager', 'clusterMonitor',
'hostManager', 'root', 'restore'],
# Deprecated parameters
$master = undef,
$slave = undef,
$only = undef,
$source = undef,
) inherits mongodb::params {
if $ssl {
validate_string($ssl_key, $ssl_ca)
validate_bool($ssl_weak_cert)
}
if ($ensure == 'present' or $ensure == true) {
if $restart {
anchor { 'mongodb::server::start': }
-> class { 'mongodb::server::install': }
# If $restart is true, notify the service on config changes (~>)
-> class { 'mongodb::server::config': }
~> class { 'mongodb::server::service': }
-> anchor { 'mongodb::server::end': }
} else {
anchor { 'mongodb::server::start': }
-> class { 'mongodb::server::install': }
# If $restart is false, config changes won't restart the service (->)
-> class { 'mongodb::server::config': }
-> class { 'mongodb::server::service': }
-> anchor { 'mongodb::server::end': }
}
} else {
anchor { 'mongodb::server::start': }
-> class { '::mongodb::server::service': }
-> class { '::mongodb::server::config': }
-> class { '::mongodb::server::install': }
-> anchor { 'mongodb::server::end': }
}
if $create_admin {
validate_string($admin_password)
mongodb::db { 'admin':
user => $admin_username,
password => $admin_password,
roles => $admin_roles
}
# Make sure it runs at the correct point
Anchor['mongodb::server::end'] -> Mongodb::Db['admin']
# Make sure it runs before other DB creation
Mongodb::Db['admin'] -> Mongodb::Db <| title != 'admin' |>
}
# Set-up replicasets
if $replset {
# Check that we've got either a members array or a replset_config hash
if $replset_members and $replset_config {
fail('You can provide either replset_members or replset_config, not both.')
} elsif !$replset_members and !$replset_config {
# No members or config provided. Warn about it.
warning('Replset specified, but no replset_members or replset_config provided.')
} else {
if $replset_config {
validate_hash($replset_config)
# Copy it to REAL value
$_replset_config = $replset_config
} else {
validate_array($replset_members)
# Build up a config hash
$_replset_config = {
"${replset}" => {
'ensure' => 'present',
'members' => $replset_members
}
}
}
# Wrap the replset class
class { 'mongodb::replset':
sets => $_replset_config
}
$replset_config_REAL = $_replset_config # lint:ignore:variable_is_lowercase required for compatibility
Anchor['mongodb::server::end'] -> Class['mongodb::replset']
# Make sure that the ordering is correct
if $create_admin {
Class['mongodb::replset'] -> Mongodb::Db['admin']
}
}
}
}
|