Skip to content

Commit 320c82d

Browse files
committed
Stop loading the /root/.mongorc.js when querying master state
Querying master state doesn't require authentication.
1 parent e7ecd03 commit 320c82d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/facter/is_master.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ def get_options_from_config(file)
4343
file = mongod_conf_file
4444
if file
4545
options = get_options_from_config(file)
46-
e = File.exist?('/root/.mongorc.js') ? 'load(\'/root/.mongorc.js\'); ' : ''
4746

4847
# Check if the mongodb server is responding:
49-
Facter::Core::Execution.exec("mongo --quiet #{options} --eval \"#{e}printjson(db.adminCommand({ ping: 1 }))\"")
48+
Facter::Core::Execution.exec("mongo --quiet #{options} --eval \"printjson(db.adminCommand({ ping: 1 }))\"")
5049

5150
if $CHILD_STATUS.success?
52-
Facter::Core::Execution.exec("mongo --quiet #{options} --eval \"#{e}db.isMaster().ismaster\"")
51+
Facter::Core::Execution.exec("mongo --quiet #{options} --eval \"db.isMaster().ismaster\"")
5352
else
5453
'not_responding'
5554
end

lib/puppet/provider/mongodb.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ def self.conn_string
137137

138138
def self.db_ismaster
139139
cmd_ismaster = 'db.isMaster().ismaster'
140-
cmd_ismaster = mongorc_file + cmd_ismaster if mongorc_file
141140
db = 'admin'
142141
res = mongo_cmd(db, conn_string, cmd_ismaster).to_s.split(%r{\n}).last.chomp
143142
res.eql?('true')

0 commit comments

Comments
 (0)