|
69 | 69 | $ssl_ca = undef, |
70 | 70 | $restart = $mongodb::params::restart, |
71 | 71 | $storage_engine = undef, |
| 72 | + $version = $mongodb::params::version, |
72 | 73 |
|
73 | 74 | $create_admin = $mongodb::params::create_admin, |
74 | 75 | $admin_username = $mongodb::params::admin_username, |
75 | 76 | $admin_password = undef, |
76 | 77 | $store_creds = $mongodb::params::store_creds, |
77 | 78 | $admin_roles = ['userAdmin', 'readWrite', 'dbAdmin', |
78 | | - 'dbAdminAnyDatabase', 'readAnyDatabase', |
79 | | - 'readWriteAnyDatabase', 'userAdminAnyDatabase', |
80 | | - 'clusterAdmin', 'clusterManager', 'clusterMonitor', |
81 | | - 'hostManager', 'root', 'restore'], |
| 79 | + 'dbAdminAnyDatabase', 'readAnyDatabase', |
| 80 | + 'readWriteAnyDatabase', 'userAdminAnyDatabase', |
| 81 | + 'clusterAdmin', 'clusterManager', 'clusterMonitor', |
| 82 | + 'hostManager', 'root', 'restore'], |
82 | 83 |
|
83 | 84 | # Deprecated parameters |
84 | 85 | $master = undef, |
|
96 | 97 | if $restart { |
97 | 98 | anchor { 'mongodb::server::start': }-> |
98 | 99 | class { 'mongodb::server::install': }-> |
99 | | - # If $restart is true, notify the service on config changes (~>) |
| 100 | + # If $restart is true, notify the service on config changes (~>) |
100 | 101 | class { 'mongodb::server::config': }~> |
101 | 102 | class { 'mongodb::server::service': }-> |
102 | 103 | anchor { 'mongodb::server::end': } |
103 | 104 | } else { |
104 | 105 | anchor { 'mongodb::server::start': }-> |
105 | 106 | class { 'mongodb::server::install': }-> |
106 | | - # If $restart is false, config changes won't restart the service (->) |
| 107 | + # If $restart is false, config changes won't restart the service (->) |
107 | 108 | class { 'mongodb::server::config': }-> |
108 | 109 | class { 'mongodb::server::service': }-> |
109 | 110 | anchor { 'mongodb::server::end': } |
|
158 | 159 | } |
159 | 160 | } |
160 | 161 | } |
| 162 | + } |
161 | 163 |
|
162 | | - # Wrap the replset class |
163 | | - class { 'mongodb::replset': |
164 | | - sets => $replset_config_REAL |
165 | | - } |
166 | | - Anchor['mongodb::server::end'] -> Class['mongodb::replset'] |
| 164 | + # Wrap the replset class |
| 165 | + class { 'mongodb::replset': |
| 166 | + sets => $replset_config_REAL |
| 167 | + } |
| 168 | + Anchor['mongodb::server::end'] -> Class['mongodb::replset'] |
| 169 | + |
| 170 | + # Make sure that the ordering is correct |
| 171 | + if $create_admin { |
| 172 | + Class['mongodb::replset'] -> Mongodb::Db['admin'] |
| 173 | + if $::mongodb_is_master == 'not_installed' and $auth == true and $noauth != true and versioncmp($version, '2.6.0') >= 0 { |
| 174 | + file_line{ 'enable_authentication' : |
| 175 | + ensure => present, |
| 176 | + path => $config, |
| 177 | + match => 'security.authorization:', |
| 178 | + line => 'security.authorization: enabled', |
| 179 | + require => [Class['mongodb::replset'], Mongodb::Db['admin'] ] |
| 180 | + } |
| 181 | + if $keyfile { |
| 182 | + file_line{ 'enable_keyfile' : |
| 183 | + ensure => present, |
| 184 | + path => $config, |
| 185 | + line => "security.keyFile: ${keyfile}", |
| 186 | + require => [Class['mongodb::replset'], Mongodb::Db['admin']], |
| 187 | + notify => Exec['/sbin/restart mongod'] |
| 188 | + } |
| 189 | + } |
167 | 190 |
|
168 | | - # Make sure that the ordering is correct |
169 | | - if $create_admin { |
170 | | - Class['mongodb::replset'] -> Mongodb::Db['admin'] |
| 191 | + exec{ '/sbin/restart mongod': |
| 192 | + user => 'root', |
| 193 | + refreshonly => true, |
| 194 | + cwd => '/tmp', |
| 195 | + subscribe => File_line['enable_authentication'] |
| 196 | + } |
171 | 197 | } |
172 | | - |
173 | 198 | } |
| 199 | + |
174 | 200 | } |
175 | 201 | } |
0 commit comments