Skip to content

Commit

Permalink
SIRE-9538 remove un-needed versioncmp
Browse files Browse the repository at this point in the history
Reviewed-by: muspelkat
  • Loading branch information
Bernd Eilers committed Jun 23, 2023
1 parent c4b50c4 commit 2b7373b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
6 changes: 0 additions & 6 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
$tls_invalid_hostnames = $mongodb::server::tls_invalid_hostnames
$tls_mode = $mongodb::server::tls_mode
$storage_engine = $mongodb::server::storage_engine
$version = $mongodb::globals::version

File {
owner => $user,
Expand Down Expand Up @@ -175,11 +174,6 @@
$admin_password
}
if $handle_creds {
if versioncmp($version, '5.0') >= 0 {
$major_version_greater5 = true
} else {
$major_version_greater5 = false
}
file { $rcfile:
ensure => file,
content => template('mongodb/mongoshrc.js.erb'),
Expand Down
13 changes: 3 additions & 10 deletions templates/mongoshrc.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,13 @@ function authRequired() {

if (authRequired()) {
<%- if @replset -%>
// rs.slaveOk + rs secondaryOk have been deprecated, use setReadPref when running mongodb version >=5
try {
<%- if @major_version_greater5 -%>
db.getMongo().setReadPref('nearest')
<%- else -%>
rs.secondaryOk()
<%- end -%>
}
catch (err) {
rs.slaveOk()
db.getMongo().setReadPref('nearest')
} catch (err) {
rs.secondaryOk()
}
<% end -%>


<%- if @admin_auth_mechanism == 'x509' -%>
try {
db.getSiblingDB('$external').auth(
Expand Down

0 comments on commit 2b7373b

Please sign in to comment.