Puppet Class: mongodb::server

Inherits:
mongodb::params
Defined in:
manifests/server.pp

Overview

This installs a MongoDB server. See README.md for more details.

Parameters:

  • ensure (Any) (defaults to: $mongodb::params::ensure)
  • user (Any) (defaults to: $mongodb::params::user)
  • group (Any) (defaults to: $mongodb::params::group)
  • config (Any) (defaults to: $mongodb::params::config)
  • dbpath (Any) (defaults to: $mongodb::params::dbpath)
  • dbpath_fix (Any) (defaults to: $mongodb::params::dbpath_fix)
  • pidfilepath (Any) (defaults to: $mongodb::params::pidfilepath)
  • pidfilemode (Any) (defaults to: $mongodb::params::pidfilemode)
  • manage_pidfile (Any) (defaults to: $mongodb::params::manage_pidfile)
  • rcfile (Any) (defaults to: $mongodb::params::rcfile)
  • service_manage (Any) (defaults to: $mongodb::params::service_manage)
  • service_provider (Any) (defaults to: $mongodb::params::service_provider)
  • service_name (Any) (defaults to: $mongodb::params::service_name)
  • service_enable (Any) (defaults to: $mongodb::params::service_enable)
  • service_ensure (Any) (defaults to: $mongodb::params::service_ensure)
  • service_status (Any) (defaults to: $mongodb::params::service_status)
  • package_ensure (Any) (defaults to: $mongodb::params::package_ensure)
  • package_name (Any) (defaults to: $mongodb::params::server_package_name)
  • logpath (Any) (defaults to: $mongodb::params::logpath)
  • bind_ip (Any) (defaults to: $mongodb::params::bind_ip)
  • ipv6 (Any) (defaults to: undef)
  • logappend (Any) (defaults to: true)
  • system_logrotate (Any) (defaults to: undef)
  • fork (Any) (defaults to: $mongodb::params::fork)
  • port (Any) (defaults to: undef)
  • journal (Any) (defaults to: $mongodb::params::journal)
  • nojournal (Any) (defaults to: undef)
  • smallfiles (Any) (defaults to: undef)
  • cpu (Any) (defaults to: undef)
  • auth (Any) (defaults to: false)
  • noauth (Any) (defaults to: undef)
  • verbose (Any) (defaults to: undef)
  • verbositylevel (Any) (defaults to: undef)
  • objcheck (Any) (defaults to: undef)
  • quota (Any) (defaults to: undef)
  • quotafiles (Any) (defaults to: undef)
  • diaglog (Any) (defaults to: undef)
  • directoryperdb (Any) (defaults to: undef)
  • profile (Any) (defaults to: undef)
  • maxconns (Any) (defaults to: undef)
  • oplog_size (Any) (defaults to: undef)
  • nohints (Any) (defaults to: undef)
  • nohttpinterface (Any) (defaults to: undef)
  • noscripting (Any) (defaults to: undef)
  • notablescan (Any) (defaults to: undef)
  • noprealloc (Any) (defaults to: undef)
  • nssize (Any) (defaults to: undef)
  • mms_token (Any) (defaults to: undef)
  • mms_name (Any) (defaults to: undef)
  • mms_interval (Any) (defaults to: undef)
  • replset (Any) (defaults to: undef)
  • replset_config (Any) (defaults to: undef)
  • replset_members (Any) (defaults to: undef)
  • configsvr (Any) (defaults to: undef)
  • shardsvr (Any) (defaults to: undef)
  • rest (Any) (defaults to: undef)
  • quiet (Any) (defaults to: undef)
  • slowms (Any) (defaults to: undef)
  • keyfile (Any) (defaults to: undef)
  • key (Any) (defaults to: undef)
  • set_parameter (Any) (defaults to: undef)
  • syslog (Any) (defaults to: undef)
  • config_content (Any) (defaults to: undef)
  • config_template (Any) (defaults to: undef)
  • ssl (Any) (defaults to: undef)
  • ssl_key (Any) (defaults to: undef)
  • ssl_ca (Any) (defaults to: undef)
  • ssl_weak_cert (Any) (defaults to: false)
  • restart (Any) (defaults to: $mongodb::params::restart)
  • storage_engine (Any) (defaults to: undef)
  • create_admin (Any) (defaults to: $mongodb::params::create_admin)
  • admin_username (Any) (defaults to: $mongodb::params::admin_username)
  • admin_password (Any) (defaults to: undef)
  • handle_creds (Any) (defaults to: $mongodb::params::handle_creds)
  • store_creds (Any) (defaults to: $mongodb::params::store_creds)
  • admin_roles (Any) (defaults to: ['userAdmin', 'readWrite', 'dbAdmin', 'dbAdminAnyDatabase', 'readAnyDatabase', 'readWriteAnyDatabase', 'userAdminAnyDatabase', 'clusterAdmin', 'clusterManager', 'clusterMonitor', 'hostManager', 'root', 'restore'])
  • master (Any) (defaults to: undef)
  • slave (Any) (defaults to: undef)
  • only (Any) (defaults to: undef)
  • source (Any) (defaults to: undef)


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']
      }

    }
  }
}