@@ -30,24 +30,22 @@ class { 'mongodb::globals':
3030 class { 'mongodb::globals':
3131 #{ repo_ver_param }
3232 }
33+ -> class { 'mongodb::client': }
3334 -> class { 'mongodb::server':
3435 bind_ip => ['0.0.0.0'],
3536 replset => 'test',
3637 }
37- -> class { 'mongodb::client': }
38+ -> mongodb_replset { 'test':
39+ members => [#{ hosts . map { |x | "'#{ x } :27017'" } . join ( ',' ) } ],
40+ }
41+
3842 EOS
3943
40- apply_manifest_on ( hosts . reverse , pp , catch_failures : true )
41- apply_manifest_on ( hosts . reverse , pp , catch_changes : true )
44+ apply_manifest_on ( hosts , pp , catch_failures : true )
45+ apply_manifest_on ( hosts , pp , catch_changes : true )
4246 end
4347
4448 it 'sets up the replset with puppet' do
45- pp = <<-EOS
46- mongodb_replset { 'test':
47- members => [#{ hosts . map { |x | "'#{ x } :27017'" } . join ( ',' ) } ],
48- }
49- EOS
50- apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_failures : true )
5149 on ( hosts_as ( 'master' ) , 'mongosh --quiet --eval "EJSON.stringify(rs.conf())"' ) do |r |
5250 expect ( r . stdout ) . to match %r{#{ hosts [ 0 ] } :27017}
5351 expect ( r . stdout ) . to match %r{#{ hosts [ 1 ] } :27017}
@@ -101,12 +99,12 @@ class { 'mongodb::globals':
10199 class { 'mongodb::globals':
102100 #{ repo_ver_param }
103101 }
102+ -> class { 'mongodb::client': }
104103 -> class { 'mongodb::server':
105104 bind_ip => ['0.0.0.0'],
106105 replset => 'test',
107106 replset_members => [#{ hosts . map { |x | "'#{ x } :27017'" } . join ( ',' ) } ],
108107 }
109- -> class { 'mongodb::client': }
110108 EOS
111109
112110 apply_manifest_on ( hosts , pp , catch_failures : true )
@@ -176,6 +174,7 @@ class { 'mongodb::globals':
176174 class { 'mongodb::globals':
177175 #{ repo_ver_param }
178176 }
177+ -> class { 'mongodb::client': }
179178 -> class { 'mongodb::server':
180179 admin_username => 'admin',
181180 admin_password => 'password',
@@ -201,30 +200,29 @@ class { 'mongodb::globals':
201200 nc1ohyB0lNt8lHf1U00mtgDSV3fwo5LkwhRi6d+bDBTL/C6MZETMLdyCqDlTdUWG
202201 YXIsJ0gYcu9XG3mx10LbdPJvxSMg',
203202 }
204- -> class { 'mongodb::client': }
203+ -> mongodb_replset { 'test':
204+ members => [#{ hosts . map { |x | "'#{ x } :27017'" } . join ( ',' ) } ],
205+ }
206+
207+ unless $facts['mongodb_is_master'] == 'false' { # lint:ignore:quoted_booleans
208+ mongodb_user { "User admin on db admin":
209+ ensure => present,
210+ password_hash => mongodb_password('admin', 'password'),
211+ username => 'admin',
212+ database => 'admin',
213+ roles => ['userAdmin', 'readWrite', 'dbAdmin', 'dbAdminAnyDatabase', 'readAnyDatabase',
214+ 'readWriteAnyDatabase', 'userAdminAnyDatabase', 'clusterAdmin',
215+ 'clusterManager', 'clusterMonitor', 'hostManager', 'root', 'restore',],
216+ require => Mongodb_replset['test'],
217+ }
218+ }
205219 EOS
206220
207- apply_manifest_on ( hosts . reverse , pp , catch_failures : true )
208- apply_manifest_on ( hosts . reverse , pp , catch_changes : true )
221+ apply_manifest_on ( hosts , pp , catch_failures : true )
222+ apply_manifest_on ( hosts , pp , catch_changes : true )
209223 end
210224
211225 it 'sets up the replset with puppet' do
212- pp = <<~EOS
213- mongodb_replset { 'test':
214- members => [#{ hosts . map { |x | "'#{ x } :27017'" } . join ( ',' ) } ],
215- }
216- -> mongodb_user { "User admin on db admin":
217- ensure => present,
218- password_hash => mongodb_password('admin', 'password'),
219- username => 'admin',
220- database => 'admin',
221- roles => ['userAdmin', 'readWrite', 'dbAdmin', 'dbAdminAnyDatabase', 'readAnyDatabase',
222- 'readWriteAnyDatabase', 'userAdminAnyDatabase', 'clusterAdmin',
223- 'clusterManager', 'clusterMonitor', 'hostManager', 'root', 'restore',],
224- }
225- EOS
226- apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_failures : true )
227- apply_manifest_on ( hosts_as ( 'master' ) , pp , catch_changes : true )
228226 on ( hosts_as ( 'master' ) , 'mongosh --quiet --eval "load(\'/root/.mongoshrc.js\');EJSON.stringify(rs.conf())"' ) do |r |
229227 expect ( r . stdout ) . to match %r{#{ hosts [ 0 ] } :27017}
230228 expect ( r . stdout ) . to match %r{#{ hosts [ 1 ] } :27017}
0 commit comments