Skip to content

Commit d791e3d

Browse files
committed
Only create database and user when mongodb_is_master
1 parent 041bd39 commit d791e3d

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

manifests/db.pp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,26 @@
2020
Integer[0] $tries = 10,
2121
) {
2222

23-
mongodb_database { $db_name:
24-
ensure => present,
25-
tries => $tries,
26-
}
23+
if $facts['mongodb_is_master'] == 'true' { # lint:ignore:quoted_booleans
24+
mongodb_database { $db_name:
25+
ensure => present,
26+
tries => $tries,
27+
}
2728

28-
if $password_hash {
29-
$hash = $password_hash
30-
} elsif $password {
31-
$hash = mongodb_password($user, $password)
32-
} else {
33-
fail("Parameter 'password_hash' or 'password' should be provided to mongodb::db.")
34-
}
29+
if $password_hash {
30+
$hash = $password_hash
31+
} elsif $password {
32+
$hash = mongodb_password($user, $password)
33+
} else {
34+
fail("Parameter 'password_hash' or 'password' should be provided to mongodb::db.")
35+
}
3536

36-
mongodb_user { "User ${user} on db ${db_name}":
37-
ensure => present,
38-
password_hash => $hash,
39-
username => $user,
40-
database => $db_name,
41-
roles => $roles,
37+
mongodb_user { "User ${user} on db ${db_name}":
38+
ensure => present,
39+
password_hash => $hash,
40+
username => $user,
41+
database => $db_name,
42+
roles => $roles,
43+
}
4244
}
43-
4445
}

0 commit comments

Comments
 (0)