Skip to content

Commit ca4080b

Browse files
committed
server/config: convert mongoshrc.js template to EPP
Fixes #762.
1 parent f0188db commit ca4080b

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

manifests/server/config.pp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,10 @@
153153
}
154154
}
155155

156-
$admin_password_unsensitive = if $admin_password =~ Sensitive[String] {
157-
$admin_password.unwrap
158-
} else {
159-
$admin_password
160-
}
161156
if $handle_creds {
162157
file { $rcfile:
163158
ensure => file,
164-
content => template('mongodb/mongoshrc.js.erb'),
159+
content => epp("${module_name}/mongoshrc.js.epp"),
165160
owner => 'root',
166161
group => 'root',
167162
mode => '0600',
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function rsReconfigSettings(settings){
1616
return rs.reconfig(cfg)
1717
}
1818

19-
<% if @auth and @store_creds -%>
19+
<% if $mongodb::server::config::auth and $mongodb::server::config::store_creds { -%>
2020
function authRequired() {
2121
try {
2222
return rs.status().ok != 1;
@@ -29,12 +29,12 @@ function authRequired() {
2929
}
3030

3131
if (authRequired()) {
32-
<%- if @replset -%>
32+
<%- if $mongodb::server::config::replset { -%>
3333
db.getMongo().setReadPref('primaryPreferred')
34-
<%- end -%>
34+
<%- } -%>
3535
try {
3636
admin = db.getSiblingDB('admin')
37-
admin.auth('<%= @admin_username %>', '<%= @admin_password_unsensitive.gsub('\\','\\\\\\\\').gsub("'","\\\\'") %>')
37+
admin.auth('<%= $mongodb::server::config::admin_username %>', '<%= $mongodb::server::config::admin_password.regsubst('\\\\','\\\\\\\\','G').regsubst("'","\\\\'",'G') %>')
3838
}
3939
catch (err) {
4040
// Silently ignore this error, we can't really do anything about it.
@@ -44,4 +44,4 @@ if (authRequired()) {
4444
// This is normal when setting up a new cluster/server.
4545
}
4646
}
47-
<% end -%>
47+
<% } -%>

0 commit comments

Comments
 (0)